ccp.c (55146) | ccp.c (58034) |
---|---|
1/* 2 * PPP Compression Control Protocol (CCP) Module 3 * 4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp) 5 * 6 * Copyright (C) 1994, 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 Compression Control Protocol (CCP) Module 3 * 4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp) 5 * 6 * Copyright (C) 1994, 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/ccp.c 55146 1999-12-27 11:54:57Z brian $ | 20 * $FreeBSD: head/usr.sbin/ppp/ccp.c 58034 2000-03-14 01:46:54Z brian $ |
21 * 22 * TODO: 23 * o Support other compression protocols 24 */ 25#include <sys/param.h> 26#include <netinet/in.h> 27#include <netinet/in_systm.h> 28#include <netinet/ip.h> --- 59 unchanged lines hidden (view full) --- 88 CcpDecodeConfig, 89 CcpRecvResetReq, 90 CcpRecvResetAck 91}; 92 93static const char * const ccp_TimerNames[] = 94 {"CCP restart", "CCP openmode", "CCP stopped"}; 95 | 21 * 22 * TODO: 23 * o Support other compression protocols 24 */ 25#include <sys/param.h> 26#include <netinet/in.h> 27#include <netinet/in_systm.h> 28#include <netinet/ip.h> --- 59 unchanged lines hidden (view full) --- 88 CcpDecodeConfig, 89 CcpRecvResetReq, 90 CcpRecvResetAck 91}; 92 93static const char * const ccp_TimerNames[] = 94 {"CCP restart", "CCP openmode", "CCP stopped"}; 95 |
96static char const * const cftypes[] = { 97 /* Check out the latest ``Compression Control Protocol'' rfc (rfc1962.txt) */ 98 "OUI", /* 0: OUI */ 99 "PRED1", /* 1: Predictor type 1 */ 100 "PRED2", /* 2: Predictor type 2 */ 101 "PUDDLE", /* 3: Puddle Jumber */ 102 "???", "???", "???", "???", "???", "???", 103 "???", "???", "???", "???", "???", "???", 104 "HWPPC", /* 16: Hewlett-Packard PPC */ 105 "STAC", /* 17: Stac Electronics LZS (rfc1974) */ 106 "MPPC", /* 18: Microsoft PPC (rfc2118) */ 107 "GAND", /* 19: Gandalf FZA (rfc1993) */ 108 "V42BIS", /* 20: ARG->DATA.42bis compression */ 109 "BSD", /* 21: BSD LZW Compress */ 110 "???", 111 "LZS-DCP", /* 23: LZS-DCP Compression Protocol (rfc1967) */ 112 "MAGNALINK/DEFLATE", /* 24: Magnalink Variable Resource (rfc1975) */ 113 /* 24: Deflate (according to pppd-2.3.*) */ 114 "DCE", /* 25: Data Circuit-Terminating Equip (rfc1976) */ 115 "DEFLATE", /* 26: Deflate (rfc1979) */ 116}; 117 118#define NCFTYPES (sizeof cftypes/sizeof cftypes[0]) 119 | |
120static const char * 121protoname(int proto) 122{ | 96static const char * 97protoname(int proto) 98{ |
123 if (proto < 0 || proto > NCFTYPES) 124 return "none"; | 99 static char const * const cftypes[] = { 100 /* Check out the latest ``Compression Control Protocol'' rfc (1962) */ 101 "OUI", /* 0: OUI */ 102 "PRED1", /* 1: Predictor type 1 */ 103 "PRED2", /* 2: Predictor type 2 */ 104 "PUDDLE", /* 3: Puddle Jumber */ 105 NULL, NULL, NULL, NULL, NULL, NULL, 106 NULL, NULL, NULL, NULL, NULL, NULL, 107 "HWPPC", /* 16: Hewlett-Packard PPC */ 108 "STAC", /* 17: Stac Electronics LZS (rfc1974) */ 109 "MPPC", /* 18: Microsoft PPC (rfc2118) */ 110 "GAND", /* 19: Gandalf FZA (rfc1993) */ 111 "V42BIS", /* 20: ARG->DATA.42bis compression */ 112 "BSD", /* 21: BSD LZW Compress */ 113 NULL, 114 "LZS-DCP", /* 23: LZS-DCP Compression Protocol (rfc1967) */ 115 "MAGNALINK/DEFLATE",/* 24: Magnalink Variable Resource (rfc1975) */ 116 /* 24: Deflate (according to pppd-2.3.*) */ 117 "DCE", /* 25: Data Circuit-Terminating Equip (rfc1976) */ 118 "DEFLATE", /* 26: Deflate (rfc1979) */ 119 }; 120 121 if (proto < 0 || proto > sizeof cftypes / sizeof *cftypes || 122 cftypes[proto] == NULL) 123 return HexStr(proto, NULL, 0); 124 |
125 return cftypes[proto]; 126} 127 128/* We support these algorithms, and Req them in the given order */ 129static const struct ccp_algorithm * const algorithm[] = { 130 &DeflateAlgorithm, 131 &Pred1Algorithm, 132 &PppdDeflateAlgorithm --- 303 unchanged lines hidden (view full) --- 436 for (f = NALGORITHMS-1; f > -1; f--) 437 if (algorithm[f]->id == type) 438 break; 439 440 end = f == -1 ? "" : (*algorithm[f]->Disp)((struct lcp_opt *)cp); 441 if (end == NULL) 442 end = ""; 443 | 125 return cftypes[proto]; 126} 127 128/* We support these algorithms, and Req them in the given order */ 129static const struct ccp_algorithm * const algorithm[] = { 130 &DeflateAlgorithm, 131 &Pred1Algorithm, 132 &PppdDeflateAlgorithm --- 303 unchanged lines hidden (view full) --- 436 for (f = NALGORITHMS-1; f > -1; f--) 437 if (algorithm[f]->id == type) 438 break; 439 440 end = f == -1 ? "" : (*algorithm[f]->Disp)((struct lcp_opt *)cp); 441 if (end == NULL) 442 end = ""; 443 |
444 if (type < NCFTYPES) 445 log_Printf(LogCCP, " %s[%d] %s\n", cftypes[type], length, end); 446 else 447 log_Printf(LogCCP, " ???[%d] %s\n", length, end); | 444 log_Printf(LogCCP, " %s[%d] %s\n", protoname(type), length, end); |
448 449 if (f == -1) { 450 /* Don't understand that :-( */ 451 if (mode_type == MODE_REQ) { 452 ccp->my_reject |= (1 << type); 453 memcpy(dec->rejend, cp, length); 454 dec->rejend += length; 455 } --- 213 unchanged lines hidden --- | 445 446 if (f == -1) { 447 /* Don't understand that :-( */ 448 if (mode_type == MODE_REQ) { 449 ccp->my_reject |= (1 << type); 450 memcpy(dec->rejend, cp, length); 451 dec->rejend += length; 452 } --- 213 unchanged lines hidden --- |