When ppp can't identify the relevant name, don't use "???", use
<nnn> or <0xxxx> instead.
This commit is contained in:
parent
52c9ca1968
commit
d6d3eeab46
@ -151,7 +151,7 @@ cbcpstate(int s)
|
||||
{
|
||||
if (s < sizeof cbcpname / sizeof cbcpname[0])
|
||||
return cbcpname[s];
|
||||
return "???";
|
||||
return HexStr(s, NULL, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -214,7 +214,7 @@ cbcp_data_Type(int type)
|
||||
};
|
||||
|
||||
if (type < 1 || type > sizeof types / sizeof types[0])
|
||||
return "???";
|
||||
return HexStr(type, NULL, 0);
|
||||
return types[type-1];
|
||||
}
|
||||
|
||||
|
@ -93,35 +93,35 @@ static struct fsm_callbacks ccp_Callbacks = {
|
||||
static const char * const ccp_TimerNames[] =
|
||||
{"CCP restart", "CCP openmode", "CCP stopped"};
|
||||
|
||||
static char const * const cftypes[] = {
|
||||
/* Check out the latest ``Compression Control Protocol'' rfc (rfc1962.txt) */
|
||||
"OUI", /* 0: OUI */
|
||||
"PRED1", /* 1: Predictor type 1 */
|
||||
"PRED2", /* 2: Predictor type 2 */
|
||||
"PUDDLE", /* 3: Puddle Jumber */
|
||||
"???", "???", "???", "???", "???", "???",
|
||||
"???", "???", "???", "???", "???", "???",
|
||||
"HWPPC", /* 16: Hewlett-Packard PPC */
|
||||
"STAC", /* 17: Stac Electronics LZS (rfc1974) */
|
||||
"MPPC", /* 18: Microsoft PPC (rfc2118) */
|
||||
"GAND", /* 19: Gandalf FZA (rfc1993) */
|
||||
"V42BIS", /* 20: ARG->DATA.42bis compression */
|
||||
"BSD", /* 21: BSD LZW Compress */
|
||||
"???",
|
||||
"LZS-DCP", /* 23: LZS-DCP Compression Protocol (rfc1967) */
|
||||
"MAGNALINK/DEFLATE", /* 24: Magnalink Variable Resource (rfc1975) */
|
||||
/* 24: Deflate (according to pppd-2.3.*) */
|
||||
"DCE", /* 25: Data Circuit-Terminating Equip (rfc1976) */
|
||||
"DEFLATE", /* 26: Deflate (rfc1979) */
|
||||
};
|
||||
|
||||
#define NCFTYPES (sizeof cftypes/sizeof cftypes[0])
|
||||
|
||||
static const char *
|
||||
protoname(int proto)
|
||||
{
|
||||
if (proto < 0 || proto > NCFTYPES)
|
||||
return "none";
|
||||
static char const * const cftypes[] = {
|
||||
/* Check out the latest ``Compression Control Protocol'' rfc (1962) */
|
||||
"OUI", /* 0: OUI */
|
||||
"PRED1", /* 1: Predictor type 1 */
|
||||
"PRED2", /* 2: Predictor type 2 */
|
||||
"PUDDLE", /* 3: Puddle Jumber */
|
||||
NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
"HWPPC", /* 16: Hewlett-Packard PPC */
|
||||
"STAC", /* 17: Stac Electronics LZS (rfc1974) */
|
||||
"MPPC", /* 18: Microsoft PPC (rfc2118) */
|
||||
"GAND", /* 19: Gandalf FZA (rfc1993) */
|
||||
"V42BIS", /* 20: ARG->DATA.42bis compression */
|
||||
"BSD", /* 21: BSD LZW Compress */
|
||||
NULL,
|
||||
"LZS-DCP", /* 23: LZS-DCP Compression Protocol (rfc1967) */
|
||||
"MAGNALINK/DEFLATE",/* 24: Magnalink Variable Resource (rfc1975) */
|
||||
/* 24: Deflate (according to pppd-2.3.*) */
|
||||
"DCE", /* 25: Data Circuit-Terminating Equip (rfc1976) */
|
||||
"DEFLATE", /* 26: Deflate (rfc1979) */
|
||||
};
|
||||
|
||||
if (proto < 0 || proto > sizeof cftypes / sizeof *cftypes ||
|
||||
cftypes[proto] == NULL)
|
||||
return HexStr(proto, NULL, 0);
|
||||
|
||||
return cftypes[proto];
|
||||
}
|
||||
|
||||
@ -441,10 +441,7 @@ CcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
if (end == NULL)
|
||||
end = "";
|
||||
|
||||
if (type < NCFTYPES)
|
||||
log_Printf(LogCCP, " %s[%d] %s\n", cftypes[type], length, end);
|
||||
else
|
||||
log_Printf(LogCCP, " ???[%d] %s\n", length, end);
|
||||
log_Printf(LogCCP, " %s[%d] %s\n", protoname(type), length, end);
|
||||
|
||||
if (f == -1) {
|
||||
/* Don't understand that :-( */
|
||||
|
@ -35,6 +35,7 @@
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <termios.h>
|
||||
@ -315,3 +316,29 @@ MakeArgs(char *script, char **pvect, int maxargs, int flags)
|
||||
*pvect = NULL;
|
||||
return nargs;
|
||||
}
|
||||
|
||||
const char *
|
||||
NumStr(long val, char *buf, size_t sz)
|
||||
{
|
||||
static char result[23]; /* handles 64 bit numbers */
|
||||
|
||||
if (buf == NULL || sz == 0) {
|
||||
buf = result;
|
||||
sz = sizeof result;
|
||||
}
|
||||
snprintf(buf, sz, "<%ld>", val);
|
||||
return buf;
|
||||
}
|
||||
|
||||
const char *
|
||||
HexStr(long val, char *buf, size_t sz)
|
||||
{
|
||||
static char result[21]; /* handles 64 bit numbers */
|
||||
|
||||
if (buf == NULL || sz == 0) {
|
||||
buf = result;
|
||||
sz = sizeof result;
|
||||
}
|
||||
snprintf(buf, sz, "<0x%lx>", val);
|
||||
return buf;
|
||||
}
|
||||
|
@ -107,3 +107,5 @@ extern int SpeedToInt(speed_t);
|
||||
extern speed_t IntToSpeed(int);
|
||||
extern char *findblank(char *, int);
|
||||
extern int MakeArgs(char *, char **, int, int);
|
||||
extern const char *NumStr(long, char *, size_t);
|
||||
extern const char *HexStr(long, char *, size_t);
|
||||
|
@ -104,8 +104,7 @@ dns_Qclass2Txt(u_short qclass)
|
||||
if (qtxt[f].id == qclass)
|
||||
return qtxt[f].txt;
|
||||
|
||||
snprintf(failure, sizeof failure, "<0x%02x>", qclass);
|
||||
return failure;
|
||||
return HexStr(qclass, failure, sizeof failure);
|
||||
}
|
||||
|
||||
static const char *
|
||||
@ -132,8 +131,7 @@ dns_Qtype2Txt(u_short qtype)
|
||||
if (qtxt[f].id == qtype)
|
||||
return qtxt[f].txt;
|
||||
|
||||
snprintf(failure, sizeof failure, "<0x%02x>", qtype);
|
||||
return failure;
|
||||
return HexStr(qtype, failure, sizeof failure);
|
||||
}
|
||||
|
||||
static __inline int
|
||||
|
@ -208,26 +208,30 @@ static struct fsm_callbacks ipcp_Callbacks = {
|
||||
fsm_NullRecvResetAck
|
||||
};
|
||||
|
||||
static const char * const cftypes[] = {
|
||||
/* Check out the latest ``Assigned numbers'' rfc (rfc1700.txt) */
|
||||
"???",
|
||||
"IPADDRS", /* 1: IP-Addresses */ /* deprecated */
|
||||
"COMPPROTO", /* 2: IP-Compression-Protocol */
|
||||
"IPADDR", /* 3: IP-Address */
|
||||
};
|
||||
static const char *
|
||||
protoname(int proto)
|
||||
{
|
||||
static struct {
|
||||
int id;
|
||||
const char *txt;
|
||||
} cftypes[] = {
|
||||
/* Check out the latest ``Assigned numbers'' rfc (rfc1700.txt) */
|
||||
{ 1, "IPADDRS" }, /* IP-Addresses */ /* deprecated */
|
||||
{ 2, "COMPPROTO" }, /* IP-Compression-Protocol */
|
||||
{ 3, "IPADDR" }, /* IP-Address */
|
||||
{ 129, "PRIDNS" }, /* 129: Primary DNS Server Address */
|
||||
{ 130, "PRINBNS" }, /* 130: Primary NBNS Server Address */
|
||||
{ 131, "SECDNS" }, /* 131: Secondary DNS Server Address */
|
||||
{ 132, "SECNBNS" } /* 132: Secondary NBNS Server Address */
|
||||
};
|
||||
int f;
|
||||
|
||||
#define NCFTYPES (sizeof cftypes/sizeof cftypes[0])
|
||||
for (f = 0; f < sizeof cftypes / sizeof *cftypes; f++)
|
||||
if (cftypes[f].id == proto)
|
||||
return cftypes[f].txt;
|
||||
|
||||
static const char * const cftypes128[] = {
|
||||
/* Check out the latest ``Assigned numbers'' rfc (rfc1700.txt) */
|
||||
"???",
|
||||
"PRIDNS", /* 129: Primary DNS Server Address */
|
||||
"PRINBNS", /* 130: Primary NBNS Server Address */
|
||||
"SECDNS", /* 131: Secondary DNS Server Address */
|
||||
"SECNBNS", /* 132: Secondary NBNS Server Address */
|
||||
};
|
||||
|
||||
#define NCFTYPES128 (sizeof cftypes128/sizeof cftypes128[0])
|
||||
return NumStr(proto, NULL, 0);
|
||||
}
|
||||
|
||||
void
|
||||
ipcp_AddInOctets(struct ipcp *ipcp, int n)
|
||||
@ -960,12 +964,7 @@ IpcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
break;
|
||||
}
|
||||
|
||||
if (type < NCFTYPES)
|
||||
snprintf(tbuff, sizeof tbuff, " %s[%d] ", cftypes[type], length);
|
||||
else if (type > 128 && type < 128 + NCFTYPES128)
|
||||
snprintf(tbuff, sizeof tbuff, " %s[%d] ", cftypes128[type-128], length);
|
||||
else
|
||||
snprintf(tbuff, sizeof tbuff, " <%d>[%d] ", type, length);
|
||||
snprintf(tbuff, sizeof tbuff, " %s[%d] ", protoname(type), length);
|
||||
|
||||
switch (type) {
|
||||
case TY_IPADDR: /* RFC1332 */
|
||||
|
@ -104,35 +104,43 @@ static struct fsm_callbacks lcp_Callbacks = {
|
||||
static const char * const lcp_TimerNames[] =
|
||||
{"LCP restart", "LCP openmode", "LCP stopped"};
|
||||
|
||||
static const char * const cftypes[] = {
|
||||
/* Check out the latest ``Assigned numbers'' rfc (rfc1700.txt) */
|
||||
"???",
|
||||
"MRU", /* 1: Maximum-Receive-Unit */
|
||||
"ACCMAP", /* 2: Async-Control-Character-Map */
|
||||
"AUTHPROTO", /* 3: Authentication-Protocol */
|
||||
"QUALPROTO", /* 4: Quality-Protocol */
|
||||
"MAGICNUM", /* 5: Magic-Number */
|
||||
"RESERVED", /* 6: RESERVED */
|
||||
"PROTOCOMP", /* 7: Protocol-Field-Compression */
|
||||
"ACFCOMP", /* 8: Address-and-Control-Field-Compression */
|
||||
"FCSALT", /* 9: FCS-Alternatives */
|
||||
"SDP", /* 10: Self-Describing-Pad */
|
||||
"NUMMODE", /* 11: Numbered-Mode */
|
||||
"MULTIPROC", /* 12: Multi-Link-Procedure */
|
||||
"CALLBACK", /* 13: Callback */
|
||||
"CONTIME", /* 14: Connect-Time */
|
||||
"COMPFRAME", /* 15: Compound-Frames */
|
||||
"NDE", /* 16: Nominal-Data-Encapsulation */
|
||||
"MRRU", /* 17: Multilink-MRRU */
|
||||
"SHORTSEQ", /* 18: Multilink-Short-Sequence-Number-Header */
|
||||
"ENDDISC", /* 19: Multilink-Endpoint-Discriminator */
|
||||
"PROPRIETRY", /* 20: Proprietary */
|
||||
"DCEID", /* 21: DCE-Identifier */
|
||||
"MULTIPP", /* 22: Multi-Link-Plus-Procedure */
|
||||
"LDBACP", /* 23: Link Discriminator for BACP */
|
||||
};
|
||||
static const char *
|
||||
protoname(int proto)
|
||||
{
|
||||
static const char * const cftypes[] = {
|
||||
/* Check out the latest ``Assigned numbers'' rfc (1700) */
|
||||
NULL,
|
||||
"MRU", /* 1: Maximum-Receive-Unit */
|
||||
"ACCMAP", /* 2: Async-Control-Character-Map */
|
||||
"AUTHPROTO", /* 3: Authentication-Protocol */
|
||||
"QUALPROTO", /* 4: Quality-Protocol */
|
||||
"MAGICNUM", /* 5: Magic-Number */
|
||||
"RESERVED", /* 6: RESERVED */
|
||||
"PROTOCOMP", /* 7: Protocol-Field-Compression */
|
||||
"ACFCOMP", /* 8: Address-and-Control-Field-Compression */
|
||||
"FCSALT", /* 9: FCS-Alternatives */
|
||||
"SDP", /* 10: Self-Describing-Pad */
|
||||
"NUMMODE", /* 11: Numbered-Mode */
|
||||
"MULTIPROC", /* 12: Multi-Link-Procedure */
|
||||
"CALLBACK", /* 13: Callback */
|
||||
"CONTIME", /* 14: Connect-Time */
|
||||
"COMPFRAME", /* 15: Compound-Frames */
|
||||
"NDE", /* 16: Nominal-Data-Encapsulation */
|
||||
"MRRU", /* 17: Multilink-MRRU */
|
||||
"SHORTSEQ", /* 18: Multilink-Short-Sequence-Number-Header */
|
||||
"ENDDISC", /* 19: Multilink-Endpoint-Discriminator */
|
||||
"PROPRIETRY", /* 20: Proprietary */
|
||||
"DCEID", /* 21: DCE-Identifier */
|
||||
"MULTIPP", /* 22: Multi-Link-Plus-Procedure */
|
||||
"LDBACP", /* 23: Link Discriminator for BACP */
|
||||
};
|
||||
|
||||
#define NCFTYPES (sizeof cftypes/sizeof cftypes[0])
|
||||
if (proto < 0 || proto > sizeof cftypes / sizeof *cftypes ||
|
||||
cftypes[proto] == NULL)
|
||||
return HexStr(proto, NULL, 0);
|
||||
|
||||
return cftypes[proto];
|
||||
}
|
||||
|
||||
int
|
||||
lcp_ReportStatus(struct cmdargs const *arg)
|
||||
@ -546,10 +554,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
type = *cp;
|
||||
length = cp[1];
|
||||
|
||||
if (type < 0 || type >= NCFTYPES)
|
||||
snprintf(request, sizeof request, " <%d>[%d]", type, length);
|
||||
else
|
||||
snprintf(request, sizeof request, " %s[%d]", cftypes[type], length);
|
||||
snprintf(request, sizeof request, " %s[%d]", protoname(type), length);
|
||||
|
||||
if (length < 2) {
|
||||
log_Printf(LogLCP, "%s:%s: Bad LCP length\n", fp->link->name, request);
|
||||
|
@ -300,13 +300,13 @@ Index2Nam(int idx)
|
||||
if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) {
|
||||
log_Printf(LogERROR, "Index2Nam: sysctl: estimate: %s\n",
|
||||
strerror(errno));
|
||||
return "???";
|
||||
return NumStr(idx, NULL, 0);
|
||||
}
|
||||
if ((buf = malloc(needed)) == NULL)
|
||||
return "???";
|
||||
return NumStr(idx, NULL, 0);
|
||||
if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) {
|
||||
free(buf);
|
||||
return "???";
|
||||
return NumStr(idx, NULL, 0);
|
||||
}
|
||||
end = buf + needed;
|
||||
|
||||
@ -334,7 +334,7 @@ Index2Nam(int idx)
|
||||
ifs = NULL;
|
||||
}
|
||||
free(buf);
|
||||
return "???";
|
||||
return NumStr(idx, NULL, 0);
|
||||
}
|
||||
ifs = newifs;
|
||||
memset(ifs + had, '\0', sizeof(char *) * (have - had));
|
||||
@ -364,7 +364,7 @@ Index2Nam(int idx)
|
||||
}
|
||||
|
||||
if (idx < 1 || idx > nifs || ifs[idx-1] == NULL)
|
||||
return "???";
|
||||
return NumStr(idx, NULL, 0);
|
||||
|
||||
return ifs[idx-1];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user