From: fredrik@DOLDA2000.COM Date: Thu, 28 Apr 2005 00:51:09 +0000 (+0000) Subject: First test version. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=51a629415834385d11fe0351b2e5b518a381cdfa;p=icmp-dn.git First test version. git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/icmp-dn@209 959494ce-11ee-0310-bf91-de5d638817bd --- diff --git a/idnlookup.c b/idnlookup.c new file mode 100644 index 0000000..e2632df --- /dev/null +++ b/idnlookup.c @@ -0,0 +1,48 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct icmphdr { + u_int8_t type; + u_int8_t code; + u_int16_t checksum; + u_int16_t id; + u_int16_t seq; +}; + +#define ICMP_NAMEREQ 37 +#define ICMP_NAMEREP 38 + +int main(int argc, char **argv) +{ + int ret; + int s; + struct sockaddr_in host; + struct icmphdr data; + + if((s = socket(PF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0) { + perror("could not create raw socket"); + exit(1); + } + + host.sin_family = AF_INET; + inet_aton("192.168.1.254", &host.sin_addr); + + memset(&data, 0, sizeof(data)); + data.type = ICMP_NAMEREQ; + + ret = sendto(s, &data, sizeof(data), 0, (struct sockaddr *)&host, sizeof(host)); + if(ret < 0) { + perror("sendto"); + } else { + printf("%i\n", ret); + } + close(s); + return(0); +}