Graphics Programs Reference
In-Depth Information
data structures for the packet header information. The nemesis_arp() function
shown below is called in nemesis.c to build and inject an ARP packet.
From nemesis-arp.c
static ETHERhdr etherhdr;
static ARPhdr arphdr;
...
void nemesis_arp(int argc, char **argv)
{
const char *module= "ARP/RARP Packet Injection";
nemesis_maketitle(title, module, version);
if (argc > 1 && !strncmp(argv[1], "help", 4))
arp_usage(argv[0]);
arp_initdata();
arp_cmdline(argc, argv);
arp_validatedata();
arp_verbose();
if (got_payload)
{
if (builddatafromfile(ARPBUFFSIZE, &pd, (const char *)file,
(const u_int32_t)PAYLOADMODE) < 0)
arp_exit(1);
}
if (buildarp(&etherhdr, &arphdr, &pd, device, reply) < 0)
{
printf("\n%s Injection Failure\n", (rarp == 0 ? "ARP" : "RARP"));
arp_exit(1);
}
else
{
printf("\n%s Packet Injected\n", (rarp == 0 ? "ARP" : "RARP"));
arp_exit(0);
}
}
The structures ETHERhdr and ARPhdr are defined in the file nemesis.h (shown
below) as aliases for existing libnet data structures. In C, typedef is used to alias
a data type with a symbol.
From nemesis.h
typedef struct libnet_arp_hdr ARPhdr;
typedef struct libnet_as_lsa_hdr ASLSAhdr;
typedef struct libnet_auth_hdr AUTHhdr;
typedef struct libnet_dbd_hdr DBDhdr;
Search WWH ::




Custom Search