2
* author: Darren Bounds <dbounds@intrusense.com>
3
* copyright: Copyright (C) 2002 by Darren Bounds
4
* license: This software is under GPL version 2 of license
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
* 4g8 official page at http://.net
26
udp_hdr(u_int8_t *packet, u_int16_t diff)
28
struct libnet_udp_hdr *udphdr;
31
fprintf(stdout, "DEBUG: udp_hdr()\n");
34
udphdr = (struct libnet_udp_hdr *)(packet + IPV4_H + hdr_len);
36
fprintf(stdout, "UDP header: Src Port: %d Dst Port: %d Len: %d ",
37
htons(udphdr->uh_sport),
38
htons(udphdr->uh_dport),
39
ntohs(udphdr->uh_ulen));
41
fprintf(stdout, "\n");
43
payload_len = ntohs(udphdr->uh_ulen) - 8;
46
htons(udphdr->uh_sport),
47
htons(udphdr->uh_dport),
48
ntohs(udphdr->uh_ulen),
50
(payload_len == 0) ? NULL : packet + hdr_len + IPV4_H + 8,
55
fatal_error("Unable to build UDP header: %s", libnet_geterror(pkt_d));