aboutsummaryrefslogtreecommitdiffstats
path: root/net/mpd5/files/patch-ccp
blob: 3055d4f84643c951f6a2fe6f3bbefa1ede64cf4b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
Index: ccp.h
===================================================================
--- src/ccp.h	(revision 2511)
+++ src/ccp.h	(working copy)
@@ -39,7 +39,7 @@
   #define CCP_TY_PRED1		1	/* Predictor type 1 */
   #define CCP_TY_PRED2		2	/* Predictor type 2 */
   #define CCP_TY_PUDDLE		3	/* Puddle Jumper */
-  #define CCP_TY_HWPPC		16	/* Hewlett-Packard PPC */
+  #define CCP_TY_HPPPC		16	/* Hewlett-Packard PPC */
   #define CCP_TY_STAC		17	/* Stac Electronics LZS */
   #define CCP_TY_MPPC		18	/* Microsoft PPC */
   #define CCP_TY_GAND		19	/* Gandalf FZA */
@@ -50,6 +50,7 @@
   #define CCP_TY_DCE		25	/* Data Compression in Data Circuit-Terminating Equipment */
   #define CCP_TY_DEFLATE	26	/* Gzip "deflate" compression */
   #define CCP_TY_V44		27	/* V.44/LZJH Compression Protocol */
+  #define CCP_TY_LASTKNOWN	CCP_TY_V44
 
   #define CCP_OVERHEAD		2
 
--- src/ccp.c.orig	2023-10-27 15:59:28.379182000 +0700
+++ src/ccp.c	2023-10-27 16:00:57.038431000 +0700
@@ -60,7 +60,7 @@
   static int		CcpCheckEncryption(Bund b);
   static int		CcpSetCommand(Context ctx, int ac, const char *const av[], const void *arg);
   static CompType	CcpFindComp(int type, int *indexp);
-  static const char	*CcpTypeName(int type, char *buf, size_t len);
+  static const char	*CcpTypeName(u_char type, char *buf, size_t len);
 
   static void		CcpNgCtrlEvent(int type, void *cookie);
   static void		CcpNgDataEvent(int type, void *cookie);
@@ -132,28 +132,6 @@
     NULL, NULL, NULL, NULL
   };
 
-  /* Names for different types of compression */
-  static const struct ccpname {
-    u_char	type;
-    const char	*name;
-  } gCcpTypeNames[] = {
-    { CCP_TY_OUI,		"OUI" },
-    { CCP_TY_PRED1,		"PRED1" },
-    { CCP_TY_PRED2,		"PRED2" },
-    { CCP_TY_PUDDLE,		"PUDDLE" },
-    { CCP_TY_HWPPC,		"HWPPC" },
-    { CCP_TY_STAC,		"STAC" },
-    { CCP_TY_MPPC,		"MPPC" },
-    { CCP_TY_GAND,		"GAND" },
-    { CCP_TY_V42BIS,		"V42BIS" },
-    { CCP_TY_BSD,		"BSD" },
-    { CCP_TY_LZS_DCP,		"LZS-DCP" },
-    { CCP_TY_MVRCA,		"MVRCA" },
-    { CCP_TY_DCE,		"DCE" },
-    { CCP_TY_DEFLATE,		"DEFLATE" },
-    { CCP_TY_V44,		"V.44/LZJH" },
-    { 0,			NULL },
-  };
 
 int		gCcpCsock = -1;		/* Socket node control socket */
 int		gCcpDsock = -1;		/* Socket node data socket */
@@ -1107,17 +1085,35 @@ CcpFindComp(int type, int *indexp)
  */
 
 static const char *
-CcpTypeName(int type, char *buf, size_t len)
-{
-  const struct ccpname	*p;
+CcpTypeName(u_char type, char *buf, size_t len)
+ {
+  /* Names for different types of compression */
+  static const char * const ccpnames[] = {
+      "OUI",
+      "PRED1",
+      "PRED2",
+      "PUDDLE",
+      "HPPPC",
+      "STAC",
+      "MPPC",
+      "GAND",
+      "V42BIS",
+      "BSD",
+      "UNKNOWN[22]",
+      "LZS_DCP",
+      "MVRCA",
+      "DCE",
+      "DEFLATE",
+      "V.44/LZJH"
+  };
+  if (type <= CCP_TY_PUDDLE)
+    return(ccpnames[type]);
 
-  for (p = gCcpTypeNames; p->name; p++) {
-    if (p->type == type) {
-	strlcpy(buf, p->name, len);
-        return (buf);
-    }
-  }
-  snprintf(buf, sizeof(buf), "UNKNOWN[%d]", type);
+  if (type >= CCP_TY_HPPPC && type <= CCP_TY_LASTKNOWN)
+    /* type - (CCP_TY_HPPPC-CCP_TY_PUDDLE-1) */
+    return(ccpnames[type - 12]);
+
+  snprintf(buf, len, "UNKNOWN[%u]", (unsigned)type);
   return(buf);
 }