nrpe: update to 4.1.3
[oi-userland.git] / components / sysutils / snort / patches / 05-u6_addr.patch
blob0fc64ce7dccbc1b957dd9db90a748016e5a33667
1 We don't export s6_addr16 and don't have
2 suitable uint16_t member in in6_addr
3 --- snort-2.9.9.0/src/sfutil/sf_ip.h.~2~ 2017-02-01 21:45:38.917735171 +0300
4 +++ snort-2.9.9.0/src/sfutil/sf_ip.h 2017-02-01 21:48:52.021491697 +0300
5 @@ -44,6 +44,7 @@
7 #include "snort_debug.h" /* for inline definition */
8 #include "sf_types.h"
9 +#include <inttypes.h>
11 /* define SFIP_ROBUST to check pointers passed into the sfip libs.
12 * Robustification should not be enabled if the client code is trustworthy.
13 @@ -75,13 +76,25 @@
15 #ifndef WIN32
16 #if !defined(s6_addr8)
17 -#define s6_addr8 __u6_addr.__u6_addr8
18 +#if defined __sun
19 +#define s6_addr8 _S6_un._S6_u8
20 +#else
21 +#define s6_addr8 u6_addr.u6_addr8
22 +#endif
23 #endif
24 #if !defined(s6_addr16)
25 -#define s6_addr16 __u6_addr.__u6_addr16
26 +#if defined __sun
27 +/* Unfortunately, we don't have uint16_t[] member here */
28 +#else
29 +#define s6_addr16 u6_addr.u6_addr16
30 +#endif
31 #endif
32 #if !defined(s6_addr32)
33 -#define s6_addr32 __u6_addr.__u6_addr32
34 +#if defined __sun
35 +#define s6_addr32 _S6_un._S6_u32
36 +#else
37 +#define s6_addr32 u6_addr.u6_addr32
38 +#endif
39 #endif
41 #ifdef _WIN32
42 @@ -93,7 +106,9 @@
43 struct in6_addr ip;
44 uint16_t family;
45 # define ia8 ip.s6_addr
46 +#if !defined(__sun)
47 # define ia16 ip.s6_addr16
48 +#endif
49 # define ia32 ip.s6_addr32
50 #ifdef _WIN32
52 @@ -272,16 +287,26 @@
53 * need to determine if it's safe to not check these pointers */\
54 static inline int sfraw_is_set(const struct in6_addr *addr) {
55 /* ARG_CHECK1(ip, -1); */
56 +#ifdef __sun
57 + return (addr->s6_addr32[3] || addr->s6_addr32[0] || addr->s6_addr32[1] || ((uint16_t*)(addr->s6_addr32))[4] ||
58 + (((uint16_t*)(addr->s6_addr32))[5] && ((uint16_t*)(addr->s6_addr32))[5] != 0xFFFF)) ? 1 : 0;
59 +#else
60 return (addr->s6_addr32[3] || addr->s6_addr32[0] || addr->s6_addr32[1] || addr->s6_addr16[4] ||
61 (addr->s6_addr16[5] && addr->s6_addr16[5] != 0xFFFF)) ? 1 : 0;
62 +#endif
65 static inline int sfaddr_is_set(const sfaddr_t *addr) {
66 /* ARG_CHECK1(ip, -1); */
67 return ((addr->family == AF_INET && addr->ia32[3]) ||
68 (addr->family == AF_INET6 &&
69 +#ifdef __sun
70 + (addr->ia32[0] || addr->ia32[1] || addr->ia32[3] || ((uint16_t*)(addr->ia32))[4] ||
71 + (((uint16_t *)(addr->ia32))[5] && ((uint16_t*)(addr->ia32))[5] != 0xFFFF)))) ? 1 : 0;
72 +#else
73 (addr->ia32[0] || addr->ia32[1] || addr->ia32[3] || addr->ia16[4] ||
74 (addr->ia16[5] && addr->ia16[5] != 0xFFFF)))) ? 1 : 0;
75 +#endif
78 static inline int sfip_is_set(const sfcidr_t *ip) {
79 @@ -297,8 +322,11 @@
80 /* Returns 1 if the IPv6 address appears mapped. 0 otherwise. */
81 static inline int sfip_ismapped(const sfaddr_t *ip) {
82 ARG_CHECK1(ip, 0);
84 +#ifdef __sun
85 + return (ip->ia32[0] || ip->ia32[1] || ((uint16_t*)(ip->ia32))[4] || ( ((uint16_t*)(ip->ia32))[5] != 0xffff && ((uint16_t*)(ip->ia32))[5])) ? 0 : 1;
86 +#else
87 return (ip->ia32[0] || ip->ia32[1] || ip->ia16[4] || (ip->ia16[5] != 0xffff && ip->ia16[5])) ? 0 : 1;
88 +#endif
91 /* Support function for sfip_compare */
92 @@ -532,9 +560,15 @@
94 /* Check the first 80 bits in an IPv6 address, and */
95 /* verify they're zero. If not, it's not a loopback */
96 - if(ip->ia32[0] || ip->ia32[1] || ip->ia16[4]) return 0;
97 +#ifdef __sun
98 + if(ip->ia32[0] || ip->ia32[1] || ((uint16_t *)(ip->ia32))[4]) return 0;
100 + if ( ((uint16_t *)(ip->ia32))[5] == 0xffff ) {
101 +#else
102 + if(ip->ia32[0] || ip->ia32[1] || ip->ia16[4]) return 0;
104 if ( ip->ia16[5] == 0xffff ) {
105 +#endif
106 /* ::ffff: IPv4 mapped over IPv6 */
108 * 10.0.0.0 - 10.255.255.255 (10/8 prefix)
109 @@ -547,7 +581,11 @@
112 /* Check if the 3rd 32-bit int is zero */
113 +#ifdef __sun
114 + if ( !((uint16_t *)(ip->ia32))[5] ) {
115 +#else
116 if ( !ip->ia16[5] ) {
117 +#endif
118 /* ::ipv4 compatible ipv6 */
119 /* ::1 is the IPv6 loopback */
120 return ( (ip->ia8[12] == 10)
121 --- snort-2.9.9.0/src/sfutil/sfrt.h.1 2017-02-01 21:50:21.485565677 +0300
122 +++ snort-2.9.9.0/src/sfutil/sfrt.h 2017-02-01 21:51:56.601538134 +0300
123 @@ -229,7 +229,11 @@
124 rt = table->rt;
125 subtable = ((dir_table_t *)rt)->sub_table;
126 /* 16 bits*/
127 +#ifdef __sun
128 + index = ntohs (((uint16_t*)(ip->ia8))[6]);
129 +#else
130 index = ntohs(ip->ia16[6]);
131 +#endif
132 if( !subtable->entries[index] || subtable->lengths[index] )
134 return table->data[subtable->entries[index]];
135 --- snort-2.9.9.0/src/sfutil/sfrt_flat.h.1 2017-02-01 21:53:43.221557566 +0300
136 +++ snort-2.9.9.0/src/sfutil/sfrt_flat.h 2017-02-01 21:55:02.016896936 +0300
137 @@ -102,7 +102,11 @@
138 rt = (dir_table_flat_t *)(&base[table->rt]);
139 subtable = (dir_sub_table_flat_t *)(&base[rt->sub_table]);
140 /* 16 bits */
141 +#ifdef __sun
142 + index = ntohs(((uint16_t*)(ip->ia8))[6]);
143 +#else
144 index = ntohs(ip->ia16[6]);
145 +#endif
146 entries_value = (Entry_Value *)(&base[subtable->entries_value]);
147 entries_length = (Entry_Len *)(&base[subtable->entries_length]);
148 if( !entries_value[index] || entries_length[index] )
149 --- snort-2.9.9.0/src/sfutil/sf_ip.c 2016-06-07 10:47:49.000000000 +0300
150 +++ snort-2.9.9.0/src/sfutil/sf_ip.c 2017-02-01 22:03:00.217171822 +0300
151 @@ -386,8 +386,13 @@
152 new_octet = (chr == '.');
154 addr = (sfaddr_t*)dst;
155 +#ifdef __sun
156 + addr->ia32[0] = addr->ia32[1] = ((uint16_t*)(addr->ia8))[4] = 0;
157 + ((uint16_t*)(addr->ia32))[5] = 0xFFFF;
158 +#else
159 addr->ia32[0] = addr->ia32[1] = addr->ia16[4] = 0;
160 addr->ia16[5] = 0xFFFF;
161 +#endif
162 dst = &addr->ia32[3];
165 @@ -419,8 +424,13 @@
167 dst->family = family;
168 if(family == AF_INET) {
169 +#ifdef __sun
170 + dst->ia32[0] = dst->ia32[1] = ((uint16_t*)(dst->ia32))[4] = 0;
171 + ((uint16_t*)(dst->ia32))[5] = 0xFFFF;
172 +#else
173 dst->ia32[0] = dst->ia32[1] = dst->ia16[4] = 0;
174 dst->ia16[5] = 0xFFFF;
175 +#endif
176 dst->ia32[3] = *(uint32_t*)src;
177 } else if(family == AF_INET6) {
178 memcpy(sfaddr_get_ip6_ptr(dst), src, 16);
179 @@ -612,16 +622,27 @@
181 /* Check the first 80 bits in an IPv6 address, and */
182 /* verify they're zero. If not, it's not a loopback */
183 +#ifdef __sun
184 + if(ip->ia32[0] || ip->ia32[1] || ((uint16_t*)(ip->ia8))[4])
185 +#else
186 if(ip->ia32[0] || ip->ia32[1] || ip->ia16[4])
187 +#endif
188 return 0;
190 +#ifdef __sun
191 + if(((uint16_t*)(ip->ia8))[5] == 0xFFFF)
192 +#else
193 if(ip->ia16[5] == 0xFFFF)
194 +#endif
196 /* ::ffff:7f00:0/104 is ipv4 compatible ipv6 */
197 return (ip->ia8[12] == 0x7f);
200 +#ifdef __sun
201 + if(!((uint16_t*)(ip->ia8))[5])
202 +#else
203 if(!ip->ia16[5])
204 +#endif
206 /* ::7f00:0/104 is ipv4 compatible ipv6 */
207 /* ::1 is the IPv6 loopback */
208 --- snort-2.9.9.0/src/decode.c.1 2017-02-01 22:26:01.531260324 +0300
209 +++ snort-2.9.9.0/src/decode.c 2017-02-01 22:30:34.379039380 +0300
210 @@ -3188,9 +3188,17 @@
212 /* Multicast addresses only specify the first 16 and last 40 bits.
213 Others should be zero. */
214 +#ifdef __sun
215 + if ((((uint16_t*)(ip_dst->s6_addr32))[1] != 0) ||
216 +#else
217 if ((ip_dst->s6_addr16[1] != 0) ||
218 +#endif
219 (ip_dst->s6_addr32[1] != 0) ||
220 +#ifdef __sun
221 + (((uint16_t*)(ip_dst->s6_addr32))[4] != 0) ||
222 +#else
223 (ip_dst->s6_addr16[4] != 0) ||
224 +#endif
225 (ip_dst->s6_addr[10] != 0))
227 DecoderEvent(p, DECODE_IPV6_DST_RESERVED_MULTICAST,
228 @@ -3201,10 +3209,18 @@
229 if (ip_dst->s6_addr[1] == IP6_MULTICAST_SCOPE_INTERFACE)
231 // Node-local scope
232 +#ifdef __sun
233 + if ((((uint16_t*)(ip_dst->s6_addr32))[1] != 0) ||
234 +#else
235 if ((ip_dst->s6_addr16[1] != 0) ||
236 +#endif
237 (ip_dst->s6_addr32[1] != 0) ||
238 (ip_dst->s6_addr32[2] != 0) ||
239 +#ifdef __sun
240 + (((uint16_t*)(ip_dst->s6_addr32))[6] != 0))
241 +#else
242 (ip_dst->s6_addr16[6] != 0))
243 +#endif
246 DecoderEvent(p, DECODE_IPV6_DST_RESERVED_MULTICAST,