Browse Source

make protocol table zero byte separated and add ipv6 protocols

master
Timo Teräs 11 years ago
committed by Rich Felker
parent
commit
6a5242e4cb
  1. 48
      src/network/proto.c

48
src/network/proto.c

@ -4,25 +4,28 @@
/* do we really need all these?? */ /* do we really need all these?? */
static int idx; static int idx;
static const unsigned char protos[][8] = { static const unsigned char protos[] = {
"\000ip", "\000ip\0"
"\001icmp", "\001icmp\0"
"\002igmp", "\002igmp\0"
"\003ggp", "\003ggp\0"
"\006tcp", "\006tcp\0"
"\014pup", "\014pup\0"
"\021udp", "\021udp\0"
"\026idp", "\026idp\0"
"\051ipv6", "\051ipv6\0"
"\057gre", "\053ipv6-route\0"
"\062esp", "\054ipv6-frag\0"
"\063ah", "\057gre\0"
"\072icmpv6", "\062esp\0"
"\131ospf", "\063ah\0"
"\136ipip", "\072ipv6-icmp\0"
"\147pim", "\073ipv6-nonxt\0"
"\377raw", "\074ipv6-opts\0"
"\0\0" "\131ospf\0"
"\136ipip\0"
"\147pim\0"
"\377raw"
}; };
void endprotoent(void) void endprotoent(void)
@ -39,10 +42,11 @@ struct protoent *getprotoent(void)
{ {
static struct protoent p; static struct protoent p;
static const char *aliases; static const char *aliases;
if (!protos[idx][1]) return NULL; if (idx >= sizeof protos) return NULL;
p.p_proto = protos[idx][0]; p.p_proto = protos[idx];
p.p_name = (char *)protos[idx++]+1; p.p_name = (char *)&protos[idx+1];
p.p_aliases = (char **)&aliases; p.p_aliases = (char **)&aliases;
idx += strlen(p.p_name) + 2;
return &p; return &p;
} }

Loading…
Cancel
Save