libnetfilter_conntrack  1.0.9
proto.c
1 #include <internal/proto.h>
2 #include <internal/internal.h>
3 
4 static const uint8_t invmap_icmp[] = {
5  [ICMP_ECHO] = ICMP_ECHOREPLY + 1,
6  [ICMP_ECHOREPLY] = ICMP_ECHO + 1,
7  [ICMP_TIMESTAMP] = ICMP_TIMESTAMPREPLY + 1,
8  [ICMP_TIMESTAMPREPLY] = ICMP_TIMESTAMP + 1,
9  [ICMP_INFO_REQUEST] = ICMP_INFO_REPLY + 1,
10  [ICMP_INFO_REPLY] = ICMP_INFO_REQUEST + 1,
11  [ICMP_ADDRESS] = ICMP_ADDRESSREPLY + 1,
12  [ICMP_ADDRESSREPLY] = ICMP_ADDRESS + 1
13 };
14 
15 static const uint8_t invmap_icmpv6[] = {
16  [ICMPV6_ECHO_REQUEST - 128] = ICMPV6_ECHO_REPLY + 1,
17  [ICMPV6_ECHO_REPLY - 128] = ICMPV6_ECHO_REQUEST + 1,
18  [ICMPV6_NI_QUERY - 128] = ICMPV6_NI_REPLY + 1,
19  [ICMPV6_NI_REPLY - 128] = ICMPV6_NI_QUERY + 1
20 };
21 
22 uint8_t __icmp_reply_type(uint8_t type)
23 {
24  if (type < ARRAY_SIZE(invmap_icmp))
25  return invmap_icmp[type];
26 
27  return 0;
28 }
29 
30 uint8_t __icmpv6_reply_type(uint8_t type)
31 {
32  if (type - 128 < ARRAY_SIZE(invmap_icmpv6))
33  return invmap_icmpv6[type - 128];
34 
35  return 0;
36 }