| 1 |
/* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 |
/* |
| 3 |
* ll_proto.c |
| 4 |
* |
| 5 |
* |
| 6 |
* Authors: Alexey Kuznetsov, <[email protected]> |
| 7 |
*/ |
| 8 |
|
| 9 |
#include <stdio.h> |
| 10 |
#include <stdlib.h> |
| 11 |
#include <unistd.h> |
| 12 |
#include <fcntl.h> |
| 13 |
#include <sys/ioctl.h> |
| 14 |
#include <sys/socket.h> |
| 15 |
#include <netinet/in.h> |
| 16 |
#include <arpa/inet.h> |
| 17 |
#include <string.h> |
| 18 |
|
| 19 |
#include <linux/netdevice.h> |
| 20 |
#include <linux/if_arp.h> |
| 21 |
#include <linux/sockios.h> |
| 22 |
|
| 23 |
#include "utils.h" |
| 24 |
#include "rt_names.h" |
| 25 |
|
| 26 |
|
| 27 |
#define __PF(f,n) { ETH_P_##f, #n }, |
| 28 |
|
| 29 |
static const struct proto llproto_names[] = { |
| 30 |
__PF(LOOP,loop) |
| 31 |
__PF(PUP,pup) |
| 32 |
__PF(PUPAT,pupat) |
| 33 |
__PF(IP,ip) |
| 34 |
__PF(X25,x25) |
| 35 |
__PF(ARP,arp) |
| 36 |
__PF(BPQ,bpq) |
| 37 |
__PF(IEEEPUP,ieeepup) |
| 38 |
__PF(IEEEPUPAT,ieeepupat) |
| 39 |
__PF(DEC,dec) |
| 40 |
__PF(DNA_DL,dna_dl) |
| 41 |
__PF(DNA_RC,dna_rc) |
| 42 |
__PF(DNA_RT,dna_rt) |
| 43 |
__PF(LAT,lat) |
| 44 |
__PF(DIAG,diag) |
| 45 |
__PF(CUST,cust) |
| 46 |
__PF(SCA,sca) |
| 47 |
__PF(RARP,rarp) |
| 48 |
__PF(ATALK,atalk) |
| 49 |
__PF(AARP,aarp) |
| 50 |
__PF(IPX,ipx) |
| 51 |
__PF(IPV6,ipv6) |
| 52 |
__PF(PPP_DISC,ppp_disc) |
| 53 |
__PF(PPP_SES,ppp_ses) |
| 54 |
__PF(ATMMPOA,atmmpoa) |
| 55 |
__PF(ATMFATE,atmfate) |
| 56 |
__PF(802_3,802_3) |
| 57 |
__PF(AX25,ax25) |
| 58 |
__PF(ALL,all) |
| 59 |
__PF(802_2,802_2) |
| 60 |
__PF(SNAP,snap) |
| 61 |
__PF(DDCMP,ddcmp) |
| 62 |
__PF(WAN_PPP,wan_ppp) |
| 63 |
__PF(PPP_MP,ppp_mp) |
| 64 |
__PF(LOCALTALK,localtalk) |
| 65 |
__PF(CAN,can) |
| 66 |
__PF(PPPTALK,ppptalk) |
| 67 |
__PF(TR_802_2,tr_802_2) |
| 68 |
__PF(MOBITEX,mobitex) |
| 69 |
__PF(CONTROL,control) |
| 70 |
__PF(IRDA,irda) |
| 71 |
__PF(ECONET,econet) |
| 72 |
__PF(TIPC,tipc) |
| 73 |
__PF(PROFINET,profinet) |
| 74 |
__PF(AOE,aoe) |
| 75 |
__PF(ETHERCAT,ethercat) |
| 76 |
__PF(8021Q,802.1Q) |
| 77 |
__PF(8021AD,802.1ad) |
| 78 |
__PF(MPLS_UC,mpls_uc) |
| 79 |
__PF(MPLS_MC,mpls_mc) |
| 80 |
__PF(TEB,teb) |
| 81 |
__PF(CFM,cfm) |
| 82 |
|
| 83 |
{ 0x8100, "802.1Q" }, |
| 84 |
{ 0x88cc, "LLDP" }, |
| 85 |
{ ETH_P_IP, "ipv4" }, |
| 86 |
}; |
| 87 |
#undef __PF |
| 88 |
|
| 89 |
const char *ll_proto_n2a(unsigned short id, char *buf, int len) |
| 90 |
{ |
| 91 |
size_t len_tb = ARRAY_SIZE(llproto_names); |
| 92 |
|
| 93 |
return proto_n2a(id, buf, len, llproto_names, len_tb); |
| 94 |
} |
| 95 |
|
| 96 |
int ll_proto_a2n(unsigned short *id, const char *buf) |
| 97 |
{ |
| 98 |
size_t len_tb = ARRAY_SIZE(llproto_names); |
| 99 |
|
| 100 |
return proto_a2n(id, buf, llproto_names, len_tb); |
| 101 |
} |