/*** * Create a new Traceroute Option * @function new_traceroute * @tparam string orig_ip the original IP * @treturn IPOption */ int l_ipoption_ref::l_IP_Traceroute(lua_State *l) { IPOptionTraceroute *opt; const char *src = luaL_checkstring(l, 1); opt = l_ipoption_ref::new_option_ref<IPOptionTraceroute>(l); if (!opt) return 0; opt->SetIDNumber(rand() % USHRT_MAX); opt->SetOrigIP(src); return 1; }
int main() { /* Init the library */ InitCrafter(); /* Set the interface */ string iface = "wlan0"; /* Get the IP address associated to the interface */ string MyIP = GetMyIP(iface); /* Create an IP header */ IP ip_header; /* Set the Source and Destination IP address */ ip_header.SetSourceIP(MyIP); ip_header.SetDestinationIP("192.168.0.1"); IPOptionTraceroute trace; trace.SetIDNumber(RNG16()); trace.SetOrigIP(MyIP); /* Create an ICMP header */ ICMP icmp_header; icmp_header.SetType(ICMP::EchoRequest); icmp_header.SetIdentifier(RNG16()); /* Create a payload */ RawLayer raw_header; raw_header.SetPayload("HelloPing!\n"); /* Create a packet... */ Packet packet = ip_header / trace / icmp_header / raw_header; /* Send the packet, this would fill the missing fields (like checksum, lengths, etc) */ packet.Send(iface); /* Clean before exit */ CleanCrafter(); return 0; }