[Nagiosplug-devel] Fwd: Patch proposal for check_icmp
Patrick Cervicek
patrick.postfix at cervicek.de
Thu Dec 20 20:27:46 CET 2007
Ton Voon schrieb:
> Hi!
>
> I got this email from Harald re: check_icmp specifying a source
> address. I don't know too much about check_icmp, so can anyone else
> look over this?
I applied this patch and it works, but i have 3 questions:
> Begin forwarded message:
> +#include <netinet/in.h>
1) in.h is already included 5 lines higher. Is this #include necessary?
It compiles & works also without it.
> +static int
> +add_source_ip(char *arg)
> + if (bind(icmp_sock, (struct sockaddr *) &src, sizeof(struct sockaddr_un)) == -1) {
2) Wouldn't it better to check before, if 'icmp_sock' or 'sockets' is >0 ?
3) Is 'sizeof(struct sockaddr_UN)' good? In all other examples on the
web to networkprogramming i find only 'sizeof(struct sockaddr)' or
'sizeof(struct sockaddr_in)'.
I did a test with sizeof and get different results on my system:
> sizeof test
> sockaddr_un: 110
> sockaddr_in: 16
> sockaddr : 16
testcode:
> #include <linux/socket.h>
> #include <linux/un.h>
> #include <linux/in.h>
>
>
> void main (void) {
>
> printf("sizeof test\n"
> "sockaddr_un: %d\n"
> "sockaddr_in: %d\n"
> "sockaddr : %d\n"
> ,sizeof(struct sockaddr_un),
> sizeof(struct sockaddr_in),
> sizeof(struct sockaddr));
> }
>
Patrick
More information about the Devel
mailing list