Patch to add Type of Service to ip_link.c
[email protected] Wed, 08 Sep 2004 12:37:09 -0400
| Newsgroups | gmane.comp.security.libnet |
|---|---|
| Message-ID | <[email protected]> |
I don't know if this is the right way to get this to the Powers That Be but here's a patch against 1.1.2.1 that allows you to specify an IP TOS value on the command line of ip_link. I hope someone finds this useful.
Chris
ip_link.patch
(application/octet-stream, 1.8 KB)
--- ip_link.orig Sat Jan 3 15:31:01 2004 +++ ip_link.c Wed Sep 8 12:30:30 2004 @@ -6,6 +6,8 @@ * Copyright (c) 2003 Frédéric Raynal <[email protected]> * All rights reserved. * + * -T added by Chris Nelson <[email protected]> + * * Ex: * - send an UDP packet from port 4369 to port 8738 * ./ip -s 1.1.1.1 -d 2.2.2.2 @@ -56,10 +58,11 @@ u_short proto = IPPROTO_UDP; u_char payload[255] = {0x11, 0x11, 0x22, 0x22, 0x00, 0x08, 0xc6, 0xa5}; u_long payload_s = 8; + u_int8_t tos = 0; printf("libnet 1.1 packet shaping: IP + payload[link]\n"); - while ((c = getopt(argc, argv, "d:s:D:S:tp:i:h")) != EOF) + while ((c = getopt(argc, argv, "d:s:D:S:tp:i:T:h")) != EOF) { switch (c) { @@ -92,6 +95,18 @@ payload_s = strlen(payload); break; + case 'T': + { + unsigned int temp; + if (sscanf(optarg, "%d", &temp) != 1 + || temp > UCHAR_MAX) { + usage(argv[0]); + exit(EXIT_FAILURE); + } + tos = temp; + break; + } + case 'h': usage(argv[0]); exit(EXIT_SUCCESS); @@ -135,7 +150,7 @@ */ ip_ptag = libnet_build_ipv4( LIBNET_IPV4_H + payload_s, /* length */ - 0, /* TOS */ + tos, /* TOS */ 242, /* IP ID */ 0, /* IP Frag */ 64, /* TTL */ @@ -194,7 +209,7 @@ fprintf(stderr, "usage: %s [-s source_ip] [-d destination_ip]" " [-S HW src] [-D HW dst]" - " [-i iface] [-p payload] [-t]\n", + " [-i iface] [-p payload] [-t] [-T tos]\n", name); }