X-Git-Url: http://git.onelab.eu/?p=iproute2.git;a=blobdiff_plain;f=lib%2Finet_proto.c;fp=lib%2Finet_proto.c;h=0000000000000000000000000000000000000000;hp=a55e0e7ba3239eee32e87878f47ce458710f3087;hb=3331a68859fd71047bb1f309048960b48eab2d83;hpb=2bd4a72f2100be7ad7d9518cb1d49bb2a5b71994 diff --git a/lib/inet_proto.c b/lib/inet_proto.c deleted file mode 100644 index a55e0e7..0000000 --- a/lib/inet_proto.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * inet_proto.c - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - * - * Authors: Alexey Kuznetsov, - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "utils.h" - -char *inet_proto_n2a(int proto, char *buf, int len) -{ - static char ncache[16]; - static int icache = -1; - struct protoent *pe; - - if (proto == icache) - return ncache; - - pe = getprotobynumber(proto); - if (pe) { - icache = proto; - strncpy(ncache, pe->p_name, 16); - strncpy(buf, pe->p_name, len); - return buf; - } - snprintf(buf, len, "ipproto-%d", proto); - return buf; -} - -int inet_proto_a2n(char *buf) -{ - static char ncache[16]; - static int icache = -1; - struct protoent *pe; - - if (icache>=0 && strcmp(ncache, buf) == 0) - return icache; - - if (buf[0] >= '0' && buf[0] <= '9') { - __u8 ret; - if (get_u8(&ret, buf, 10)) - return -1; - return ret; - } - - pe = getprotobyname(buf); - if (pe) { - icache = pe->p_proto; - strncpy(ncache, pe->p_name, 16); - return pe->p_proto; - } - return -1; -} - -