Deleted Added
full compact
ipcp.c (55146) ipcp.c (58034)
1/*
2 * PPP IP Control Protocol (IPCP) 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 IP Control Protocol (IPCP) 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 * $FreeBSD: head/usr.sbin/ppp/ipcp.c 55146 1999-12-27 11:54:57Z brian $
20 * $FreeBSD: head/usr.sbin/ppp/ipcp.c 58034 2000-03-14 01:46:54Z brian $
21 *
22 * TODO:
23 * o Support IPADDRS properly
24 * o Validate the length in IpcpDecodeConfig
25 */
26#include <sys/param.h>
27#include <netinet/in_systm.h>
28#include <netinet/in.h>

--- 174 unchanged lines hidden (view full) ---

203 IpcpSendConfigReq,
204 IpcpSentTerminateReq,
205 IpcpSendTerminateAck,
206 IpcpDecodeConfig,
207 fsm_NullRecvResetReq,
208 fsm_NullRecvResetAck
209};
210
21 *
22 * TODO:
23 * o Support IPADDRS properly
24 * o Validate the length in IpcpDecodeConfig
25 */
26#include <sys/param.h>
27#include <netinet/in_systm.h>
28#include <netinet/in.h>

--- 174 unchanged lines hidden (view full) ---

203 IpcpSendConfigReq,
204 IpcpSentTerminateReq,
205 IpcpSendTerminateAck,
206 IpcpDecodeConfig,
207 fsm_NullRecvResetReq,
208 fsm_NullRecvResetAck
209};
210
211static const char * const cftypes[] = {
212 /* Check out the latest ``Assigned numbers'' rfc (rfc1700.txt) */
213 "???",
214 "IPADDRS", /* 1: IP-Addresses */ /* deprecated */
215 "COMPPROTO", /* 2: IP-Compression-Protocol */
216 "IPADDR", /* 3: IP-Address */
217};
211static const char *
212protoname(int proto)
213{
214 static struct {
215 int id;
216 const char *txt;
217 } cftypes[] = {
218 /* Check out the latest ``Assigned numbers'' rfc (rfc1700.txt) */
219 { 1, "IPADDRS" }, /* IP-Addresses */ /* deprecated */
220 { 2, "COMPPROTO" }, /* IP-Compression-Protocol */
221 { 3, "IPADDR" }, /* IP-Address */
222 { 129, "PRIDNS" }, /* 129: Primary DNS Server Address */
223 { 130, "PRINBNS" }, /* 130: Primary NBNS Server Address */
224 { 131, "SECDNS" }, /* 131: Secondary DNS Server Address */
225 { 132, "SECNBNS" } /* 132: Secondary NBNS Server Address */
226 };
227 int f;
218
228
219#define NCFTYPES (sizeof cftypes/sizeof cftypes[0])
229 for (f = 0; f < sizeof cftypes / sizeof *cftypes; f++)
230 if (cftypes[f].id == proto)
231 return cftypes[f].txt;
220
232
221static const char * const cftypes128[] = {
222 /* Check out the latest ``Assigned numbers'' rfc (rfc1700.txt) */
223 "???",
224 "PRIDNS", /* 129: Primary DNS Server Address */
225 "PRINBNS", /* 130: Primary NBNS Server Address */
226 "SECDNS", /* 131: Secondary DNS Server Address */
227 "SECNBNS", /* 132: Secondary NBNS Server Address */
228};
233 return NumStr(proto, NULL, 0);
234}
229
235
230#define NCFTYPES128 (sizeof cftypes128/sizeof cftypes128[0])
231
232void
233ipcp_AddInOctets(struct ipcp *ipcp, int n)
234{
235 throughput_addin(&ipcp->throughput, n);
236}
237
238void
239ipcp_AddOutOctets(struct ipcp *ipcp, int n)

--- 715 unchanged lines hidden (view full) ---

955 type = *cp;
956 length = cp[1];
957
958 if (length == 0) {
959 log_Printf(LogIPCP, "%s: IPCP size zero\n", fp->link->name);
960 break;
961 }
962
236void
237ipcp_AddInOctets(struct ipcp *ipcp, int n)
238{
239 throughput_addin(&ipcp->throughput, n);
240}
241
242void
243ipcp_AddOutOctets(struct ipcp *ipcp, int n)

--- 715 unchanged lines hidden (view full) ---

959 type = *cp;
960 length = cp[1];
961
962 if (length == 0) {
963 log_Printf(LogIPCP, "%s: IPCP size zero\n", fp->link->name);
964 break;
965 }
966
963 if (type < NCFTYPES)
964 snprintf(tbuff, sizeof tbuff, " %s[%d] ", cftypes[type], length);
965 else if (type > 128 && type < 128 + NCFTYPES128)
966 snprintf(tbuff, sizeof tbuff, " %s[%d] ", cftypes128[type-128], length);
967 else
968 snprintf(tbuff, sizeof tbuff, " <%d>[%d] ", type, length);
967 snprintf(tbuff, sizeof tbuff, " %s[%d] ", protoname(type), length);
969
970 switch (type) {
971 case TY_IPADDR: /* RFC1332 */
972 memcpy(&ipaddr.s_addr, cp + 2, 4);
973 log_Printf(LogIPCP, "%s %s\n", tbuff, inet_ntoa(ipaddr));
974
975 switch (mode_type) {
976 case MODE_REQ:

--- 391 unchanged lines hidden ---
968
969 switch (type) {
970 case TY_IPADDR: /* RFC1332 */
971 memcpy(&ipaddr.s_addr, cp + 2, 4);
972 log_Printf(LogIPCP, "%s %s\n", tbuff, inet_ntoa(ipaddr));
973
974 switch (mode_type) {
975 case MODE_REQ:

--- 391 unchanged lines hidden ---