]>
git.proxmox.com Git - mirror_iproute2.git/blob - lib/inet_proto.c
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>
17 #include <sys/socket.h>
18 #include <netinet/in.h>
25 const char *inet_proto_n2a(int proto
, char *buf
, int len
)
28 static int icache
= -1;
34 pe
= getprotobynumber(proto
);
39 ncache
= strdup(pe
->p_name
);
40 strlcpy(buf
, pe
->p_name
, len
);
43 snprintf(buf
, len
, "ipproto-%d", proto
);
47 int inet_proto_a2n(const char *buf
)
50 static int icache
= -1;
54 if (icache
!= -1 && strcmp(ncache
, buf
) == 0)
57 if (!get_u8(&ret
, buf
, 10))
60 pe
= getprotobyname(buf
);
65 ncache
= strdup(pe
->p_name
);