summaryrefslogtreecommitdiffstats
path: root/lib/ppp_proto.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 14:18:53 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 14:18:53 +0000
commita0e0018c9a7ef5ce7f6d2c3ae16aecbbd16a8f67 (patch)
tree8feaf1a1932871b139b3b30be4c09c66489918be /lib/ppp_proto.c
parentInitial commit. (diff)
downloadiproute2-a0e0018c9a7ef5ce7f6d2c3ae16aecbbd16a8f67.tar.xz
iproute2-a0e0018c9a7ef5ce7f6d2c3ae16aecbbd16a8f67.zip
Adding upstream version 6.1.0.upstream/6.1.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--lib/ppp_proto.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/lib/ppp_proto.c b/lib/ppp_proto.c
new file mode 100644
index 0000000..a634664
--- /dev/null
+++ b/lib/ppp_proto.c
@@ -0,0 +1,52 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Utilities for translating PPP protocols from strings
+ * and vice versa.
+ *
+ * Authors: Wojciech Drewek <wojciech.drewek@intel.com>
+ */
+
+#include <linux/ppp_defs.h>
+#include <linux/if_ether.h>
+#include "utils.h"
+#include "rt_names.h"
+
+static const struct proto ppp_proto_names[] = {
+ {PPP_IP, "ip"},
+ {PPP_AT, "at"},
+ {PPP_IPX, "ipx"},
+ {PPP_VJC_COMP, "vjc_comp"},
+ {PPP_VJC_UNCOMP, "vjc_uncomp"},
+ {PPP_MP, "mp"},
+ {PPP_IPV6, "ipv6"},
+ {PPP_COMPFRAG, "compfrag"},
+ {PPP_COMP, "comp"},
+ {PPP_MPLS_UC, "mpls_uc"},
+ {PPP_MPLS_MC, "mpls_mc"},
+ {PPP_IPCP, "ipcp"},
+ {PPP_ATCP, "atcp"},
+ {PPP_IPXCP, "ipxcp"},
+ {PPP_IPV6CP, "ipv6cp"},
+ {PPP_CCPFRAG, "ccpfrag"},
+ {PPP_CCP, "ccp"},
+ {PPP_MPLSCP, "mplscp"},
+ {PPP_LCP, "lcp"},
+ {PPP_PAP, "pap"},
+ {PPP_LQR, "lqr"},
+ {PPP_CHAP, "chap"},
+ {PPP_CBCP, "cbcp"},
+};
+
+const char *ppp_proto_n2a(unsigned short id, char *buf, int len)
+{
+ size_t len_tb = ARRAY_SIZE(ppp_proto_names);
+
+ return proto_n2a(id, buf, len, ppp_proto_names, len_tb);
+}
+
+int ppp_proto_a2n(unsigned short *id, const char *buf)
+{
+ size_t len_tb = ARRAY_SIZE(ppp_proto_names);
+
+ return proto_a2n(id, buf, ppp_proto_names, len_tb);
+}