diff --git a/usr.sbin/ppp/Makefile b/usr.sbin/ppp/Makefile index 5bfe87df8eb2..696479e3af8c 100644 --- a/usr.sbin/ppp/Makefile +++ b/usr.sbin/ppp/Makefile @@ -1,8 +1,8 @@ -# $Id: Makefile,v 1.47 1998/08/31 12:14:31 brian Exp $ +# $Id: Makefile,v 1.49 1998/10/20 00:19:38 brian Exp $ PROG= ppp SRCS= arp.c async.c auth.c bundle.c cbcp.c ccp.c chap.c chat.c command.c \ - datalink.c deflate.c defs.c filter.c fsm.c hdlc.c id.c ip.c \ + datalink.c deflate.c defs.c filter.c fsm.c hdlc.c id.c iface.c ip.c \ ipcp.c iplist.c lcp.c link.c log.c lqr.c main.c mbuf.c modem.c \ mp.c pap.c physical.c pred.c probe.c prompt.c route.c server.c \ sig.c slcompress.c systems.c throughput.c timer.c tun.c vjcomp.c diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c index 569d893f72dd..28da452fe169 100644 --- a/usr.sbin/ppp/bundle.c +++ b/usr.sbin/ppp/bundle.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bundle.c,v 1.34 1998/08/26 17:39:36 brian Exp $ + * $Id: bundle.c,v 1.35 1998/09/17 00:45:25 brian Exp $ */ #include @@ -89,6 +89,7 @@ #include "cbcp.h" #include "datalink.h" #include "ip.h" +#include "iface.h" #define SCATTER_SEGMENTS 4 /* version, datalink, name, physical */ #define SOCKET_OVERHEAD 100 /* additional buffer space for large */ @@ -148,49 +149,6 @@ bundle_NewPhase(struct bundle *bundle, u_int new) } } -static int -bundle_CleanInterface(const struct bundle *bundle) -{ - int s; - struct ifreq ifrq; - struct ifaliasreq ifra; - - s = ID0socket(AF_INET, SOCK_DGRAM, 0); - if (s < 0) { - log_Printf(LogERROR, "bundle_CleanInterface: socket(): %s\n", - strerror(errno)); - return (-1); - } - strncpy(ifrq.ifr_name, bundle->ifp.Name, sizeof ifrq.ifr_name - 1); - ifrq.ifr_name[sizeof ifrq.ifr_name - 1] = '\0'; - while (ID0ioctl(s, SIOCGIFADDR, &ifrq) == 0) { - memset(&ifra.ifra_mask, '\0', sizeof ifra.ifra_mask); - strncpy(ifra.ifra_name, bundle->ifp.Name, sizeof ifra.ifra_name - 1); - ifra.ifra_name[sizeof ifra.ifra_name - 1] = '\0'; - ifra.ifra_addr = ifrq.ifr_addr; - if (ID0ioctl(s, SIOCGIFDSTADDR, &ifrq) < 0) { - if (ifra.ifra_addr.sa_family == AF_INET) - log_Printf(LogERROR, "Can't get dst for %s on %s !\n", - inet_ntoa(((struct sockaddr_in *)&ifra.ifra_addr)->sin_addr), - bundle->ifp.Name); - close(s); - return 0; - } - ifra.ifra_broadaddr = ifrq.ifr_dstaddr; - if (ID0ioctl(s, SIOCDIFADDR, &ifra) < 0) { - if (ifra.ifra_addr.sa_family == AF_INET) - log_Printf(LogERROR, "Can't delete %s address on %s !\n", - inet_ntoa(((struct sockaddr_in *)&ifra.ifra_addr)->sin_addr), - bundle->ifp.Name); - close(s); - return 0; - } - } - close(s); - - return 1; -} - static void bundle_LayerStart(void *v, struct fsm *fp) { @@ -387,14 +345,14 @@ bundle_LayerUp(void *v, struct fsm *fp) if (bundle->ncp.mp.active) { struct datalink *dl; - bundle->ifp.Speed = 0; + bundle->ifSpeed = 0; for (dl = bundle->links; dl; dl = dl->next) if (dl->state == DATALINK_OPEN) - bundle->ifp.Speed += modem_Speed(dl->physical); + bundle->ifSpeed += modem_Speed(dl->physical); tun_configure(bundle, bundle->ncp.mp.peer_mrru); bundle->autoload.running = 1; } else { - bundle->ifp.Speed = modem_Speed(p); + bundle->ifSpeed = modem_Speed(p); tun_configure(bundle, fsm2lcp(fp)->his_mru); } } else if (fp->proto == PROTO_IPCP) { @@ -424,15 +382,15 @@ bundle_LayerDown(void *v, struct fsm *fp) struct datalink *dl; struct datalink *lost; - bundle->ifp.Speed = 0; + bundle->ifSpeed = 0; lost = NULL; for (dl = bundle->links; dl; dl = dl->next) if (fp == &dl->physical->link.lcp.fsm) lost = dl; else if (dl->state == DATALINK_OPEN) - bundle->ifp.Speed += modem_Speed(dl->physical); + bundle->ifSpeed += modem_Speed(dl->physical); - if (bundle->ifp.Speed) + if (bundle->ifSpeed) /* Don't configure down to a speed of 0 */ tun_configure(bundle, bundle->ncp.mp.link.lcp.his_mru); @@ -769,10 +727,11 @@ struct bundle * bundle_Create(const char *prefix, int type, const char **argv) { int s, enoentcount, err; + const char *ifname; struct ifreq ifrq; static struct bundle bundle; /* there can be only one */ - if (bundle.ifp.Name != NULL) { /* Already allocated ! */ + if (bundle.iface != NULL) { /* Already allocated ! */ log_Printf(LogALERT, "bundle_Create: There's only one BUNDLE !\n"); return NULL; } @@ -811,24 +770,32 @@ bundle_Create(const char *prefix, int type, const char **argv) return NULL; } - bundle.ifp.Name = strrchr(bundle.dev.Name, '/'); - if (bundle.ifp.Name == NULL) - bundle.ifp.Name = bundle.dev.Name; + ifname = strrchr(bundle.dev.Name, '/'); + if (ifname == NULL) + ifname = bundle.dev.Name; else - bundle.ifp.Name++; + ifname++; + + bundle.iface = iface_Create(ifname); + if (bundle.iface == NULL) { + close(s); + close(bundle.dev.fd); + return NULL; + } /* * Now, bring up the interface. */ memset(&ifrq, '\0', sizeof ifrq); - strncpy(ifrq.ifr_name, bundle.ifp.Name, sizeof ifrq.ifr_name - 1); + strncpy(ifrq.ifr_name, ifname, sizeof ifrq.ifr_name - 1); ifrq.ifr_name[sizeof ifrq.ifr_name - 1] = '\0'; if (ID0ioctl(s, SIOCGIFFLAGS, &ifrq) < 0) { log_Printf(LogERROR, "bundle_Create: ioctl(SIOCGIFFLAGS): %s\n", strerror(errno)); close(s); + iface_Destroy(bundle.iface); + bundle.iface = NULL; close(bundle.dev.fd); - bundle.ifp.Name = NULL; return NULL; } ifrq.ifr_flags |= IFF_UP; @@ -836,22 +803,17 @@ bundle_Create(const char *prefix, int type, const char **argv) log_Printf(LogERROR, "bundle_Create: ioctl(SIOCSIFFLAGS): %s\n", strerror(errno)); close(s); + iface_Destroy(bundle.iface); + bundle.iface = NULL; close(bundle.dev.fd); - bundle.ifp.Name = NULL; return NULL; } close(s); - if ((bundle.ifp.Index = GetIfIndex(bundle.ifp.Name)) < 0) { - log_Printf(LogERROR, "Can't find interface index.\n"); - close(bundle.dev.fd); - bundle.ifp.Name = NULL; - return NULL; - } - log_Printf(LogPHASE, "Using interface: %s\n", bundle.ifp.Name); + log_Printf(LogPHASE, "Using interface: %s\n", ifname); - bundle.ifp.Speed = 0; + bundle.ifSpeed = 0; bundle.routing_seq = 0; bundle.phase = PHASE_DEAD; @@ -882,8 +844,9 @@ bundle_Create(const char *prefix, int type, const char **argv) bundle.links = datalink_Create("deflink", &bundle, type); if (bundle.links == NULL) { log_Printf(LogALERT, "Cannot create data link: %s\n", strerror(errno)); + iface_Destroy(bundle.iface); + bundle.iface = NULL; close(bundle.dev.fd); - bundle.ifp.Name = NULL; return NULL; } @@ -917,7 +880,7 @@ bundle_Create(const char *prefix, int type, const char **argv) memset(&bundle.choked.timer, '\0', sizeof bundle.choked.timer); /* Clean out any leftover crud */ - bundle_CleanInterface(&bundle); + iface_Clear(bundle.iface, IFACE_CLEAR_ALL); bundle_LockTun(&bundle); @@ -939,7 +902,7 @@ bundle_DownInterface(struct bundle *bundle) } memset(&ifrq, '\0', sizeof ifrq); - strncpy(ifrq.ifr_name, bundle->ifp.Name, sizeof ifrq.ifr_name - 1); + strncpy(ifrq.ifr_name, bundle->iface->name, sizeof ifrq.ifr_name - 1); ifrq.ifr_name[sizeof ifrq.ifr_name - 1] = '\0'; if (ID0ioctl(s, SIOCGIFFLAGS, &ifrq) < 0) { log_Printf(LogERROR, "bundle_DownInterface: ioctl(SIOCGIFFLAGS): %s\n", @@ -985,7 +948,8 @@ bundle_Destroy(struct bundle *bundle) /* In case we never made PHASE_NETWORK */ bundle_Notify(bundle, EX_ERRDEAD); - bundle->ifp.Name = NULL; + iface_Destroy(bundle->iface); + bundle->iface = NULL; } struct rtmsg { @@ -1032,24 +996,10 @@ bundle_SetRoute(struct bundle *bundle, int cmd, struct in_addr dst, cp += rtdata.sin_len; if (cmd == RTM_ADD) { if (gateway.s_addr == INADDR_ANY) { - /* Add a route through the interface */ - struct sockaddr_dl dl; - const char *iname; - int ilen; - - iname = Index2Nam(bundle->ifp.Index); - ilen = strlen(iname); - dl.sdl_len = sizeof dl - sizeof dl.sdl_data + ilen; - dl.sdl_family = AF_LINK; - dl.sdl_index = bundle->ifp.Index; - dl.sdl_type = 0; - dl.sdl_nlen = ilen; - dl.sdl_alen = 0; - dl.sdl_slen = 0; - strncpy(dl.sdl_data, iname, sizeof dl.sdl_data); - memcpy(cp, &dl, dl.sdl_len); - cp += dl.sdl_len; - rtmes.m_rtm.rtm_addrs |= RTA_GATEWAY; + log_Printf(LogERROR, "bundle_SetRoute: Cannot add a route with" + " destination 0.0.0.0\n"); + close(s); + return result; } else { rtdata.sin_addr = gateway; memcpy(cp, &rtdata, rtdata.sin_len); @@ -1241,7 +1191,7 @@ bundle_ShowStatus(struct cmdargs const *arg) prompt_Printf(arg->prompt, "Phase %s\n", bundle_PhaseName(arg->bundle)); prompt_Printf(arg->prompt, " Device: %s\n", arg->bundle->dev.Name); prompt_Printf(arg->prompt, " Interface: %s @ %lubps\n", - arg->bundle->ifp.Name, arg->bundle->ifp.Speed); + arg->bundle->iface->name, arg->bundle->ifSpeed); prompt_Printf(arg->prompt, "\nDefaults:\n"); prompt_Printf(arg->prompt, " Label: %s\n", arg->bundle->cfg.label); @@ -1294,6 +1244,8 @@ bundle_ShowStatus(struct cmdargs const *arg) optval(arg->bundle, OPT_THROUGHPUT)); prompt_Printf(arg->prompt, " Utmp Logging: %s\n", optval(arg->bundle, OPT_UTMP)); + prompt_Printf(arg->prompt, " Iface-Alias: %s\n", + optval(arg->bundle, OPT_IFACEALIAS)); return 0; } @@ -1636,11 +1588,6 @@ bundle_SetMode(struct bundle *bundle, struct datalink *dl, int mode) /* Regenerate phys_type and adjust autoload & idle timers */ bundle_LinksRemoved(bundle); - if (omode == PHYS_AUTO && !(bundle->phys_type.all & PHYS_AUTO) && - bundle->phase != PHASE_NETWORK) - /* No auto links left */ - ipcp_CleanInterface(&bundle->ncp.ipcp); - return 1; } diff --git a/usr.sbin/ppp/bundle.h b/usr.sbin/ppp/bundle.h index aee0cc23c594..2f24b18c206c 100644 --- a/usr.sbin/ppp/bundle.h +++ b/usr.sbin/ppp/bundle.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bundle.h,v 1.12 1998/08/07 18:42:47 brian Exp $ + * $Id: bundle.h,v 1.13 1998/08/25 17:48:42 brian Exp $ */ #define PHASE_DEAD 0 /* Link is dead */ @@ -40,6 +40,7 @@ #define OPT_SROUTES 0x10 #define OPT_THROUGHPUT 0x20 #define OPT_UTMP 0x40 +#define OPT_IFACEALIAS 0x80 #define MAX_ENDDISC_CLASS 5 @@ -51,6 +52,7 @@ struct physical; struct link; struct server; struct prompt; +struct iface; struct bundle { struct descriptor desc; /* really all our datalinks */ @@ -62,11 +64,15 @@ struct bundle { int fd; /* The /dev/XXXX descriptor */ } dev; +#if 0 struct { - u_long Speed; /* struct tuninfo speed */ int Index; /* The interface index */ char *Name; /* The interface name */ } ifp; +#endif + + u_long ifSpeed; /* struct tuninfo speed */ + struct iface *iface; /* Interface information */ int routing_seq; /* The current routing sequence number */ u_int phase; /* Curent phase */ diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index 071df09a92b9..ced6a8a088d2 100644 --- a/usr.sbin/ppp/command.c +++ b/usr.sbin/ppp/command.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: command.c,v 1.166 1998/09/17 00:45:26 brian Exp $ + * $Id: command.c,v 1.167 1998/10/17 12:28:05 brian Exp $ * */ #include @@ -83,6 +83,7 @@ #include "chap.h" #include "cbcp.h" #include "datalink.h" +#include "iface.h" /* ``set'' values */ #define VAR_AUTHKEY 0 @@ -131,7 +132,7 @@ #define NEG_DNS 50 const char Version[] = "2.0"; -const char VersionDate[] = "$Date: 1998/09/17 00:45:26 $"; +const char VersionDate[] = "$Date: 1998/10/17 12:28:05 $"; static int ShowCommand(struct cmdargs const *); static int TerminalCommand(struct cmdargs const *); @@ -139,15 +140,17 @@ static int QuitCommand(struct cmdargs const *); static int OpenCommand(struct cmdargs const *); static int CloseCommand(struct cmdargs const *); static int DownCommand(struct cmdargs const *); -static int AllowCommand(struct cmdargs const *); static int SetCommand(struct cmdargs const *); static int LinkCommand(struct cmdargs const *); static int AddCommand(struct cmdargs const *); static int DeleteCommand(struct cmdargs const *); static int NegotiateCommand(struct cmdargs const *); static int ClearCommand(struct cmdargs const *); +static int RunListCommand(struct cmdargs const *); +static int IfaceAddCommand(struct cmdargs const *); +static int IfaceDeleteCommand(struct cmdargs const *); +static int IfaceClearCommand(struct cmdargs const *); #ifndef NOALIAS -static int AliasCommand(struct cmdargs const *); static int AliasEnable(struct cmdargs const *); static int AliasOption(struct cmdargs const *); #endif @@ -386,7 +389,7 @@ expand(char **nargv, int argc, char const *const *oargv, struct bundle *bundle) nargv[arg] = subst(nargv[arg], "HISADDR", inet_ntoa(bundle->ncp.ipcp.peer_ip)); nargv[arg] = subst(nargv[arg], "AUTHNAME", bundle->cfg.auth.name); - nargv[arg] = subst(nargv[arg], "INTERFACE", bundle->ifp.Name); + nargv[arg] = subst(nargv[arg], "INTERFACE", bundle->iface->name); nargv[arg] = subst(nargv[arg], "MYADDR", inet_ntoa(bundle->ncp.ipcp.my_ip)); nargv[arg] = subst(nargv[arg], "USER", bundle->ncp.mp.peer.authname); nargv[arg] = subst(nargv[arg], "PEER_ENDDISC", @@ -513,6 +516,69 @@ FgShellCommand(struct cmdargs const *arg) return ShellCommand(arg, 0); } +#ifndef NOALIAS +static struct cmdtab const AliasCommands[] = +{ + {"addr", NULL, alias_RedirectAddr, LOCAL_AUTH, + "static address translation", "alias addr [addr_local addr_alias]"}, + {"deny_incoming", NULL, AliasOption, LOCAL_AUTH, + "stop incoming connections", "alias deny_incoming [yes|no]", + (const void *) PKT_ALIAS_DENY_INCOMING}, + {"enable", NULL, AliasEnable, LOCAL_AUTH, + "enable IP aliasing", "alias enable [yes|no]"}, + {"log", NULL, AliasOption, LOCAL_AUTH, + "log aliasing link creation", "alias log [yes|no]", + (const void *) PKT_ALIAS_LOG}, + {"port", NULL, alias_RedirectPort, LOCAL_AUTH, + "port redirection", "alias port [proto addr_local:port_local port_alias]"}, + {"same_ports", NULL, AliasOption, LOCAL_AUTH, + "try to leave port numbers unchanged", "alias same_ports [yes|no]", + (const void *) PKT_ALIAS_SAME_PORTS}, + {"unregistered_only", NULL, AliasOption, LOCAL_AUTH, + "alias unregistered (private) IP address space only", + "alias unregistered_only [yes|no]", + (const void *) PKT_ALIAS_UNREGISTERED_ONLY}, + {"use_sockets", NULL, AliasOption, LOCAL_AUTH, + "allocate host sockets", "alias use_sockets [yes|no]", + (const void *) PKT_ALIAS_USE_SOCKETS}, + {"help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH, + "Display this message", "alias help|? [command]", AliasCommands}, + {NULL, NULL, NULL}, +}; +#endif + +static struct cmdtab const AllowCommands[] = { + {"modes", "mode", AllowModes, LOCAL_AUTH, + "Only allow certain ppp modes", "allow modes mode..."}, + {"users", "user", AllowUsers, LOCAL_AUTH, + "Only allow ppp access to certain users", "allow users logname..."}, + {"help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH, + "Display this message", "allow help|? [command]", AllowCommands}, + {NULL, NULL, NULL}, +}; + +static struct cmdtab const IfaceCommands[] = +{ + {"add", NULL, IfaceAddCommand, LOCAL_AUTH, + "Add iface address", "iface add addr[/bits| mask] peer", NULL}, + {NULL, "add!", IfaceAddCommand, LOCAL_AUTH, + "Add or change an iface address", "iface add! addr[/bits| mask] peer", + (void *)1}, + {"clear", NULL, IfaceClearCommand, LOCAL_AUTH, + "Clear iface address(es)", "iface clear"}, + {"delete", "rm", IfaceDeleteCommand, LOCAL_AUTH, + "Delete iface address", "iface delete addr", NULL}, + {NULL, "rm!", IfaceDeleteCommand, LOCAL_AUTH, + "Delete iface address", "iface delete addr", (void *)1}, + {NULL, "delete!", IfaceDeleteCommand, LOCAL_AUTH, + "Delete iface address", "iface delete addr", (void *)1}, + {"show", NULL, iface_Show, LOCAL_AUTH, + "Show iface address(es)", "iface show"}, + {"help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH, + "Display this message", "alias help|? [command]", IfaceCommands}, + {NULL, NULL, NULL}, +}; + static struct cmdtab const Commands[] = { {"accept", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT, "accept option request", "accept option .."}, @@ -521,11 +587,11 @@ static struct cmdtab const Commands[] = { {NULL, "add!", AddCommand, LOCAL_AUTH, "add or change route", "add! dest mask gateway", (void *)1}, #ifndef NOALIAS - {"alias", NULL, AliasCommand, LOCAL_AUTH, - "alias control", "alias option [yes|no]"}, + {"alias", NULL, RunListCommand, LOCAL_AUTH, + "alias control", "alias option [yes|no]", AliasCommands}, #endif - {"allow", "auth", AllowCommand, LOCAL_AUTH, - "Allow ppp access", "allow users|modes ...."}, + {"allow", "auth", RunListCommand, LOCAL_AUTH, + "Allow ppp access", "allow users|modes ....", AllowCommands}, {"bg", "!bg", BgShellCommand, LOCAL_AUTH, "Run a background command", "[!]bg command"}, {"clear", NULL, ClearCommand, LOCAL_AUTH | LOCAL_CX_OPT, @@ -548,6 +614,8 @@ static struct cmdtab const Commands[] = { "Generate a down event", "down"}, {"enable", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT, "Enable option", "enable option .."}, + {"iface", "interface", RunListCommand, LOCAL_AUTH, + "interface control", "iface option ...", IfaceCommands}, {"link", "datalink", LinkCommand, LOCAL_AUTH, "Link specific commands", "link name command ..."}, {"load", NULL, LoadCommand, LOCAL_AUTH | LOCAL_CX_OPT, @@ -655,6 +723,8 @@ static struct cmdtab const ShowCommands[] = { "packet filters", "show filter [in|out|dial|alive]"}, {"hdlc", NULL, hdlc_ReportStatus, LOCAL_AUTH | LOCAL_CX, "HDLC errors", "show hdlc"}, + {"iface", "interface", iface_Show, LOCAL_AUTH, + "Interface status", "show iface"}, {"ipcp", NULL, ipcp_Show, LOCAL_AUTH, "IPCP status", "show ipcp"}, {"lcp", NULL, lcp_ReportStatus, LOCAL_AUTH | LOCAL_CX, @@ -1200,13 +1270,12 @@ SetInterfaceAddr(struct cmdargs const *arg) struct ipcp *ipcp = &arg->bundle->ncp.ipcp; const char *hisaddr; - hisaddr = NULL; - ipcp->cfg.my_range.ipaddr.s_addr = INADDR_ANY; - ipcp->cfg.peer_range.ipaddr.s_addr = INADDR_ANY; - if (arg->argc > arg->argn + 4) return -1; + hisaddr = NULL; + ipcp->cfg.my_range.ipaddr.s_addr = INADDR_ANY; + ipcp->cfg.peer_range.ipaddr.s_addr = INADDR_ANY; ipcp->cfg.HaveTriggerAddress = 0; ipcp->cfg.netmask.s_addr = INADDR_ANY; iplist_reset(&ipcp->cfg.peer_list); @@ -1228,20 +1297,13 @@ SetInterfaceAddr(struct cmdargs const *arg) } } - /* - * For backwards compatibility, 0.0.0.0 means any address. - */ + /* 0.0.0.0 means any address (0 bits) */ if (ipcp->cfg.my_range.ipaddr.s_addr == INADDR_ANY) { ipcp->cfg.my_range.mask.s_addr = INADDR_ANY; ipcp->cfg.my_range.width = 0; } ipcp->my_ip.s_addr = ipcp->cfg.my_range.ipaddr.s_addr; - if (ipcp->cfg.peer_range.ipaddr.s_addr == INADDR_ANY) { - ipcp->cfg.peer_range.mask.s_addr = INADDR_ANY; - ipcp->cfg.peer_range.width = 0; - } - if (hisaddr && !ipcp_UseHisaddr(arg->bundle, hisaddr, arg->bundle->phys_type.all & PHYS_AUTO)) return 4; @@ -1717,7 +1779,6 @@ SetCommand(struct cmdargs const *arg) return 0; } - static int AddCommand(struct cmdargs const *arg) { @@ -1759,9 +1820,7 @@ AddCommand(struct cmdargs const *arg) if (strcasecmp(arg->argv[arg->argn+gw], "HISADDR") == 0) { gateway = arg->bundle->ncp.ipcp.peer_ip; addrs |= ROUTE_GWHISADDR; - } else if (strcasecmp(arg->argv[arg->argn+gw], "INTERFACE") == 0) - gateway.s_addr = INADDR_ANY; - else + } else gateway = GetIpAddr(arg->argv[arg->argn+gw]); if (bundle_SetRoute(arg->bundle, RTM_ADD, dest, gateway, netmask, @@ -1808,51 +1867,6 @@ DeleteCommand(struct cmdargs const *arg) } #ifndef NOALIAS -static struct cmdtab const AliasCommands[] = -{ - {"addr", NULL, alias_RedirectAddr, LOCAL_AUTH, - "static address translation", "alias addr [addr_local addr_alias]"}, - {"deny_incoming", NULL, AliasOption, LOCAL_AUTH, - "stop incoming connections", "alias deny_incoming [yes|no]", - (const void *) PKT_ALIAS_DENY_INCOMING}, - {"enable", NULL, AliasEnable, LOCAL_AUTH, - "enable IP aliasing", "alias enable [yes|no]"}, - {"log", NULL, AliasOption, LOCAL_AUTH, - "log aliasing link creation", "alias log [yes|no]", - (const void *) PKT_ALIAS_LOG}, - {"port", NULL, alias_RedirectPort, LOCAL_AUTH, - "port redirection", "alias port [proto addr_local:port_local port_alias]"}, - {"same_ports", NULL, AliasOption, LOCAL_AUTH, - "try to leave port numbers unchanged", "alias same_ports [yes|no]", - (const void *) PKT_ALIAS_SAME_PORTS}, - {"unregistered_only", NULL, AliasOption, LOCAL_AUTH, - "alias unregistered (private) IP address space only", - "alias unregistered_only [yes|no]", - (const void *) PKT_ALIAS_UNREGISTERED_ONLY}, - {"use_sockets", NULL, AliasOption, LOCAL_AUTH, - "allocate host sockets", "alias use_sockets [yes|no]", - (const void *) PKT_ALIAS_USE_SOCKETS}, - {"help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH, - "Display this message", "alias help|? [command]", AliasCommands}, - {NULL, NULL, NULL}, -}; - - -static int -AliasCommand(struct cmdargs const *arg) -{ - if (arg->argc > arg->argn) - FindExec(arg->bundle, AliasCommands, arg->argc, arg->argn, arg->argv, - arg->prompt, arg->cx); - else if (arg->prompt) - prompt_Printf(arg->prompt, "Use `alias help' to get a list or `alias help" - "