From c905df5091647a7076a6c9da188e3098e8d9cd1c Mon Sep 17 00:00:00 2001 From: brian Date: Tue, 14 Mar 2000 01:46:54 +0000 Subject: When ppp can't identify the relevant name, don't use "???", use or <0xxxx> instead. --- usr.sbin/ppp/lcp.c | 71 +++++++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 33 deletions(-) (limited to 'usr.sbin/ppp/lcp.c') diff --git a/usr.sbin/ppp/lcp.c b/usr.sbin/ppp/lcp.c index 8df2061..74a2849 100644 --- a/usr.sbin/ppp/lcp.c +++ b/usr.sbin/ppp/lcp.c @@ -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 */ -}; - -#define NCFTYPES (sizeof cftypes/sizeof cftypes[0]) +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 */ + }; + + 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); -- cgit v1.1