… | |
… | |
255 | icmpv4_fd = setup_socket (PROT_ICMPv4, PF_INET, SOCK_RAW, IPPROTO_ICMP); |
255 | icmpv4_fd = setup_socket (PROT_ICMPv4, PF_INET, SOCK_RAW, IPPROTO_ICMP); |
256 | |
256 | |
257 | if (icmpv4_fd < 0) |
257 | if (icmpv4_fd < 0) |
258 | return -1; |
258 | return -1; |
259 | |
259 | |
|
|
260 | // no clue where trhis is actually defined |
|
|
261 | #if !defined(ICMP_FILTER) && defined(__linux) |
|
|
262 | #define ICMP_FILTER 1 |
|
|
263 | #endif |
|
|
264 | |
260 | #ifdef ICMP_FILTER |
265 | #ifdef ICMP_FILTER |
261 | { |
266 | { |
262 | icmp_filter oval; |
267 | uint32_t oval; |
263 | oval.data = 0; |
268 | oval = 0; |
264 | if (::conf.icmp_type < 32) |
269 | if (::conf.icmp_type < 32) |
265 | oval.data |= 1 << ::conf.icmp_type; |
270 | oval |= 1 << ::conf.icmp_type; |
266 | oval.data = ~oval.data; |
271 | oval = ~oval; |
267 | |
272 | |
268 | setsockopt (icmpv4_fd, SOL_RAW, ICMP_FILTER, &oval, sizeof oval); |
273 | setsockopt (icmpv4_fd, SOL_RAW, ICMP_FILTER, &oval, sizeof oval); |
269 | } |
274 | } |
270 | #endif |
275 | #endif |
271 | |
276 | |