Ethical Hacking Learn to find vulnerabilities before the bad guys do! Gain real world hands on hacking experience in our state of the art hacking lab. Course designed and taught by expert instructors with years of penetration testing experience. 12 student maximum in every class. Certification attempt included in every package. | Computer Forensics Training at InfoSec Institute Gain the in-demand skills of a certified computer examiner, learn to recover trace data left behind by fraud, theft, and cybercrime perpetrators. Discover the source of computer crime and abuse at your organization so that it never happens again. All of our class sizes are guaranteed to be 12 students or less to facilitate one-on-one interaction with one of our expert instructors. |

| Subject: | Message too long |
|---|---|
| Date: | Sat, 16 Apr 2005 00:10:37 -0600 |
This should be a relatively simple problem, but it is beyond me. I'm trying
to write 1243 bytes to the wire (which should fit in an ethernet frame), but
am getting "Message too long".
This function (below) is getting called, and it is printing:
1243
ERROR (libnet_context.cxx,249,0x8104fa0): Write error: libnet_write_link():
only -1 bytes written (Message too long)
Here is the function:
// Send a Base packet
bool LibnetContext::send(BasePacket& base_packet)
{
libnet_ptag_t ip_tag = LIBNET_PTAG_INITIALIZER,
ethernet_tag = LIBNET_PTAG_INITIALIZER,
udp_tag = LIBNET_PTAG_INITIALIZER;
const string contents=base_packet.serialize_contents();
const int length=contents.length();
cout << (LIBNET_IPV4_H + LIBNET_UDP_H + length) << endl;
//Build the udp header
udp_tag = libnet_build_udp(
base_packet.src_port.value(),
base_packet.dest_port.value(),
LIBNET_UDP_H,
0,
(u_int8_t*)contents.data(), //payload
length, //payload size
l, //libnet handle
udp_tag); //libnet id
if (udp_tag == -1)
{
ERROR << "Can't build UDP header: " << libnet_geterror(l) << "\n";
return false;
}
//Build the ipv4 header
ip_tag = libnet_build_ipv4(
LIBNET_IPV4_H + LIBNET_UDP_H + length, //length
0, //TOS
0, //IP ID
0, //IP Frag
64, //TTL
IPPROTO_UDP, //Protocol
0, //checksum
base_packet.src_ip.get_inaddr(), //source IP
base_packet.dest_ip.get_inaddr(), //destination IP
NULL, //payload
0, //payload size
l, //libnet handle
ip_tag); //libnet id
if (ip_tag == -1)
{
ERROR << "Can't build IP header: " << libnet_geterror(l) << "\n";
return false;
}
//Build the ethernet header
ethernet_tag = libnet_build_ethernet(
base_packet.dest_mac.get_array(),
base_packet.src_mac.get_array(),
ETHERTYPE_IP,
NULL,
0,
l,
ethernet_tag);
if (ethernet_tag == -1)
{
ERROR << "Can't build ethernet header: " << libnet_geterror(l) <<
"\n";
return false;
}
const int c = libnet_write(l);
if (c==-1)
{
ERROR << "Write error: " << libnet_geterror(l) << "\n";
return false;
}
return true;
}
ERROR is a macro that prints the header on the error message; line 249 is the
line that says "Write error...".
For anyone who can offer any help, I'd be greatly appreciative. :)
- Karen
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: Any way to automatically change arbitrary headers of IP packets on-the-fly?, G P |
|---|---|
| Next by Date: | Re: Ethernet Trailers, Mike Schiffman |
| Previous by Thread: | Any way to automatically change arbitrary headers of IP packets on-the-fly?, João Paulo Caldas Campello |
| Next by Thread: | How can I add ieee 802.11b support to libnet?, Liang Yang |
| Indexes: | [Date] [Thread] [Top] [All Lists] |