4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
18 #include <sys/socket.h>
19 #include <netinet/in.h>
25 char *inet_proto_n2a(int proto, char *buf, int len)
27 static char ncache[16];
28 static int icache = -1;
34 pe = getprotobynumber(proto);
37 strncpy(ncache, pe->p_name, 16);
38 strncpy(buf, pe->p_name, len);
41 snprintf(buf, len, "ipproto-%d", proto);
45 int inet_proto_a2n(char *buf)
47 static char ncache[16];
48 static int icache = -1;
51 if (icache>=0 && strcmp(ncache, buf) == 0)
54 if (buf[0] >= '0' && buf[0] <= '9') {
56 if (get_u8(&ret, buf, 10))
61 pe = getprotobyname(buf);
64 strncpy(ncache, pe->p_name, 16);