commit - c01470d76de8add2ac75ff1569941b9f997eaf06
commit + 01bc5d48c9c87c8feffb618640ae989586f58c09
blob - 81e527b15bf334d83848c0a41170935fb559e1f4
blob + a6030ec3030e55cb93190ae6502044171e9eb406
--- arp.c
+++ arp.c
* Set an individual arp entry
*/
int
-arpset(int argc, char *argv[])
+arpset(int argc, char *argv[], ...)
{
struct sockaddr_inarp *sin;
struct sockaddr_dl *sdl;
blob - 2a3c298673f93f97a419f91e4124069c9e698f95
blob + a6b11b3e6eb64a9ed76aba8e13c055b4c2c90bb4
--- bgpnsh/bgpnsh.c
+++ bgpnsh/bgpnsh.c
};
static int
-showcmd(int argc, char **argv)
+showcmd(int argc, char **argv, ...)
{
Menu *s; /* pointer to current command */
}
int
-quit(void)
+quit(int argc, char **argv, ...)
{
printf("%% Session terminated.\n");
exit(0);
blob - d1c00fab01ebd7b6d21509c07078eeb7d1141720
blob + 73f5434c3d252691502815908f2a4f3b33978c03
--- bridge.c
+++ bridge.c
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
+#include <stdarg.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/param.h>
};
int
-brport(char *ifname, int ifs, int argc, char **argv)
+brport(int argc, char **argv, ...)
{
int set, i;
struct brc *x;
+ va_list ap;
+ char *ifname;
+ int ifs;
+
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
if (NO_ARG(argv[0])) {
set = 0;
};
int
-brval(char *ifname, int ifs, int argc, char **argv)
+brval(int argc, char **argv, ...)
{
int set;
u_int32_t val = 0;
const char *errmsg = NULL;
struct brc *x;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argv++;
}
int
-brrule(char *ifname, int ifs, int argc, char **argv)
+brrule(int argc, char **argv, ...)
{
+ va_list ap;
+ char *ifname;
+ int ifs;
+
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
printf("%% all rules for a member must be applied in order\n");
printf("%% use flush bridge-rules <bridge> <member>\n");
}
int
-brstatic(char *ifname, int ifs, int argc, char **argv)
+brstatic(int argc, char **argv, ...)
{
int set;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argv++;
};
int
-brpri(char *ifname, int ifs, int argc, char **argv)
+brpri(int argc, char **argv, ...)
{
int set, val;
const char *errmsg = NULL;
struct brd *x;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argv++;
* flush wrappers here
*/
int
-flush_bridgedyn(char *brdg)
+flush_bridgedyn(int argc, char **argv, ...)
{
+ va_list ap;
+ char *brdg;
int ifs;
+ va_start(ap, argv);
+ brdg = va_arg(ap, char *);
+ va_end (ap);
+
ifs = socket(AF_INET, SOCK_DGRAM, 0);
if (ifs < 0) {
printf("%% socket: %s\n", strerror(errno));
}
int
-flush_bridgeall(char *brdg)
+flush_bridgeall(int argc, char **argv, ...)
{
+ va_list ap;
+ char *brdg;
int ifs;
+
+ va_start(ap, argv);
+ brdg = va_arg(ap, char *);
+ va_end(ap);
ifs = socket(AF_INET, SOCK_DGRAM, 0);
if (ifs < 0) {
}
int
-flush_bridgerule(char *brdg, char *member)
+flush_bridgerule(int argc, char **argv, ...)
{
+ va_list ap;
+ char *brdg, *member;
int ifs;
+ va_start(ap, argv);
+ brdg = va_arg(ap, char *);
+ member = va_arg(ap, char *);
+ va_end(ap);
+
ifs = socket(AF_INET, SOCK_DGRAM, 0);
if (ifs < 0) {
printf("%% socket: %s\n", strerror(errno));
}
int
-brprotect(char *ifname, int ifs, int argc, char **argv)
+brprotect(int argc, char **argv, ...)
{
int set;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argv++;
}
int
-show_bridges(int argc, char **argv)
+show_bridges(int argc, char **argv, ...)
{
switch (argc) {
case 2:
blob - 00d468e4f2977eda1ed8ea03f5c1659914056b36
blob + 7e74fed9a973e2c2fe7f76aa50d48faf1ca39404
--- carp.c
+++ carp.c
#include <stdio.h>
#include <stdlib.h>
+#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <sys/limits.h>
static const char *carp_bal_modes[] = { CARP_BAL_MODES };
int
-intcarp(char *ifname, int ifs, int argc, char **argv)
+intcarp(int argc, char **argv, ...)
{
const char *errmsg = NULL;
struct ifreq ifr;
struct carpreq creq;
int set, bal_mode = 0, val = 0;
struct intc *x;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argc--;
}
int
-intcpass(char *ifname, int ifs, int argc, char **argv)
+intcpass(int argc, char **argv, ...)
{
struct ifreq ifr;
struct carpreq creq;
int set;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argc--;
}
int
-intcnode(char *ifname, int ifs, int argc, char **argv)
+intcnode(int argc, char **argv, ...)
{
struct ifreq ifr;
struct carpreq creq;
const char *errmsg = NULL;
int set, i, last;
u_int vhid, advskew;
+ va_list ap;
+ char *ifname;
+ int ifs;
+
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
if (NO_ARG(argv[0])) {
set = 0;
}
int
-intcdev(char *ifname, int ifs, int argc, char **argv)
+intcdev(int argc, char **argv, ...)
{
struct ifreq ifr;
struct carpreq creq;
int set;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argc--;
blob - 5287c97ee9c9f53122b0ca88867d57acadfbe2da
blob + 58e53e15ac18acf7bfeb34903c17c935f6a4da37
--- commands.c
+++ commands.c
#include <string.h>
#include <errno.h>
#include <signal.h>
+#include <stdarg.h>
#include <sys/fcntl.h>
#include <sys/stat.h>
#include <sys/socket.h>
extern volatile sig_atomic_t caught_sigwinch;
-static int disable(void);
-static int clear(void);
-static int doverbose(int, char**);
-static int doediting(int, char**);
-static int doconfig(int, char**);
-static int exitconfig(int, char**);
-int rtable(int, char**);
-int group(int, char**);
-static int pr_crontab(int, char **, FILE *);
-static int pr_routes(int, char **);
-static int pr_routes6(int, char **);
-static int pr_arp(int, char **);
-static int pr_ndp(int, char **);
-static int pr_sadb(int, char **);
-static int pr_kernel(int, char **);
-static int pr_dhcp(int, char **);
-static int pr_conf(int, char **);
-static int pr_s_conf(int, char **);
-static int pr_a_conf(int, char **);
-static int pr_conf_diff(int, char **);
-static int pr_environment(int, char **);
-static int show_hostname(int, char **);
-static int wr_startup(void);
+static int disable(int, char **, ...);
+static int clear(int, char **, ...);
+static int doverbose(int, char**, ...);
+static int doediting(int, char**, ...);
+static int doconfig(int, char**, ...);
+static int exitconfig(int, char **, ...);
+static int rtable(int, char**, ...);
+static int pr_crontab(int, char **, ...);
+static int pr_routes(int, char **, ...);
+static int pr_routes6(int, char **, ...);
+static int pr_arp(int, char **, ...);
+static int pr_ndp(int, char **, ...);
+static int pr_sadb(int, char **, ...);
+static int pr_kernel(int, char **, ...);
+static int pr_dhcp(int, char **, ...);
+static int pr_conf(int, char **, ...);
+static int pr_s_conf(int, char **, ...);
+static int pr_a_conf(int, char **, ...);
+static int pr_conf_diff(int, char **, ...);
+static int pr_environment(int, char **, ...);
+static int show_hostname(int, char **, ...);
+static int wr_startup(int, char **, ...);
static int wr_conf(char *);
-static int sysctlhelp(int, char **, char **, int);
-static int flush_pf(char *);
-static int flush_help(void);
-static int flush_line(char *);
-static int flush_ip_routes(void);
-static int flush_arp_cache(void);
-static int flush_ndp_cache(void);
-static int flush_history(void);
+static int sysctlhelp(int, char **, ...);
+static int flush_pf(int, char **, ...);
+static int flush_help(int, char **, ...);
+static int flush_line(int, char **, ...);
+static int flush_ip_routes(int, char **, ...);
+static int flush_arp_cache(int, char **, ...);
+static int flush_ndp_cache(int, char **, ...);
+static int flush_history(int, char **, ...);
static int is_bad_input(const char *, size_t);
static int read_command_line(EditLine *, History *);
-static int int_logger(char *, int, int, char **);
-static int int_ping(char *, int, int, char **);
-static int int_ping6(char *, int, int, char **);
-static int int_traceroute(char *, int, int, char **);
-static int int_traceroute6(char *, int, int, char **);
-static int int_ssh(char *, int, int, char **);
-static int int_telnet(char *, int, int, char **);
-static int int_do(char *, int, int, char **);
-static int int_setenv(char *, int, int, char **);
-static int int_unsetenv(char *, int, int, char **);
-static int int_saveenv(char *, int, int, char **);
-static int int_show(char *, int, int, char **);
-static int int_who(char *, int, int, char **);
-static int int_doverbose(char *, int, int, char **);
-static int int_doediting(char *, int, int, char **);
-static int int_manual(char *, int, int, char **);
-static int int_shell(char *, int, int, char **);
-static int int_clear(void);
-static int int_help(void);
-static int int_exit(void);
-static int hostname(int, char **);
-static int logger(int, char **);
-static int manual(int, char**);
-static int nocmd(int, char **);
-static int docmd(int, char **);
-static int setenvcmd(int, char **);
-static int unsetenvcmd(int, char **);
-static int saveenvcmd(int, char **);
-static int shell(int, char*[]);
-static int ping(int, char*[]);
-static int ping6(int, char*[]);
-static int traceroute(int, char*[]);
-static int traceroute6(int, char*[]);
-static int ssh(int, char*[]);
-static int telnet(int, char*[]);
- void p_argv(int, char **);
-static int nreboot(void);
-static int halt(void);
-static int powerdown(void);
+static int int_logger(int, char **, ...);
+static int int_ping(int, char **, ...);
+static int int_ping6(int, char **, ...);
+static int int_traceroute(int, char **, ...);
+static int int_traceroute6(int, char **, ...);
+static int int_ssh(int, char **, ...);
+static int int_telnet(int, char **, ...);
+static int int_do(int, char **, ...);
+static int int_setenv(int, char **, ...);
+static int int_unsetenv(int, char **, ...);
+static int int_saveenv(int, char **, ...);
+static int int_show(int, char **, ...);
+static int int_who(int, char **, ...);
+static int int_doverbose(int, char **, ...);
+static int int_doediting(int, char **, ...);
+static int int_manual(int, char **, ...);
+static int int_shell(int, char ** ,...);
+static int int_clear(int, char **, ...);
+static int int_help(int, char **, ...);
+static int int_exit(int, char **, ...);
+static int hostname(int, char **, ...);
+static int logger(int, char **, ...);
+static int manual(int, char**, ...);
+static int nocmd(int, char **, ...);
+static int docmd(int, char **, ...);
+static int setenvcmd(int, char **, ...);
+static int unsetenvcmd(int, char **, ...);
+static int saveenvcmd(int, char **, ...);
+static int shell(int, char **, ...);
+static int ping(int, char **, ...);
+static int ping6(int, char**, ...);
+static int traceroute(int, char**, ...);
+static int traceroute6(int, char**, ...);
+static int ssh(int, char**, ...);
+static int telnet(int, char**, ...);
+ void p_argv(int, char **);
+static int nreboot(int, char **, ...);
+static int halt(int, char **, ...);
+static int powerdown(int, char **, ...);
static void pf_stats(void);
-static int int_interface(char *, int, int, char **);
+static int interface(int, char **, ...);
+static int int_interface(int, char **, ...);
#include "commands.h"
*/
int
-quit(void)
+quit(int argc, char **argv, ...)
{
if (privexec) {
exit(NSH_REXEC_EXIT_CODE_QUIT);
};
static int
-showcmd(int argc, char **argv)
+showcmd(int argc, char **argv, ...)
{
Menu *s; /* pointer to current command */
int error = 0, outfd = -1;
};
static int
-ipcmd(int argc, char **argv)
+ipcmd(int argc, char **argv, ...)
{
Menu *i; /* pointer to current command */
struct sysctltab *stab;
}
if (i->handler)
- success = (*i->handler)(set, argv[1],
+ success = (*i->handler)(set, &argv[1],
(i->maxarg > 0) ? argv[2] : 0, stab->pf);
return(success);
}
static int
-sysctlhelp(int unused1, char **unused2, char **unused3, int type)
+sysctlhelp(int unused1, char **unused2, ...)
{
Menu *i = NULL, *j = NULL; /* pointer to current command */
char *prefix = NULL;
u_int z = 0;
struct sysctltab *stab;
+ va_list ap;
+ char **unused3 = NULL;
+ int type;
+
+ va_start(ap, unused2);
+ unused3 = va_arg(ap, char **);
+ if (unused3) { /* silence "unused variable" compiler warning */ }
+ type = va_arg(ap, int);
+ va_end(ap);
for (stab = sysctls; stab->name != NULL; stab++)
if (stab->pf == type) {
};
static int
-flushcmd(int argc, char **argv)
+flushcmd(int argc, char **argv, ...)
{
Menu *f;
if (argc < 2) {
- flush_help();
+ flush_help(argc, argv);
return 0;
}
return 0;
}
if (f->handler)
- (*f->handler)((f->maxarg > 0) ? argv[2] : 0,
+ (*f->handler)(0, NULL, (f->maxarg > 0) ? argv[2] : 0,
(f->maxarg > 1) ? argv[3] : 0);
return(1);
}
static int
-flush_line(char *line)
+flush_line(int argc, char **argv, ...)
{
- char *argv[] = { PKILL, "-9", "-t", line, NULL };
- cmdargs(PKILL, argv);
+ va_list ap;
+ char *line;
+ char * args[5] = { PKILL, "-9", "-t", /* line */ NULL, NULL };
+
+ va_start(ap, argv);
+ line = va_arg(ap, char *);
+ va_end(ap);
+
+ args[3] = line;
+ cmdargs(PKILL, args);
return (1);
}
static int
-flush_help(void)
+flush_help(int argc, char **argv, ...)
{
Menu *f;
u_int z = 0;
* interface/bridge is being configured.
*/
static int
-interface(int argc, char **argv, char *modhvar)
+interface(int argc, char **argv, ...)
{
int ifs, set = 1;
char *tmp;
char *ifunit = NULL;
struct intlist *i; /* pointer to current command */
struct ifreq ifr;
+ va_list ap;
+ char *modhvar;
+ va_start(ap, argv);
+ modhvar = va_arg(ap, char *);
+ va_end(ap);
+
if (!modhvar) {
if (NO_ARG(argv[0])) {
argv++;
if (cli_rtable != 0 && nsh_setrtable(0) == 0)
cli_rtable = 0;
- ((*i->handler) (ifname, ifs, argc, argv));
+ (*i->handler)(argc, argv, ifname, ifs);
if (save_cli_rtable != cli_rtable &&
nsh_setrtable(cli_rtable) == 0)
if (cli_rtable != 0 && nsh_setrtable(0) == 0)
cli_rtable = 0;
- ret = (*i->handler) (ifname, ifs, margc, margv);
+ ret = (*i->handler)(margc, margv, ifname, ifs);
if (cli_rtable != save_cli_rtable &&
nsh_setrtable(cli_rtable) == 0)
}
static int
-int_interface(char *old_ifname, int ifs, int argc, char **argv)
+int_interface(int argc, char **argv, ...)
{
struct ifreq ifr;
char *new_ifname;
int set = 1;
+ va_list ap;
+ char *old_ifname;
+ int ifs;
+
+ va_start(ap, argv);
+ old_ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
if (NO_ARG(argv[0])) {
argv++;
}
static int
-int_logger(char *ifname, int ifs, int argc, char **argv)
+int_logger(int argc, char **argv, ...)
{
logger(argc, argv);
return 0; /* do not leave interface context */
}
-
static int
-int_ping(char *ifname, int ifs, int argc, char **argv)
+int_ping(int argc, char **argv, ...)
{
ping(argc, argv);
return 0; /* do not leave interface context */
}
static int
-int_ping6(char *ifname, int ifs, int argc, char **argv)
+int_ping6(int argc, char **argv, ...)
{
ping6(argc, argv);
return 0; /* do not leave interface context */
}
static int
-int_traceroute(char *ifname, int ifs, int argc, char **argv)
+int_traceroute(int argc, char **argv, ...)
{
traceroute(argc, argv);
return 0; /* do not leave interface context */
}
static int
-int_traceroute6(char *ifname, int ifs, int argc, char **argv)
+int_traceroute6(int argc, char **argv, ...)
{
traceroute6(argc, argv);
return 0; /* do not leave interface context */
}
static int
-int_ssh(char *ifname, int ifs, int argc, char **argv)
+int_ssh(int argc, char **argv, ...)
{
ssh(argc, argv);
return 0; /* do not leave interface context */
}
static int
-int_telnet(char *ifname, int ifs, int argc, char **argv)
+int_telnet(int argc, char **argv, ...)
{
telnet(argc, argv);
return 0; /* do not leave interface context */
}
static int
-int_do(char *ifname, int ifs, int argc, char **argv)
+int_do(int argc, char **argv, ...)
{
docmd(argc, argv);
return 0; /* do not leave interface context */
}
static int
-int_setenv(char *ifname, int ifs, int argc, char **argv)
+int_setenv(int argc, char **argv, ...)
{
setenvcmd(argc, argv);
return 0; /* do not leave interface context */
}
static int
-int_unsetenv(char *ifname, int ifs, int argc, char **argv)
+int_unsetenv(int argc, char **argv, ...)
{
unsetenvcmd(argc, argv);
return 0; /* do not leave interface context */
}
static int
-int_saveenv(char *ifname, int ifs, int argc, char **argv)
+int_saveenv(int argc, char **argv, ...)
{
saveenvcmd(argc, argv);
return 0; /* do not leave interface context */
}
static int
-int_show(char *ifname, int ifs, int argc, char **argv)
+int_show(int argc, char **argv, ...)
{
showcmd(argc, argv);
return 0; /* do not leave interface context */
}
static int
-int_who(char *ifname, int ifs, int argc, char **argv)
+int_who(int argc, char **argv, ...)
{
who(argc, argv);
return 0; /* do not leave interface context */
}
static int
-int_doverbose(char *ifname, int ifs, int argc, char **argv)
+int_doverbose(int argc, char **argv, ...)
{
doverbose(argc, argv);
return 0; /* do not leave interface context */
}
static int
-int_doediting(char *ifname, int ifs, int argc, char **argv)
+int_doediting(int argc, char **argv, ...)
{
doediting(argc, argv);
return 0; /* do not leave interface context */
}
static int
-int_manual(char *ifname, int ifs, int argc, char **argv)
+int_manual(int argc, char **argv, ...)
{
manual(argc, argv);
return 0; /* do not leave interface context */
}
static int
-int_shell(char *ifname, int ifs, int argc, char **argv)
+int_shell(int argc, char **argv, ...)
{
if (argc >1)
{
}
static int
-int_clear(void)
+int_clear(int argc, char **argv, ...)
{
- clear();
+ return clear(argc, argv);
}
static int
-int_help(void)
+int_help(int argc, char **argv, ...)
{
struct intlist *i; /* pointer to current command */
u_int z = 0;
}
static int
-int_exit(void)
+int_exit(int argc, char **argv, ...)
{
return 1; /* leave interface config mode */
}
if (feof(stdin) || ferror(stdin)) {
if (interactive_mode)
printf("\n");
- (void) quit();
+ (void) quit(0, NULL);
/* NOTREACHED */
}
break;
}
static int
-manual(int argc, char **argv)
+manual(int argc, char **argv, ...)
{
sig_t sigint, sigquit, sigchld;
char term[32], *termenv = NULL;
/*
* Hostname command.
*/
-int
-hostname(int argc, char **argv)
+static int
+hostname(int argc, char **argv, ...)
{
argv++;
argc--;
return 0;
}
-int show_hostname(int argc, char **argv)
+static int
+show_hostname(int argc, char **argv, ...)
{
if (gethostname(hbuf, sizeof(hbuf)))
printf("%% gethostname: %s\n", strerror(errno));
return 0;
}
+
/* logger command */
-
-
int
-logger(int argc, char *argv[])
+logger(int argc, char *argv[], ...)
{
if (argc < 2) {
printf("%% Invalid arguments\n");
* This is a pseudo command table entry used for TAB-completion purposes.
*/
static int
-nocmd(int argc, char **argv)
+nocmd(int argc, char **argv, ...)
{
Command *cmd = NULL, *c;
* switches which offer a "do" command for context switching.
*/
static int
-docmd(int argc, char **argv)
+docmd(int argc, char **argv, ...)
{
if (argc < 2) {
printf("%% command name not provided\n");
if (cli_rtable != 0 && nsh_setrtable(cli_rtable) == 0)
cli_rtable = 0;
- ((*i->handler) (ifname, ifs, argc, argv));
+ (*i->handler)(argc, argv, ifname, ifs);
if (save_cli_rtable != cli_rtable &&
nsh_setrtable(cli_rtable) == 0)
}
static int
-setenvcmd(int argc, char **argv)
+setenvcmd(int argc, char **argv, ...)
{
char *name, *eq, *value;
void *name0;
}
static int
-unsetenvcmd(int argc, char **argv)
+unsetenvcmd(int argc, char **argv, ...)
{
char *name;
void *name0;
}
static int
-saveenvcmd(int argc, char **argv)
+saveenvcmd(int argc, char **argv, ...)
{
char tmppath[PATH_MAX], path[PATH_MAX];
FILE *f;
/*
* Shell command.
*/
-int
-shell(int argc, char **argv)
+static int
+shell(int argc, char **argv, ...)
{
sig_t sigint, sigquit, sigchld;
* ping command.
*/
int
-ping(int argc, char *argv[])
+ping(int argc, char *argv[], ...)
{
if (argc < 2) {
printf("%% Invalid arguments\n");
}
int
-ping6(int argc, char *argv[])
+ping6(int argc, char *argv[], ...)
{
if (argc < 2) {
printf("%% Invalid arguments\n");
* telnet command.
*/
int
-telnet(int argc, char *argv[])
+telnet(int argc, char *argv[], ...)
{
if (argc < 2) {
printf("%% Invalid arguments\n");
* ssh command.
*/
int
-ssh(int argc, char *argv[])
+ssh(int argc, char *argv[], ...)
{
if (argc < 2) {
printf("%% Invalid arguments\n");
* traceroute command.
*/
int
-traceroute(int argc, char *argv[])
+traceroute(int argc, char *argv[], ...)
{
if (argc < 2) {
printf("%% Invalid arguments\n");
}
int
-traceroute6(int argc, char *argv[])
+traceroute6(int argc, char *argv[], ...)
{
if (argc < 2) {
printf("%% Invalid arguments\n");
return i;
}
-int
-rtable(int argc, char **argv)
+static int
+rtable(int argc, char **argv, ...)
{
int table, set, pos, found, curtable;
const char *errstr;
* Group attribute command.
*/
int
-group(int argc, char **argv)
+group(int argc, char **argv, ...)
{
int counter = 1, set, ifs;
const char *errstr;
}
//clear terminal screen
-int
-clear(void)
+static int
+clear(int argc, char **argv, ...)
{
- char *argv[] = {CLEAR, NULL, NULL };
- cmdargs(CLEAR, argv);
+ char *args[] = {CLEAR, NULL, NULL };
+ cmdargs(CLEAR, args);
return 0;
}
/*
* disable privileged mode
*/
-int
-disable(void)
+static int
+disable(int argc, char **argv, ...)
{
if (privexec) {
exit(0);
/*
* verbose diagnostics
*/
-int
-doverbose(int argc, char **argv)
+static int
+doverbose(int argc, char **argv, ...)
{
if (argc > 1) {
if (NO_ARG(argv[0])) {
return 0;
}
-int
-doediting(int argc, char **argv)
+static int
+doediting(int argc, char **argv, ...)
{
if (argc > 1) {
if (NO_ARG(argv[0])) {
return 0;
}
-int
-doconfig(int argc, char **argv)
+static int
+doconfig(int argc, char **argv, ...)
{
if (argc > 1) {
if (NO_ARG(argv[0])) {
return 0;
}
-int
-exitconfig(int argc, char **argv)
+static int
+exitconfig(int argc, char **argv, ...)
{
if (!config_mode) {
printf ("%% Configuration mode is already disabled\n");
}
int
-flush_history(void)
+flush_history(int argc, char **argv, ...)
{
if (!editing) {
printf("%% Command line editing not enabled\n");
/*
* pf toilet flusher
*/
-int
-flush_pf(char *arg)
+static int
+flush_pf(int argc, char **argv, ...)
{
struct fpf *x;
+ va_list ap;
+ char *arg;
+ va_start(ap, argv);
+ arg = va_arg(ap, char *);
+ va_end(ap);
+
if (!arg || arg[0] == '?') {
gen_help((char **)fpfs, "flush pf", "flush",
sizeof(struct fpf));
}
int
-wr_startup(void)
+wr_startup(int argc, char **argv, ...)
{
- char *argv[] = { SAVESCRIPT, NSHRC_TEMP, NULL };
+ char *args[] = { SAVESCRIPT, NSHRC_TEMP, NULL };
if (wr_conf(NSHRC_TEMP))
printf("%% Saving configuration\n");
printf("%% Unable to save configuration: %s\n",
strerror(errno));
- cmdargs(SAVESCRIPT, argv);
+ cmdargs(SAVESCRIPT, args);
return(1);
}
* Reboot
*/
int
-nreboot(void)
+nreboot(int argc, char **argv, ...)
{
return do_reboot(RB_AUTOBOOT);
}
int
-halt(void)
+halt(int argc, char **argv, ...)
{
return do_reboot(RB_HALT);
}
int
-powerdown(void)
+powerdown(int argc, char **argv, ...)
{
return do_reboot(RB_POWERDOWN);
}
+
/*
* Flush wrappers
*/
-int
-flush_ip_routes(void)
+static int
+flush_ip_routes(int argc, char **argv, ...)
{
flushroutes(AF_INET, AF_INET);
return(0);
}
-int
-flush_arp_cache(void)
+static int
+flush_arp_cache(int argc, char **argv, ...)
{
flushroutes(AF_INET, AF_LINK);
return(0);
}
-int
-flush_ndp_cache(void)
+static int
+flush_ndp_cache(int argc, char **argv, ...)
{
ndpdump(NULL, 1);
return(0);
/*
* Show wrappers
*/
-int
-pr_conf(int argc, char **argv)
+static int
+pr_conf(int argc, char **argv, ...)
{
if (priv != 1) {
printf ("%% Privilege required\n");
/*
* Show startup config
*/
-int
-pr_s_conf(int argc, char **argv)
+static int
+pr_s_conf(int argc, char **argv, ...)
{
int ret;
* Show running-config for the active context.
* Currently only supports the interface/bridge context.
*/
-int
-pr_a_conf(int argc, char **argv)
+static int
+pr_a_conf(int argc, char **argv, ...)
{
if (priv != 1) {
printf ("%% Privilege required\n");
/*
* Show differences between startup and running config.
*/
-int
-pr_conf_diff(int argc, char **argv)
+static int
+pr_conf_diff(int argc, char **argv, ...)
{
int conf_fd = -1, diff_fd = -1;
char confpath[PATH_MAX];
}
static int
-pr_crontab(int argc, char **argv, FILE *outfile)
+pr_crontab(int argc, char **argv, ...)
{
char *crontab_argv[] = { CRONTAB, "-l", "-u", "root", NULL };
+ va_list ap;
+ FILE *outfile;
+ va_start(ap, argv);
+ outfile = va_arg(ap, FILE *);
+ va_end(ap);
+
if (priv != 1) {
printf("%% Privilege required\n");
return 0 ;
return 0;
}
-int
-pr_routes(int argc, char **argv)
+static int
+pr_routes(int argc, char **argv, ...)
{
switch(argc) {
case 2:
return 0;
}
-int
-pr_routes6(int argc, char **argv)
+static int
+pr_routes6(int argc, char **argv, ...)
{
switch(argc) {
case 2:
}
int
-pr_arp(int argc, char **argv)
+pr_arp(int argc, char **argv, ...)
{
switch(argc) {
case 2:
return 0;
}
-int
-pr_ndp(int argc, char **argv)
+static int
+pr_ndp(int argc, char **argv, ...)
{
switch(argc) {
case 2:
return 0;
}
-int
-pr_sadb(int argc, char **argv)
+static int
+pr_sadb(int argc, char **argv, ...)
{
p_rttables(PF_KEY, 0, 0);
return 0;
}
-int
-pr_kernel(int argc, char **argv)
+static int
+pr_kernel(int argc, char **argv, ...)
{
struct stt *x;
return;
}
-int
-pr_dhcp(int argc, char **argv)
+static int
+pr_dhcp(int argc, char **argv, ...)
{
if (argc == 3 && argv[2][0] != '?') {
if (isprefix(argv[2], "leases")) {
}
static int
-pr_environment(int argc, char **argv)
+pr_environment(int argc, char **argv, ...)
{
extern char **environ;
char **ep;
blob - 538228794818b95a085bd5e3aa46337a017832b2
blob + e3eb2326a9df857f929d08aa1b33f7ae983b6dde
--- commands.h
+++ commands.h
extern char bgpd_socket_path[PATH_MAX];
void init_bgpd_socket_path(int);
extern struct prot prots[];
-int show_help(int, char **);
+int show_help(int, char **, ...);
Command *getcmd(char *);
extern Menu showlist[];
void makeargv(void);
extern void sigalarm(int);
extern char hbuf[MAXHOSTNAMELEN];
extern char ifname[IFNAMSIZ];
-int help(int, char**);
+int help(int, char **, ...);
blob - 45e48e3aac7ea6216f5f45d3920d8d040bceafee
blob + 9270b99463cb1ad4a9e4150d2f673a0608250db5
--- ctl.c
+++ ctl.c
#include <errno.h>
#include <libgen.h>
#include <histedit.h>
+#include <stdarg.h>
#include <sys/signal.h>
#include <sys/types.h>
#include <sys/stat.h>
/* table variable (for pkill usage) */
static char table[16];
-/* service routines */
-void edit_crontab(char *);
-void install_crontab(char *);
-void edit_motd(char *);
-void call_editor(char *, char **, char *);
-void start_dhcpd(char *, char *, char *, char *, char *);
-void restart_dhcpd(char *, char *, char *, char *, char *);
+/* service routines, used as handlers in struct ctl */
+void edit_crontab(int, char **, ...);
+void install_crontab(int, char **, ...);
+void edit_motd(int, char **, ...);
+void call_editor(int, char **, ...);
+void start_dhcpd(int, char **, ...);
+void restart_dhcpd(int, char **, ...);
+
+/* subroutines */
+int fill_tmpfile(char **, char *, char **);
int edit_file(char *, mode_t, char *, char **);
-void ctl_symlink(char *, char *, char *);
int rule_writeline(char *, mode_t, char *);
-int fill_tmpfile(char **, char *, char **);
int acq_lock(char *);
void rls_lock(int);
{ PFCTL, "-d", NULL }, { NULL }, NULL, DB_X_DISABLE, T_EXEC },
{ "edit", "edit, test and stage firewall rules",
{ "pf", NULL },
- { PFCTL, "-nf", REQTEMP, NULL }, call_editor, 0, T_HANDLER_FILL1 },
+ { PFCTL, "-nf", REQTEMP, NULL }, call_editor, 0, T_HANDLER_TEST },
{ "check-config", "test and display staged firewall rules",
{ PFCTL, "-nvvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
{ "reload", "test and apply staged firewall rules",
T_EXEC },
{ "edit", "edit, test and stage OSPFd config",
{ "ospf", NULL },
- { OSPFD, "-nf", REQTEMP, NULL }, call_editor, 0, T_HANDLER_FILL1 },
+ { OSPFD, "-nf", REQTEMP, NULL }, call_editor, 0, T_HANDLER_TEST },
{ "check-config", "test staged OSPFd config",
{ OSPFD, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
{ "reload", "test and appy staged OSPFd config",
T_EXEC },
{ "edit", "edit, test and stage OSPF6d config",
{ "ospf6", NULL }, { OSPF6D, "-nf", REQTEMP, NULL },
- call_editor, 0, T_HANDLER_FILL1 },
+ call_editor, 0, T_HANDLER_TEST },
{ "check-config", "test staged OSPF6d config",
{ OSPF6D, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
{ "reload", "test and apply staged OSPF6d config",
T_EXEC },
{ "edit", "edit, test and stage EIGRPd config",
{ "eigrp", NULL }, { EIGRPD, "-nf", REQTEMP, NULL },
- call_editor, 0, T_HANDLER_FILL1 },
+ call_editor, 0, T_HANDLER_TEST },
{ "check-config", "test staged EIGRPd config",
{ EIGRPD, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
{ "reload", "test and apply stagged EIGRPd config",
{ PKILL, "bgpd", NULL }, { NULL }, NULL, DB_X_DISABLE, T_EXEC },
{ "edit", "edit, test and stage OpenBGPD config",
{ "bgp", NULL }, { BGPD, "-nf", REQTEMP, NULL, NULL },
- call_editor, 0, T_HANDLER_FILL1 },
+ call_editor, 0, T_HANDLER_TEST },
{ "check-config", "test staged OpenBGPD config",
{ BGPD, "-nvf",REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
{ "reload", "test and apply staged OpenBGPD config",
{ PKILL, table, "ripd", NULL }, { NULL }, NULL, DB_X_DISABLE, T_EXEC },
{ "edit", "edit, test and stage RIPd config",
{ "rip", NULL }, { RIPD, "-nf", REQTEMP, NULL },
- call_editor, 0, T_HANDLER_FILL1 },
+ call_editor, 0, T_HANDLER_TEST },
{ "check-config", "test staged RIPd config",
{ RIPD, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
{ "reload", "test and apply staged ripd config",
{ PKILL, "ldpd", NULL }, { NULL }, NULL, DB_X_DISABLE, T_EXEC },
{ "edit", "edit, test and stage LDPd config",
{ "ldp", NULL }, { LDPD, "-nf", REQTEMP, NULL },
- call_editor, 0, T_HANDLER_FILL1 },
+ call_editor, 0, T_HANDLER_TEST },
{ "check-config", "test staged LDPd config",
{ LDPD, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
{ "reload", "test and apply staged LDPd config",
T_EXEC },
{ "edit", "edit, test and stage isakmpd config",
{ "ipsec", NULL }, { IPSECCTL, "-nf", REQTEMP, NULL },
- call_editor, 0, T_HANDLER_FILL1 },
+ call_editor, 0, T_HANDLER_TEST },
{ "check-config", "test staged isakmpd config",
{ IPSECCTL, "-nvvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
{ "reload", "test and apply staged isakmpd config",
{ IKECTL, "decouple", NULL }, { NULL }, NULL, 0, T_EXEC },
{ "edit", "edit, test and stage IKEd config",
{ "ike", NULL }, { IKED, "-nf", REQTEMP, NULL },
- call_editor, 0, T_HANDLER_FILL1 },
+ call_editor, 0, T_HANDLER_TEST },
{ "check-config", "test IKEd config",
{ IKED, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
{ "reload", "test and apply IKEd config",
T_EXEC },
{ "edit", "edit,test and stage DVMRPd config",
{ "dvmrp", NULL }, { DVMRPD, "-nf", REQTEMP, NULL },
- call_editor, 0, T_HANDLER_FILL1 },
+ call_editor, 0, T_HANDLER_TEST },
{ "config-test", "test staged DVMRPd config",
{ DVMRPD, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
{ "log", "configure DVMRPd logging, brief/verbose",
{ PKILL, "rad", NULL }, { NULL }, NULL, DB_X_DISABLE, T_EXEC },
{ "edit", "edit,test and stage RAD config",
{ "rad", NULL}, { RAD, "-nf", REQTEMP, NULL },
- call_editor, 0, T_HANDLER_FILL1 },
+ call_editor, 0, T_HANDLER_TEST },
{ "check-config", "test staged RAD config",
{ RAD, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
{ NULL, NULL, { NULL }, { NULL }, NULL, 0, 0 }
T_EXEC },
{ "edit", "edit, test and stage ifstated config",
{ "ifstate", NULL }, { IFSTATED, "-nf", REQTEMP, NULL },
- call_editor, 0, T_HANDLER_FILL1 },
+ call_editor, 0, T_HANDLER_TEST },
{ "config-test", "test staged ifstated config ",
{ IFSTATED, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
{ NULL, NULL, { NULL }, { NULL }, NULL, 0, 0 }
T_EXEC },
{ "edit", "edit, test and stage SAsyncd config",
{ "sasync", NULL }, { SASYNCD, "-nvvc", REQTEMP, NULL },
- call_editor, 0, T_HANDLER_FILL1 },
+ call_editor, 0, T_HANDLER_TEST },
{ "check-config", "test staged SAsyncd config",
{ SASYNCD, "-nvvc", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
{ NULL, NULL, { NULL }, { NULL }, NULL, 0, 0 }
T_EXEC },
{ "edit", "edit ,test and stage nPPPd config",
{ "nppp", NULL }, { NPPPD, "-nf", REQTEMP, NULL },
- call_editor, 0, T_HANDLER_FILL1 },
+ call_editor, 0, T_HANDLER_TEST },
{ "check-config", "test staged nPPPd config",
{ NPPPD, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
{ NULL, NULL, { NULL }, { NULL }, NULL, 0, 0 }
DB_X_DISABLE, T_EXEC },
{ "edit", "edit,test and stage DHCPd config",
{ "dhcp", NULL }, { DHCPD, "-nc", REQTEMP, NULL }, call_editor, 0,
- T_HANDLER_FILL1 },
+ T_HANDLER_TEST },
{ "config-test", "test staged DHCPd config",
{ DHCPD, "-nc", REQTEMP, "-l", DHCPLEASES, NULL }, { NULL },
NULL, 0, T_EXEC },
T_EXEC },
{ "edit", "edit,test and stage OpenSNMPD config",
{ "snmp", NULL }, { SNMPD, "-nf", REQTEMP, NULL },
- call_editor, 0, T_HANDLER_FILL1 },
+ call_editor, 0, T_HANDLER_TEST },
{ "config-test", "test staged OpenSNMPD config",
{ SNMPD, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
{ NULL, NULL, { NULL }, { NULL }, NULL, 0, 0 }
DB_X_DISABLE, T_EXEC },
{ "edit", "edit, test and stage OpenSSHD config",
{ "sshd", NULL }, { SSHD, "-tf", REQTEMP, NULL }, call_editor, 0,
- T_HANDLER_FILL1 },
+ T_HANDLER_TEST },
{ "config-test", "test staged OpenSSHD config",
{ SSHD, "-tf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
{ NULL, NULL, { NULL }, { NULL }, NULL, 0, 0 }
{ PKILL, "ntpd", NULL }, { NULL }, NULL, DB_X_DISABLE, T_EXEC },
{ "edit", "edit, test and stage OpenNTPD config",
{ "ntp", NULL }, { NTPD, "-nf", REQTEMP, NULL },
- call_editor, 0, T_HANDLER_FILL1 },
+ call_editor, 0, T_HANDLER_TEST },
{ "check-config", "test staged OpenNTPD config",
{ NTPD, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
{ NULL, NULL, { NULL }, { NULL }, NULL, 0, 0 }
T_EXEC },
{ "edit", "edit, test and stage relayd config",
{ "relay", NULL }, { RELAYD, "-nf", REQTEMP, NULL },
- call_editor, 0, T_HANDLER_FILL1 },
+ call_editor, 0, T_HANDLER_TEST },
{ "check-config", "test staged relayd config",
{ RELAYD, "-nvf", REQTEMP, NULL }, { NULL}, NULL, 0, T_EXEC },
{ "reload", "test and apply staged relayd config",
T_EXEC },
{ "edit", "edit,test and stage OpenSMTPD config",
{ "smtp", NULL }, { SMTPD, "-nf", REQTEMP, NULL },
- call_editor, 0, T_HANDLER_FILL1 },
+ call_editor, 0, T_HANDLER_TEST },
{ "config-test", "test OpenSMTPD config",
{ SMTPD, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
{ "log", "set OpenSMTPD logging brief/verbose config",
{ PKILL, table, "inetd", NULL }, { NULL }, NULL, DB_X_DISABLE,
T_EXEC },
{ "edit", "edit inetd superserver config",
- { "inet", NULL, NULL }, { NULL }, call_editor, 0, T_HANDLER_FILL1 },
+ { "inet", NULL, NULL }, { NULL }, call_editor, 0, T_HANDLER_TEST },
{ NULL, NULL, { NULL }, { NULL }, NULL, 0, 0 }
};
T_EXEC },
{ "edit", "edit, test and stage LDAPd config",
{ "ldap", NULL }, { LDAPD, "-nf", REQTEMP, NULL },
- call_editor, 0, T_HANDLER_FILL1 },
+ call_editor, 0, T_HANDLER_TEST },
{ "config-test", "test staged LDAPd config",
{ LDAPD, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
{ "log", "config LDAPd logging, brief/verbose",
{ NULL, NULL, { NULL }, { NULL }, NULL, 0, 0 }
};
-void
-ctl_symlink(char *temp, char *real, char *z)
-{
- rmtemp(temp);
- symlink(real, temp);
-}
-
/* flag to other nsh sessions or nsh conf() that actions have been taken */
void
flag_x(char *name, char *daemon, int dbflag, char *data)
/* the main entry point into ctl.c from CLI */
int
-ctlhandler(int argc, char **argv, char *modhvar)
+ctlhandler(int argc, char **argv, ...)
{
struct daemons *daemons;
struct ctl *x;
char **fillargs;
int rv = 0;
int nargs;
+ va_list ap;
+ char *modhvar;
+ va_start(ap, argv);
+ modhvar = va_arg(ap, char *);
+ va_end(ap);
+
/* loop daemon list to find table pointer */
daemons = (struct daemons *) genget(hname, (char **)ctl_daemons,
sizeof(struct daemons));
case T_HANDLER:
/* pointer to handler routine, fill main args */
nargs = fill_tmpfile(fillargs, tmpfile, tmp_args);
- switch (nargs) {
- case 0:
- (*x->handler)();
- break;
- case 1:
- (*x->handler)(tmp_args[0]);
- break;
- case 2:
- (*x->handler)(tmp_args[0], tmp_args[1]);
- break;
- case 3:
- (*x->handler)(tmp_args[0], tmp_args[1], tmp_args[2]);
- break;
- case 4:
- (*x->handler)(tmp_args[0], tmp_args[1], tmp_args[2],
- tmp_args[3]);
- break;
- case 5:
- (*x->handler)(tmp_args[0], tmp_args[1], tmp_args[2],
- tmp_args[3], tmp_args[4]);
- break;
- case 6:
- (*x->handler)(tmp_args[0], tmp_args[1], tmp_args[2],
- tmp_args[3], tmp_args[4], tmp_args[5]);
- break;
- case NOPTFILL: /* bump this when adding more cases */
- default:
+ /* bump NOPTFILL when adding more arguments */
+ if (nargs < NOPTFILL) {
+ (*x->handler)(nargs, tmp_args);
+ } else {
printf("%% handler %s %s requires too many "
"arguments: %d\n", hname, argv[1], nargs);
break;
}
break;
- case T_HANDLER_FILL1:
- /* pointer to handler routine, fill args @ args[1] pointer */
+ case T_HANDLER_TEST:
+ /* pointer to handler with a test command, fill test args */
if (fill_tmpfile(x->test_args, tmpfile, tmp_args))
- (*x->handler)(fillargs[0], tmp_args, fillargs[2]);
+ (*x->handler)(1, &fillargs[0], tmp_args);
else
- (*x->handler)(fillargs[0], x->test_args, fillargs[2]);
+ (*x->handler)(1, &fillargs[0], x->test_args);
break;
case T_EXEC:
/* command to execute via execv syscall, fill main args */
}
void
-restart_dhcpd(char *arg0, char *arg1, char *arg2, char *arg3, char *arg4)
+restart_dhcpd(int argc, char **argv, ...)
{
char *argv_pkill[] = { PKILL, table, "dhcpd", NULL };
cmdargs(argv_pkill[0], argv_pkill);
sleep(1);
- start_dhcpd(arg0, arg1, arg2, arg3, arg4);
+ start_dhcpd(argc, argv);
}
/*
}
void
-edit_crontab(char *name)
+edit_crontab(int argc, char **argv, ...)
{
+ char *name = argv[0];
char *crontab_argv[] = { CRONTAB, "-u", "root", "-l", NULL };
char tmpfile[PATH_MAX];
int found = 0;
}
void
-install_crontab(char *name)
+install_crontab(int argc, char **argv, ...)
{
+ char *name = argv[0];
char *crontab_argv[] = { CRONTAB, "-u", "root", NULL, NULL };
char tmpfile[PATH_MAX];
int fd, found = 0;
}
void
-edit_motd(char *name)
+edit_motd(int argc, char **argv, ...)
{
- call_editor(name, NULL, NULL);
+ call_editor(argc, argv);
}
void
-call_editor(char *name, char **args, char *z)
+call_editor(int argc, char **argv, ...)
{
+ char *name = argv[0];
int found = 0;
char tmpfile[64];
struct daemons *daemons;
+ va_list ap;
+ char **args;
+ va_start(ap, argv);
+ args = va_arg(ap, char **);
+ va_end(ap);
+
for (daemons = ctl_daemons; daemons->name != 0; daemons++) {
if (strncmp(daemons->name, name, strlen(name)) == 0) {
found = 1;
}
void
-start_dhcpd(char *arg0, char *arg1, char *arg2, char *arg3, char *arg4)
+start_dhcpd(int argc, char **argv, ...)
{
struct if_nameindex *ifn_list, *ifnp;
char **dhcpd_args = NULL;
}
i = 0;
- dhcpd_args[i++] = arg0; /* dhcpd */
- dhcpd_args[i++] = arg1; /* -c */
- dhcpd_args[i++] = arg2; /* dhcpd.conf */
- dhcpd_args[i++] = arg3; /* -l */
+ dhcpd_args[i++] = argv[0]; /* dhcpd */
+ dhcpd_args[i++] = argv[1]; /* -c */
+ dhcpd_args[i++] = argv[2]; /* dhcpd.conf */
+ dhcpd_args[i++] = argv[3]; /* -l */
if (cli_rtable != 0) {
snprintf(leasedb, sizeof(leasedb), "%s.%d",
- arg4, cli_rtable);
+ argv[4], cli_rtable);
dhcpd_args[i++] = leasedb; /* rdomain's leasedb */
} else
- dhcpd_args[i++] = arg4; /* default leasedb */
+ dhcpd_args[i++] = argv[4]; /* default leasedb */
for (ifnp = ifn_list; ifnp->if_name != NULL; ifnp++) {
int flags, rdomain;
}
dhcpd_args[i] = NULL;
- cmdargs(arg0, dhcpd_args);
+ cmdargs(argv[0], dhcpd_args);
done:
if_freenameindex(ifn_list);
free(dhcpd_args);
blob - 1d5f9ba1bb4679f08e868a87794e6443df805da9
blob + 5695aa1cc3e00102dab7f6f7b6dbe5228b52120f
--- ctl.h
+++ ctl.h
#define IFNAME (void *)3
#define REQTEMP (void *)4
#define SIZE_CONF_TEMP 64
-int ctlhandler(int, char **, char *);
+int ctlhandler(int, char **, ...);
void rmtemp(char *);
struct ctl {
char *name;
char *help;
char *args[32];
char *test_args[32];
- void (*handler)();
+ void (*handler)(int, char **, ...);
int flag_x;
int type;
};
#define T_HANDLER 1
-#define T_HANDLER_FILL1 2
+#define T_HANDLER_TEST 2
#define T_EXEC 3
struct daemons {
char *name;
blob - 5f7bb39e4b9ecc29ba5dbcf43c0c431a81a07d5d
blob + d92806d81b6ea75c0e5fe742f5e7d194db8aadc0
--- ctlargs.c
+++ ctlargs.c
#include "ctl.h"
int
-pr_prot1(int argc, char **argv)
+pr_prot1(int argc, char **argv, ...)
{
struct prot1 *x;
struct prot *prot;
blob - 3eed39cfe7a6df63939115a4588ca1b1a515f480
blob + c5a8966d0b3506a015dd105fb55b3044ddbe1d10
--- externs.h
+++ externs.h
int nopt(int, char **, struct nopts *);
/* ppp.c */
-int intsppp(char *, int, int, char **);
+int intsppp(int, char **, ...);
void pppoe_ipcp(char *, int, int);
-int intpppoe(char *, int, int, char **);
+int intpppoe(int, char **, ...);
int is_pppoe(char *, int);
#define NSH_PPPOE_IPADDR_IPCP 1
#define NSH_PPPOE_IPADDR_STATIC 2
#define FLUSH 0
struct rtdump *getrtdump(int, int, int);
void freertdump(struct rtdump *);
-int monitor(int, char **);
+int monitor(int, char **, ...);
int rtmsg(int, int, int, int, int);
void flushroutes(int, int);
void bprintf(FILE *, int, u_char *);
#ifndef DHCPLEASES
#define DHCPLEASES "/var/db/dhcpd.leases"
#endif
-int quit(void);
+int quit(int, char **, ...);
void sigalarm(int);
void command(void);
int argvtostring(int, char **, char *, int);
extern char prompt[128];
extern char saved_prompt[sizeof(prompt)];
-int group (int, char **);
+int group (int, char **, ...);
void gen_help(char **, char *, char *, int);
void makeargv(void);
extern size_t cursor_argc;
char *complete; /* context sensitive completion list */
char **table; /* next table for context completion */
int stlen; /* struct length (for rows in next table) */
- int (*handler) (); /* routine which executes command */
+ int (*handler) (int, char **, ...); /* routine which executes command */
int needpriv; /* Do we need privilege to execute? */
int needconfig; /* Do we need config mode to execute? */
int nocmd; /* Can we specify 'no ...command...'? */
int stlen; /* struct length (for rows in next table) */
int minarg; /* Minimum number of arguments */
int maxarg; /* Maximum number of arguments */
- int (*handler)(); /* Routine to perform (for special ops) */
+ int (*handler)(int, char **, ...); /* Routine to perform */
} Menu;
struct intlist {
char *complete; /* context sensitive completion list */
char **table; /* next table for context completion */
int stlen; /* struct length (for rows in next table) */
- int (*handler)(); /* Routine to perform (for special ops) */
+ int (*handler)(int, char **, ...); /* Routine to perform */
int nocmd; /* Can we specify 'no ...command...'? */
};
void make_string(char *str, int, const u_int8_t *buf, int);
int get_nwinfo(char *, char *, int, int);
int get_nwpowersave(int, char *);
-int intnwkey(char *, int, int, char **);
-int inttxpower(char *, int, int, char **);
-int intbssid(char *, int, int, char **);
+int intnwkey(int, char **, ...);
+int inttxpower(int, char **, ...);
+int intbssid(int, char **, ...);
/* stats.c */
void rt_stats(void);
/* sysctl.c */
int sysctl_int(int[], int, int);
-int ipsysctl(int, char *, char *, int);
+int ipsysctl(int, char **, ...);
void conf_sysctls(FILE *);
/* route.c */
#define NO_NETMASK 0
#define ASSUME_NETMASK 1
-int route(int, char**);
+int route(int, char**, ...);
void show_route(char *, int);
int is_ip_addr(char *);
#ifdef _IP_T_
#define DEFAULT_LLPRIORITY 3
void imr_init(char *);
int is_valid_ifname(char *);
-int show_int(int, char **, FILE *);
-int show_vlans(int, char **);
-int show_ip(int, char **);
-int show_autoconf(int, char **);
+int show_int(int, char **, ...);
+int show_vlans(int, char **, ...);
+int show_ip(int, char **, ...);
+int show_autoconf(int, char **, ...);
int get_rdomain(int, char *);
int get_ifdata(char *, int);
int get_ifflags(char *, int);
u_int32_t in4_brdaddr(u_int32_t, u_int32_t);
extern struct ghs intiphelp[];
extern struct ghs intip6help[];
-int intip(char *, int, int, char **);
+int intip(int, char **, ...);
int intipcp(char *, int, int, char **);
-int intmtu(char *, int, int, char **);
-int intkeepalive(char *, int, int, char **);
-int intrdomain(char *, int, int, char **);
-int intdhcrelay(char *, int, int, char **);
-int intmetric(char *, int, int, char **);
-int intllprio(char *, int, int, char **);
-int intflags(char *, int, int, char **);
-int intxflags(char *, int, int, char **);
+int intmtu(int, char **, ...);
+int intkeepalive(int, char **, ...);
+int intrdomain(int, char **, ...);
+int intdhcrelay(int, char **, ...);
+int intmetric(int, char **, ...);
+int intllprio(int, char **, ...);
+int intflags(int, char **, ...);
+int intxflags(int, char **, ...);
int intaf(char *, int, int, char **);
-int intlink(char *, int, int, char **);
-int intnwid(char *, int, int, char **);
-int intpowersave(char *, int, int, char **);
-int intdesc(char *, int, int, char **);
-int intpflow(char *, int, int, char **);
-int intlladdr(char *, int, int, char **);
-int intgroup(char *, int, int, char **);
-int intrtlabel(char *, int, int, char **);
-int intparent(char *, int, int, char **);
-int intpatch(char *, int, int, char **);
-int intmpls(char *, int, int, char **);
-int intpwe3(char *, int, int, char **);
-int intvnetflowid(char *, int, int, char **);
+int intlink(int, char **, ...);
+int intnwid(int, char **, ...);
+int intpowersave(int, char **, ...);
+int intdesc(int, char **, ...);
+int intpflow(int, char **, ...);
+int intlladdr(int, char **, ...);
+int intgroup(int, char **, ...);
+int intrtlabel(int, char **, ...);
+int intparent(int, char **, ...);
+int intpatch(int, char **, ...);
+int intmpls(int, char **, ...);
+int intpwe3(int, char **, ...);
+int intvnetflowid(int, char **, ...);
int addaf(char *, int, int);
int removeaf(char *, int, int);
int check_daemon_control_socket(const char *);
void intr(void);
/* version.c */
-int version(int, char **);
+int version(int, char **, ...);
/* compile.c */
extern char compiled[], compiledby[], compiledon[], compilehost[];
int set_ifflag(int, char *, short);
int clr_ifflag(int, char *, short);
int is_bridge(int, char *);
-int brport(char *, int, int, char **);
-int brval(char *, int, int, char **);
-int brrule(char *, int, int, char **);
-int brstatic(char *, int, int, char **);
-int brpri(char *, int, int, char **);
-int flush_bridgedyn(char *);
-int flush_bridgeall(char *);
-int flush_bridgerule(char *, char*);
-int brprotect(char *, int, int, char **);
-int show_bridges(int, char **);
+int brport(int, char **, ...);
+int brval(int, char **, ...);
+int brrule(int, char **, ...);
+int brstatic(int, char **, ...);
+int brpri(int, char **, ...);
+int flush_bridgedyn(int , char **, ...);
+int flush_bridgeall(int, char **, ...);
+int flush_bridgerule(int, char **, ...);
+int brprotect(int, char **, ...);
+int show_bridges(int, char **, ...);
/* tunnel.c */
-int inttunnel(char *, int, int, char **);
-int intvnetid(char *, int, int, char **);
+int inttunnel(int, char **, ...);
+int intvnetid(int, char **, ...);
int get_physrtable(int, char *);
int get_physttl(int, char *);
int get_physecn(int, char *);
int media_status(int, char *, char *, FILE *);
void media_supported(int, char *, char *, char *, FILE *);
int phys_status(int, char *, char *, char *, int, int);
-int intmedia(char *, int, int, char **);
-int intmediaopt(char *, int, int, char **);
+int intmedia(int, char **, ...);
+int intmediaopt(int, char **, ...);
int conf_media_status(FILE *, int, char *);
struct ifmediareq;
const char *get_ifm_linkstate_str(struct ifmediareq *);
#define NSHPASSWD_TEMP "/var/run/nshpasswd"
int read_pass(char *, size_t);
int gen_salt(char *, size_t);
-int enable(int, char **);
+int enable(int, char **, ...);
/* pfsync.c */
#define PFSYNC_MAXUPDATES 128
-int intsyncdev(char *, int, int, char **);
-int intsyncpeer(char *, int, int, char **);
-int intmaxupd(char *, int, int, char **);
+int intsyncdev(int, char **, ...);
+int intsyncpeer(int, char **, ...);
+int intmaxupd(int, char **, ...);
int conf_pfsync(FILE *, int, char *);
/* carp.c */
#define CARP_VHID 2
#define CARP_PEER 3
#define CARP_BALANCING 4
-int intcarp(char *, int, int, char **);
-int intcpass(char *, int, int, char **);
-int intcnode(char *, int, int, char **);
+int intcarp(int, char **, ...);
+int intcpass(int, char **, ...);
+int intcnode(int, char **, ...);
int conf_carp(FILE *, int, char *);
int carp_state(int, char *, FILE *);
-int intcdev(char *, int, int, char **);
+int intcdev(int, char **, ...);
int carplock(int);
/* trunk.c */
-int inttrunkport(char *, int, int, char **);
-int inttrunkproto(char *, int, int, char **);
+int inttrunkport(int, char **, ...);
+int inttrunkproto(int, char **, ...);
int conf_trunk(FILE *output, int ifs, char *ifname);
void show_trunk(int ifs, char *ifname, FILE *);
/* who.c */
-int who(int, char **);
+int who(int, char **, ...);
/* arp.c */
int arpget(const char *);
-int arpset(int, char **);
+int arpset(int, char **, ...);
void arpdump(void);
void conf_arp(FILE *, char *);
char *sec2str(time_t);
char *ether_str(struct sockaddr_dl *);
/* ndp.c */
-int ndpset(int, char **);
+int ndpset(int, char **, ...);
void ndpget(const char *);
int ndpdelete(const char *);
struct sockaddr_in6;
void conf_ndp(FILE *output, char *delim);
/* nameserver.c */
-int nameserverset(int, char **);
+int nameserverset(int, char **, ...);
void conf_nameserver(FILE *);
/* more.c */
int pflow_status(int, int, char *, char *);
/* wg.c */
-int intwg(char *, int, int, char **);
-int intwgpeer(char *, int, int, char **);
+int intwg(int, char **, ...);
+int intwgpeer(int, char **, ...);
void conf_wg(FILE *, int, char *);
void show_wg(int, char *, FILE *);
/* umb.c */
-int intumb(char *, int, int, char **);
+int intumb(int, char **, ...);
void conf_umb(FILE *, int, char *);
void show_umb(int, char *, FILE *);
int mbsavis(char**, int *, const char *);
/* ctlargs.c */
-int pr_prot1(int, char **);
+int pr_prot1(int, char **, ...);
char **step_optreq(char **, char **, int, char **, int);
/* hashtable.c */
blob - 9564ad11cfdf44c8f81f31ff2f0d694bd6248954
blob + 34c3d146142d071df0804f3dd71f4585db909e98
--- helpcommands.c
+++ helpcommands.c
#include "commands.h"
int
-show_help(int argc, char **argv)
+show_help(int argc, char **argv, ...)
{
Menu *s; /* pointer to current command */
u_int z = 0;
* Help command.
*/
int
-help(int argc, char **argv)
+help(int argc, char **argv, ...)
{
Command *c;
blob - 702bb2ba0c42a7061b2a8d5e5ccf4f1eea9dbeb7
blob + b530a2fd7bcb9c19d00c32d3fcb131ad6f5df55c
--- ieee80211.c
+++ ieee80211.c
#include <string.h>
#include <unistd.h>
#include <errno.h>
+#include <stdarg.h>
#include <sys/limits.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
/* was setifnwkey() */
int
-intnwkey(char *ifname, int ifs, int argc, char **argv)
+intnwkey(int argc, char **argv, ...)
{
int i, len, set;
char *cp = NULL, *val = NULL;
struct ieee80211_nwkey nwkey;
u_int8_t keybuf[IEEE80211_WEP_NKID][16];
+ va_list ap;
+ char *ifname;
+ int ifs;
+
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
if (NO_ARG(argv[0])) {
set = 0;
}
int
-inttxpower(char *ifname, int ifs, int argc, char **argv)
+inttxpower(int argc, char **argv, ...)
{
const char *errmsg = NULL;
struct ieee80211_txpower txpower;
short dbm, set;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argv++;
}
int
-intbssid(char *ifname, int ifs, int argc, char **argv)
+intbssid(int argc, char **argv, ...)
{
struct ieee80211_bssid bssid;
struct ether_addr *ea;
short set;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argv++;
blob - ab83616edf04a266cb51b2ab7adb8f168bdef2e7
blob + e0d9b2290cd49156e41c518c76e2e3e882a1a6f9
--- if.c
+++ if.c
#include <sys/tree.h>
+#include <stdarg.h>
#include <stdio.h>
#include <ctype.h>
#include <fcntl.h>
}
int
-show_int(int argc, char **argv, FILE *outfile)
+show_int(int argc, char **argv, ...)
{
struct ifaddrs *ifap, *ifa;
struct if_nameindex *ifn_list, *ifnp;
struct sockaddr_in *sin = NULL, *sinmask = NULL, *sindest;
struct sockaddr_in6 *sin6 = NULL, *sin6mask = NULL, *sin6dest;
struct timeval tv;
-
+ FILE *outfile;
+ va_list ap;
short tmp;
int ifs, br, flags, days, hours, mins, pntd;
int ippntd = 0;
memset(ifname, 0, sizeof(ifname));
+ va_start(ap, argv);
+ outfile = va_arg(ap, FILE *);
+ va_end(ap);
+
if (argc == 4) {
/*
* Allow "interface-name interface-number" as some
}
int
-show_autoconf(int argc, char **argv)
+show_autoconf(int argc, char **argv, ...)
{
struct if_nameindex *ifn_list, *ifnp;
char *ifname = NULL;
RB_GENERATE(ip_tree, ip_tree_entry, entry, ip_tree_cmp);
int
-show_ip(int argc, char **argv)
+show_ip(int argc, char **argv, ...)
{
struct ifaddrs *ifap, *ifa;
struct sockaddr_in *sin = NULL, *sinmask = NULL;
}
int
-intip(char *ifname, int ifs, int argc, char **argv)
+intip(int argc, char **argv, ...)
{
int s, set, flags, argcmax;
int argc0 = argc;
/* ipv6 structures */
struct in6_addr in6dest;
struct in6_aliasreq ip6req;
+ va_list ap;
+ char *ifname;
+ int ifs;
+
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
if (NO_ARG(argv[0])) {
set = 0;
argv_dhcp = args;
argc_dhcp = nitems(args) - 1;
}
- return intxflags(ifname, ifs, argc_dhcp, argv_dhcp);
+ return intxflags(argc_dhcp, argv_dhcp, ifname, ifs);
} else {
printf("%% cannot get DHCP leases because dhcpleased "
"is not running\n");
argv_xflags = args;
argc_xflags = nitems(args) - 1;
}
- return intxflags(ifname, ifs, argc_xflags, argv_xflags);
+ return intxflags(argc_xflags, argv_xflags, ifname, ifs);
}
memset(&ip, 0, sizeof(ip));
* addr/port parsing lifted from sbin/ifconfig/ifconfig.c
*/
int
-intpflow(char *ifname, int ifs, int argc, char **argv)
+intpflow(int argc, char **argv, ...)
{
struct ifreq ifr;
struct pflowreq preq;
int set;
const char *errmsg = NULL;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argc--;
}
int
-intpatch(char *ifname, int ifs, int argc, char **argv)
+intpatch(int argc, char **argv, ...)
{
int set;
struct ifreq ifr;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argc--;
}
int
-intmtu(char *ifname, int ifs, int argc, char **argv)
+intmtu(int argc, char **argv, ...)
{
struct ifreq ifr;
int set;
const char *errmsg = NULL;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argc--;
}
int
-intkeepalive(char *ifname, int ifs, int argc, char **argv)
+intkeepalive(int argc, char **argv, ...)
{
struct ifkalivereq ikar;
int set;
const char *errmsg = NULL;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argc--;
/* from ifconfig.c */
int
-intmpls(char *ifname, int ifs, int argc, char **argv)
+intmpls(int argc, char **argv, ...)
{
int set;
unsigned long cmd;
struct shim_hdr shim;
struct mplsc *x;
const char *errstr;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
bzero(&ifr, sizeof(ifr));
strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
}
int
-intpwe3(char *ifname, int ifs, int argc, char **argv)
+intpwe3(int argc, char **argv, ...)
{
int set, ch, error;
unsigned long cmd;
struct if_laddrreq req;
struct addrinfo hints, *res;
struct sockaddr_mpls *smpls = (struct sockaddr_mpls *)&req.dstaddr;
+ va_list ap;
+ char *ifname;
+ int ifs;
+
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
bzero(&ifr, sizeof(ifr));
bzero(&req, sizeof(req));
}
int
-intdhcrelay(char *ifname, int ifs, int argc, char **argv)
+intdhcrelay(int argc, char **argv, ...)
{
- char *cmd[] = { DHCRELAY, "-i", ifname, NULL, NULL };
+ char *cmd[] = { DHCRELAY, "-i", NULL, NULL, NULL };
int set, alen;
struct in_addr notused;
+ va_list ap;
+ char *ifname;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argc--;
}
int
-intmetric(char *ifname, int ifs, int argc, char **argv)
+intmetric(int argc, char **argv, ...)
{
struct ifreq ifr;
int set, max;
unsigned long theioctl;
char *type;
const char *errmsg = NULL;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argc--;
}
int
-intllprio(char *ifname, int ifs, int argc, char **argv)
+intllprio(int argc, char **argv, ...)
{
struct ifreq ifr;
int set;
const char *errmsg = NULL;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argc--;
}
int
-intgroup(char *ifname, int ifs, int argc, char **argv)
+intgroup(int argc, char **argv, ...)
{
int set, i;
struct ifgroupreq ifgr;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argc--;
}
int
-intrtlabel(char *ifname, int ifs, int argc, char **argv)
+intrtlabel(int argc, char **argv, ...)
{
int set;
struct ifreq ifr;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argc--;
}
int
-intparent(char *ifname, int ifs, int argc, char **argv)
+intparent(int argc, char **argv, ...)
{
int set, ret;
unsigned long cmd;
struct if_parent ifp;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argc--;
}
int
-intflags(char *ifname, int ifs, int argc, char **argv)
+intflags(int argc, char **argv, ...)
{
int set, value, flags, iftype;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argv++;
}
int
-intxflags(char *ifname, int ifs, int argc, char **argv)
+intxflags(int argc, char **argv, ...)
{
int set, value, flags;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argv++;
}
int
-intlink(char *ifname, int ifs, int argc, char **argv)
+intlink(int argc, char **argv, ...)
{
const char *errmsg = NULL;
int set, i, flags, value = 0;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argv++;
}
int
-intnwid(char *ifname, int ifs, int argc, char **argv)
+intnwid(int argc, char **argv, ...)
{
struct ieee80211_nwid nwid;
struct ifreq ifr;
int set, len;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argv++;
}
int
-intpowersave(char *ifname, int ifs, int argc, char **argv)
+intpowersave(int argc, char **argv, ...)
{
const char *errmsg = NULL;
struct ieee80211_power power;
int set;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argv++;
}
int
-intlladdr(char *ifname, int ifs, int argc, char **argv)
+intlladdr(int argc, char **argv, ...)
{
StringList *hwdaddr;
char *lladdr, llorig[sizeof("00:00:00:00:00:00") + 1];
struct ether_addr *addr;
struct ifreq ifr;
int set;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
+
if (NO_ARG(argv[0])) {
argv++;
argc--;
}
int
-intrdomain(char *ifname, int ifs, int argc, char **argv)
+intrdomain(int argc, char **argv, ...)
{
int set, rdomain;
const char *errmsg = NULL;
struct ifreq ifr;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argv++;
}
int
-intdesc(char *ifname, int ifs, int argc, char **argv)
+intdesc(int argc, char **argv, ...)
{
int set;
char desc[IFDESCRSIZE];
struct ifreq ifr;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argv++;
}
int
-intvnetflowid(char *ifname, int ifs, int argc, char **argv)
+intvnetflowid(int argc, char **argv, ...)
{
int set;
struct ifreq ifr;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argv++;
}
int
-show_vlans(int argc, char **argv)
+show_vlans(int argc, char **argv, ...)
{
long long start_vnetid = -1, end_vnetid = -1;
const char *errstr;
blob - b0998f7a401a66c8e179f8731398ea7bc21832c4
blob + a899258cb7f4da6759becc236358b0b715f46fc0
--- kroute.c
+++ kroute.c
}
int
-monitor(int argc, char **argv)
+monitor(int argc, char **argv, ...)
{
int s, m, n, saveverbose;
fd_set fds;
blob - bf86ca8dabe0a781147f326896a21743a594b1e5
blob + 8f17b0cddf04cf5733c0c39535a23a9be92ec90d
--- media.c
+++ media.c
*/
#include <stdio.h>
+#include <stdarg.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
IFM_OPTION_DESCRIPTIONS;
int
-intmedia(char *ifname, int ifs, int argc, char **argv)
+intmedia(int argc, char **argv, ...)
{
const char *errmsg = NULL;
uint64_t set, media_current, type, subtype, inst;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argc--;
}
int
-intmediaopt(char *ifname, int ifs, int argc, char **argv)
+intmediaopt(int argc, char **argv, ...)
{
int set, media_current, mediaopt;
+ va_list ap;
+ char *ifname;
+ int ifs;
+
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
if (NO_ARG(argv[0])) {
set = 0;
blob - 917e6bfb84da3ced26912f497b3d97ed04be002e
blob + bdf7b2652df8577e557a90f07ce6fdc0d8bb1469
--- nameserver.c
+++ nameserver.c
}
int
-nameserverset(int argc, char *argv[])
+nameserverset(int argc, char *argv[], ...)
{
int i, set = 1;
blob - fb50b6294674355067d69e1886d059c6cfa3e2a1
blob + 90e0c8505715583ce7d0d867d044903b377380bf
--- ndp.c
+++ ndp.c
static int getsocket(void);
int parse_host(const char *, struct sockaddr_in6 *);
-int ndpset(int, char **);
+int ndpset(int, char **, ...);
void ndpget(const char *);
int ndpdelete(const char *);
void ndpdump(struct sockaddr_in6 *, int);
* Set an individual neighbor cache entry
*/
int
-ndpset(int argc, char *argv[])
+ndpset(int argc, char *argv[], ...)
{
struct sockaddr_in6 *sin = &sin_m;
struct sockaddr_dl *sdl;
blob - 6eb375fbb75af8281fcd5619915fb64f2123f566
blob + eb3264d77e21a24a773e0964e5b2851cbd15accf
--- passwd.c
+++ passwd.c
}
int
-enable(int argc, char **argv)
+enable(int argc, char **argv, ...)
{
char *doas_argv[] = {
NSHDOAS_PATH_STR, NULL, NULL, NULL
return 0;
else if (exit_code == NSH_REXEC_EXIT_CODE_QUIT) {
/* The child exited due to a 'quit' command. */
- quit();
+ quit(0, NULL);
} else {
printf("%% Privileged mode child process exited "
"with error code %d\n", exit_code);
blob - 78caaff6a1e2178bd9294072c088bbfb0ed83794
blob + 701590813efe3b6b89242e334d5e3835205cdcc0
--- pfsync.c
+++ pfsync.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <stdarg.h>
#include <errno.h>
#include <sys/limits.h>
#include <sys/types.h>
#define PFSYNC_MAXUPDATES 128
int
-intsyncdev(char *ifname, int ifs, int argc, char **argv)
+intsyncdev(int argc, char **argv, ...)
{
struct ifreq ifr;
struct pfsyncreq preq;
int set;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argc--;
}
int
-intsyncpeer(char *ifname, int ifs, int argc, char **argv)
+intsyncpeer(int argc, char **argv, ...)
{
struct ifreq ifr;
struct pfsyncreq preq;
struct addrinfo hints, *peerres;
int set, ecode;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argc--;
}
int
-intmaxupd(char *ifname, int ifs, int argc, char **argv)
+intmaxupd(int argc, char **argv, ...)
{
struct ifreq ifr;
struct pfsyncreq preq;
u_int32_t val;
int set;
const char *errmsg = NULL;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argc--;
blob - 8ad52dbef656a881995d75842c2fbdd9477289e6
blob + b82bb9d0657687e27334efed268df533ffe44af2
--- ppp.c
+++ ppp.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <stdarg.h>
#include <errno.h>
#include <sys/socket.h>
#include <sys/param.h>
/* auth proto, auth name, auth key, peer proto, peer name, peer key, peer flag */
int
-intsppp(char *ifname, int ifs, int argc, char **argv)
+intsppp(int argc, char **argv, ...)
{
struct sauthreq spa;
struct ifreq ifr;
int set, ch, i, cmd = 0;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
/* command options for 'auth' */
static struct nopts authopts[] = {
{ "proto", req_arg, 'p' },
/* pppoe dev, pppoe svc, pppoe ac */
int
-intpppoe(char *ifname, int ifs, int argc, char **argv)
+intpppoe(int argc, char **argv, ...)
{
struct pppoediscparms parms;
int set, ch;
+ va_list ap;
+ char *ifname;
+ int ifs;
+
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
/* command options for 'auth' */
static struct nopts authopts[] = {
blob - a558cf19abc8bd22c365719553f577e6a42ebe5b
blob + 25a10ba699b50d385b2291b3bbdcb6506995eaa7
--- route.c
+++ route.c
}
int
-route(int argc, char **argv)
+route(int argc, char **argv, ...)
{
u_short cmd = 0;
u_int32_t net;
blob - b987820def6eb3b7bc042da908ed72a34ef6a2fb
blob + 9d45212bcf2f3dfa4682063566612d2fc49d0f2b
--- sysctl.c
+++ sysctl.c
#include <string.h>
#include <netinet/in.h>
#include <stdlib.h>
+#include <stdarg.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/socket.h>
};
int
-ipsysctl(int set, char *cmd, char *arg, int type)
+ipsysctl(int set, char **cmd, ...)
{
int32_t larg;
const char *errmsg = NULL;
struct ipsysctl *x;
struct sysctltab *stab;
+ va_list ap;
+ char *arg;
+ int type;
+ va_start(ap, cmd);
+ arg = va_arg(ap, char *);
+ type = va_arg(ap, int);
+ va_end(ap);
+
for (stab = sysctls; stab-> name != NULL; stab++)
if(stab->pf == type)
break;
return 0;
}
- x = (struct ipsysctl *) genget(cmd, (char **)stab->sysctl,
+ x = (struct ipsysctl *) genget(*cmd, (char **)stab->sysctl,
sizeof(struct ipsysctl));
if (x == 0) {
- printf("%% Invalid argument %s\n", cmd);
+ printf("%% Invalid argument %s\n", *cmd);
return 0;
} else if (Ambiguous(x)) {
- printf("%% Ambiguous argument %s\n", cmd);
+ printf("%% Ambiguous argument %s\n", *cmd);
return 0;
}
blob - 4be1b9877ac4ebf68133ff2f069e13c859483fce
blob + cbd7d80d0d901cb6bd60ef617b0101ebbb4d1b2b
--- trunk.c
+++ trunk.c
*/
#include <stdio.h>
+#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
struct trunk_protos tpr[] = TRUNK_PROTOS;
int
-inttrunkport(char *ifname, int ifs, int argc, char **argv)
+inttrunkport(int argc, char **argv, ...)
{
struct trunk_reqport rp;
int set, i;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argc--;
}
int
-inttrunkproto(char *ifname, int ifs, int argc, char **argv)
+inttrunkproto(int argc, char **argv, ...)
{
int i, set;
struct trunk_reqall ra;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argc--;
blob - 28eb4eaf23744f51e0161fc8e15780d5399e18a7
blob + 92c3754a7128122d5910b0e9e7c4ecc09fede438
--- tunnel.c
+++ tunnel.c
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
+#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <stdint.h>
};
int
-intvnetid(char *ifname, int ifs, int argc, char **argv)
+intvnetid(int argc, char **argv, ...)
{
int set;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argc--;
}
int
-inttunnel(char *ifname, int ifs, int argc, char **argv)
+inttunnel(int argc, char **argv, ...)
{
int set, ch, df = 0, ecn = 0;
char *src = NULL, *dst = NULL, *rdomain = NULL, *ttl = NULL;
char *dstip = NULL, *dstport = NULL;
char buf[MAXHOSTNAMELEN+sizeof (":65535")];
+ va_list ap;
+ char *ifname;
+ int ifs;
+
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
if (NO_ARG(argv[0])) {
set = 0;
blob - cc62569dfd91f9445faca4d1c7972115be691eb7
blob + b3b15a1e6d7b72d5b5b8d9122d176ecf8c337626
--- umb.c
+++ umb.c
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
+#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <util.h>
};
int
-intumb(char *ifname, int ifs, int argc, char **argv)
+intumb(int argc, char **argv, ...)
{
int set;
struct umbc *x;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
if (NO_ARG(argv[0])) {
set = 0;
argc--;
blob - 775ab1144d79be492896a8ba89e5d1001a7eeffc
blob + f1c8de09bf9cb77daed9fe24ad90f6b1a1fe3de1
--- version.c
+++ version.c
#include "externs.h"
int
-version(int argc, char **argv)
+version(int argc, char **argv, ...)
{
char cpubuf[1024];
char kernver[1024];
blob - aa7eec25d1c7260b8c8851d7fd692918333b0e50
blob + e4a63e09d48fb5d27208253fa13f52076ba07538
--- wg.c
+++ wg.c
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
+#include <stdarg.h>
#include <time.h>
#include <sys/sockio.h>
#include <sys/ioctl.h>
};
int
-intwg(char *ifname, int ifs, int argc, char **argv)
+intwg(int argc, char **argv, ...)
{
int set;
struct wgc *x;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
/* freshen up at the NULL basin */
wgdata.wgd_size = 0;
wgdata.wgd_interface = wg_interface = NULL;
}
int
-intwgpeer(char *ifname, int ifs, int argc, char **argv)
+intwgpeer(int argc, char **argv, ...)
{
int set, ch;
+ va_list ap;
+ char *ifname;
+ int ifs;
+ va_start(ap, argv);
+ ifname = va_arg(ap, char *);
+ ifs = va_arg(ap, int);
+ va_end(ap);
+
/* command options for 'wgpeer' */
static struct nopts wgpeeropts[] = {
{ "endpoint", req_arg, 'e' },
blob - d74d306eee9958bca13ea4f91638fa7061ba62bd
blob + 7300133a8d8e3171818a686e2f5fd664c406e1b1
--- who.c
+++ who.c
void output_labels(void);
int
-who(int argc, char **argv)
+who(int argc, char **argv, ...)
{
FILE *utmp;
struct utmp who;