command.c (44106) | command.c (44279) |
---|---|
1/* 2 * PPP User command processing module 3 * 4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp) 5 * 6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd. 7 * 8 * Redistribution and use in source and binary forms are permitted 9 * provided that the above copyright notice and this paragraph are 10 * duplicated in all such forms and that any documentation, 11 * advertising materials, and other materials related to such 12 * distribution and use acknowledge that the software was developed 13 * by the Internet Initiative Japan, Inc. The name of the 14 * IIJ may not be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 * | 1/* 2 * PPP User command processing module 3 * 4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp) 5 * 6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd. 7 * 8 * Redistribution and use in source and binary forms are permitted 9 * provided that the above copyright notice and this paragraph are 10 * duplicated in all such forms and that any documentation, 11 * advertising materials, and other materials related to such 12 * distribution and use acknowledge that the software was developed 13 * by the Internet Initiative Japan, Inc. The name of the 14 * IIJ may not be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 * |
20 * $Id: command.c,v 1.181 1999/02/16 00:16:55 brian Exp $ | 20 * $Id: command.c,v 1.182 1999/02/18 00:52:12 brian Exp $ |
21 * 22 */ 23#include <sys/param.h> 24#include <netinet/in_systm.h> 25#include <netinet/in.h> 26#include <netinet/ip.h> 27#include <arpa/inet.h> 28#include <sys/socket.h> --- 107 unchanged lines hidden (view full) --- 136#define NEG_PPPDDEFLATE 47 137#define NEG_PRED1 48 138#define NEG_PROTOCOMP 49 139#define NEG_SHORTSEQ 50 140#define NEG_VJCOMP 51 141#define NEG_DNS 52 142 143const char Version[] = "2.11"; | 21 * 22 */ 23#include <sys/param.h> 24#include <netinet/in_systm.h> 25#include <netinet/in.h> 26#include <netinet/ip.h> 27#include <arpa/inet.h> 28#include <sys/socket.h> --- 107 unchanged lines hidden (view full) --- 136#define NEG_PPPDDEFLATE 47 137#define NEG_PRED1 48 138#define NEG_PROTOCOMP 49 139#define NEG_SHORTSEQ 50 140#define NEG_VJCOMP 51 141#define NEG_DNS 52 142 143const char Version[] = "2.11"; |
144const char VersionDate[] = "$Date: 1999/02/16 00:16:55 $"; | 144const char VersionDate[] = "$Date: 1999/02/18 00:52:12 $"; |
145 146static int ShowCommand(struct cmdargs const *); 147static int TerminalCommand(struct cmdargs const *); 148static int QuitCommand(struct cmdargs const *); 149static int OpenCommand(struct cmdargs const *); 150static int CloseCommand(struct cmdargs const *); 151static int DownCommand(struct cmdargs const *); 152static int SetCommand(struct cmdargs const *); --- 1113 unchanged lines hidden (view full) --- 1266 sscanf(*argv++, "%x", &code); 1267 code &= 0xff; 1268 arg->cx->physical->async.cfg.EscMap[code >> 3] |= (1 << (code & 7)); 1269 arg->cx->physical->async.cfg.EscMap[32] = 1; 1270 } 1271 return 0; 1272} 1273 | 145 146static int ShowCommand(struct cmdargs const *); 147static int TerminalCommand(struct cmdargs const *); 148static int QuitCommand(struct cmdargs const *); 149static int OpenCommand(struct cmdargs const *); 150static int CloseCommand(struct cmdargs const *); 151static int DownCommand(struct cmdargs const *); 152static int SetCommand(struct cmdargs const *); --- 1113 unchanged lines hidden (view full) --- 1266 sscanf(*argv++, "%x", &code); 1267 code &= 0xff; 1268 arg->cx->physical->async.cfg.EscMap[code >> 3] |= (1 << (code & 7)); 1269 arg->cx->physical->async.cfg.EscMap[32] = 1; 1270 } 1271 return 0; 1272} 1273 |
1274static struct in_addr 1275GetIpAddr(const char *cp) 1276{ 1277 struct hostent *hp; 1278 struct in_addr ipaddr; 1279 1280 if (inet_aton(cp, &ipaddr) == 0) { 1281 hp = gethostbyname(cp); 1282 if (hp && hp->h_addrtype == AF_INET) 1283 memcpy(&ipaddr, hp->h_addr, hp->h_length); 1284 else 1285 ipaddr.s_addr = 0; 1286 } 1287 return (ipaddr); 1288} 1289 | |
1290static int 1291SetInterfaceAddr(struct cmdargs const *arg) 1292{ 1293 struct ipcp *ipcp = &arg->bundle->ncp.ipcp; 1294 const char *hisaddr; 1295 1296 if (arg->argc > arg->argn + 4) 1297 return -1; --- 638 unchanged lines hidden (view full) --- 1936 addrs = 0; 1937 if (strcasecmp(arg->argv[arg->argn], "MYADDR") == 0) { 1938 dest = arg->bundle->ncp.ipcp.my_ip; 1939 addrs = ROUTE_DSTMYADDR; 1940 } else if (strcasecmp(arg->argv[arg->argn], "HISADDR") == 0) { 1941 dest = arg->bundle->ncp.ipcp.peer_ip; 1942 addrs = ROUTE_DSTHISADDR; 1943 } else { | 1274static int 1275SetInterfaceAddr(struct cmdargs const *arg) 1276{ 1277 struct ipcp *ipcp = &arg->bundle->ncp.ipcp; 1278 const char *hisaddr; 1279 1280 if (arg->argc > arg->argn + 4) 1281 return -1; --- 638 unchanged lines hidden (view full) --- 1920 addrs = 0; 1921 if (strcasecmp(arg->argv[arg->argn], "MYADDR") == 0) { 1922 dest = arg->bundle->ncp.ipcp.my_ip; 1923 addrs = ROUTE_DSTMYADDR; 1924 } else if (strcasecmp(arg->argv[arg->argn], "HISADDR") == 0) { 1925 dest = arg->bundle->ncp.ipcp.peer_ip; 1926 addrs = ROUTE_DSTHISADDR; 1927 } else { |
1944 if (strcasecmp(arg->argv[arg->argn], "default") == 0) 1945 dest.s_addr = INADDR_ANY; 1946 else 1947 dest = GetIpAddr(arg->argv[arg->argn]); | 1928 dest = GetIpAddr(arg->argv[arg->argn]); 1929 if (dest.s_addr == INADDR_NONE) { 1930 log_Printf(LogWARN, "%s: Invalid IP address\n", arg->argv[arg->argn]); 1931 return -1; 1932 } |
1948 addrs = ROUTE_STATIC; 1949 } 1950 none.s_addr = INADDR_ANY; 1951 bundle_SetRoute(arg->bundle, RTM_DELETE, dest, none, none, 1952 arg->cmd->args ? 1 : 0, 0); 1953 route_Delete(&arg->bundle->ncp.ipcp.route, addrs, dest); 1954 } 1955 } else --- 579 unchanged lines hidden --- | 1933 addrs = ROUTE_STATIC; 1934 } 1935 none.s_addr = INADDR_ANY; 1936 bundle_SetRoute(arg->bundle, RTM_DELETE, dest, none, none, 1937 arg->cmd->args ? 1 : 0, 0); 1938 route_Delete(&arg->bundle->ncp.ipcp.route, addrs, dest); 1939 } 1940 } else --- 579 unchanged lines hidden --- |