]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - lib/ll_proto.c
libnetlink: Convert GETMDB dumps to use rtnl_mdbdump_req
[mirror_iproute2.git] / lib / ll_proto.c
index 2277cda384693d2185f83a1a32c2448158bb75db..8316a75539efd603177fafa9b8285b3f3792c43c 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <syslog.h>
 #include <fcntl.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
-#include <sys/ioctl.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <string.h>
@@ -30,7 +28,7 @@
 
 
 #define __PF(f,n) { ETH_P_##f, #n },
-static struct {
+static const struct {
        int id;
        const char *name;
 } llproto_names[] = {
@@ -78,8 +76,11 @@ __PF(IRDA,irda)
 __PF(ECONET,econet)
 __PF(TIPC,tipc)
 __PF(AOE,aoe)
+__PF(8021Q,802.1Q)
+__PF(8021AD,802.1ad)
 
 { 0x8100, "802.1Q" },
+{ 0x88cc, "LLDP" },
 { ETH_P_IP, "ipv4" },
 };
 #undef __PF
@@ -99,17 +100,16 @@ const char * ll_proto_n2a(unsigned short id, char *buf, int len)
         return buf;
 }
 
-int ll_proto_a2n(unsigned short *id, char *buf)
+int ll_proto_a2n(unsigned short *id, const char *buf)
 {
         int i;
-        for (i=0; i<sizeof(llproto_names)/sizeof(llproto_names[0]); i++) {
+        for (i=0; i < sizeof(llproto_names)/sizeof(llproto_names[0]); i++) {
                  if (strcasecmp(llproto_names[i].name, buf) == 0) {
                         *id = htons(llproto_names[i].id);
                         return 0;
                 }
        }
-       if (get_u16(id, buf, 0))
+       if (get_be16(id, buf, 0))
                return -1;
-       *id = htons(*id);
        return 0;
 }