netinet*: use sparse C99 initializer for inetctlerrmap

and mark those PRC_* codes, that are used.  The rest are dead code.
This is not a functional change, but illustrative to make easier
review of following changes.
This commit is contained in:
Gleb Smirnoff 2022-10-03 20:53:04 -07:00
parent 43d39ca7e5
commit 53807a8a27
2 changed files with 28 additions and 13 deletions

View File

@ -873,13 +873,21 @@ ipproto_unregister(uint8_t proto)
return (ENOENT);
}
/* (x) - issued by icmp_input() */
u_char inetctlerrmap[PRC_NCMDS] = {
0, 0, 0, 0,
0, EMSGSIZE, EHOSTDOWN, EHOSTUNREACH,
EHOSTUNREACH, EHOSTUNREACH, ECONNREFUSED, ECONNREFUSED,
EMSGSIZE, EHOSTUNREACH, 0, 0,
0, 0, EHOSTUNREACH, 0,
ENOPROTOOPT, ECONNREFUSED
[PRC_MSGSIZE] = EMSGSIZE, /* (x) */
[PRC_HOSTDEAD] = EHOSTDOWN,
[PRC_HOSTUNREACH] = EHOSTUNREACH,
[PRC_UNREACH_NET] = EHOSTUNREACH, /* (x) */
[PRC_UNREACH_HOST] = EHOSTUNREACH,
[PRC_UNREACH_PROTOCOL] = ECONNREFUSED, /* (x) */
[PRC_UNREACH_PORT] = ECONNREFUSED, /* (x) */
[12] = EMSGSIZE,
[PRC_UNREACH_SRCFAIL] = EHOSTUNREACH,
[PRC_TIMXCEED_INTRANS] = EHOSTUNREACH, /* (x) */
[PRC_TIMXCEED_REASS] = 0, /* (x) */
[PRC_PARAMPROB] = ENOPROTOOPT, /* (x) */
[PRC_UNREACH_ADMIN_PROHIB] = ECONNREFUSED, /* (x) */
};
/*

View File

@ -1710,13 +1710,20 @@ ip6_lasthdr(const struct mbuf *m, int off, int proto, int *nxtp)
/*
* System control for IP6
* (x) - issued by icmp6_input()
*/
u_char inet6ctlerrmap[PRC_NCMDS] = {
0, 0, 0, 0,
0, EMSGSIZE, EHOSTDOWN, EHOSTUNREACH,
EHOSTUNREACH, EHOSTUNREACH, ECONNREFUSED, ECONNREFUSED,
EMSGSIZE, EHOSTUNREACH, 0, 0,
0, 0, EHOSTUNREACH, 0,
ENOPROTOOPT, ECONNREFUSED
[PRC_MSGSIZE] = EMSGSIZE, /* (x) */
[PRC_HOSTDEAD] = EHOSTDOWN,
[PRC_HOSTUNREACH] = EHOSTUNREACH,
[PRC_UNREACH_NET] = EHOSTUNREACH, /* (x) */
[PRC_UNREACH_HOST] = EHOSTUNREACH,
[PRC_UNREACH_PROTOCOL] = ECONNREFUSED, /* (x) */
[PRC_UNREACH_PORT] = ECONNREFUSED, /* (x) */
[12] = EMSGSIZE,
[PRC_UNREACH_SRCFAIL] = EHOSTUNREACH,
[PRC_TIMXCEED_INTRANS] = EHOSTUNREACH, /* (x) */
[PRC_TIMXCEED_REASS] = 0, /* (x) */
[PRC_PARAMPROB] = ENOPROTOOPT, /* (x) */
[PRC_UNREACH_ADMIN_PROHIB] = ECONNREFUSED, /* (x) */
};