Debian Codegraph @

lib/ppp_proto.c

raw
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Utilities for translating PPP protocols from strings
4 * and vice versa.
5 *
6 * Authors: Wojciech Drewek <[email protected]>
7 */
8
9 #include <linux/ppp_defs.h>
10 #include <linux/if_ether.h>
11 #include "utils.h"
12 #include "rt_names.h"
13
14 static const struct proto ppp_proto_names[] = {
15 {PPP_IP, "ip"},
16 {PPP_AT, "at"},
17 {PPP_IPX, "ipx"},
18 {PPP_VJC_COMP, "vjc_comp"},
19 {PPP_VJC_UNCOMP, "vjc_uncomp"},
20 {PPP_MP, "mp"},
21 {PPP_IPV6, "ipv6"},
22 {PPP_COMPFRAG, "compfrag"},
23 {PPP_COMP, "comp"},
24 {PPP_MPLS_UC, "mpls_uc"},
25 {PPP_MPLS_MC, "mpls_mc"},
26 {PPP_IPCP, "ipcp"},
27 {PPP_ATCP, "atcp"},
28 {PPP_IPXCP, "ipxcp"},
29 {PPP_IPV6CP, "ipv6cp"},
30 {PPP_CCPFRAG, "ccpfrag"},
31 {PPP_CCP, "ccp"},
32 {PPP_MPLSCP, "mplscp"},
33 {PPP_LCP, "lcp"},
34 {PPP_PAP, "pap"},
35 {PPP_LQR, "lqr"},
36 {PPP_CHAP, "chap"},
37 {PPP_CBCP, "cbcp"},
38 };
39
40 const char *ppp_proto_n2a(unsigned short id, char *buf, int len)
41 {
42 size_t len_tb = ARRAY_SIZE(ppp_proto_names);
43
44 return proto_n2a(id, buf, len, ppp_proto_names, len_tb);
45 }
46
47 int ppp_proto_a2n(unsigned short *id, const char *buf)
48 {
49 size_t len_tb = ARRAY_SIZE(ppp_proto_names);
50
51 return proto_a2n(id, buf, ppp_proto_names, len_tb);
52 }