summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/lcp.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>2000-03-14 01:46:54 +0000
committerbrian <brian@FreeBSD.org>2000-03-14 01:46:54 +0000
commitc905df5091647a7076a6c9da188e3098e8d9cd1c (patch)
treea9ddb1687fccd6cf0e8e107fd15255251a137904 /usr.sbin/ppp/lcp.c
parent3b65c00f328daf0fc8db68d8f715a571e8c6e184 (diff)
downloadFreeBSD-src-c905df5091647a7076a6c9da188e3098e8d9cd1c.zip
FreeBSD-src-c905df5091647a7076a6c9da188e3098e8d9cd1c.tar.gz
When ppp can't identify the relevant name, don't use "???", use
<nnn> or <0xxxx> instead.
Diffstat (limited to 'usr.sbin/ppp/lcp.c')
-rw-r--r--usr.sbin/ppp/lcp.c71
1 files changed, 38 insertions, 33 deletions
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);
OpenPOWER on IntegriCloud