Looking for a piece of code which sets IP level options
Katy T. Kislitzin
ktk at nas.nasa.gov
Tue Apr 30 11:07:53 AEST 1991
Hello--
I would like to see an example of a piece of code which constructs the
options field in the IP header. I was under the impression that
traceroute had a "source route" option, but the version that I have
does not have such an option, nor does it seem to contain an example
of what I seek. The version I have is from ftp.ee.lbl.gov:
#ifndef lint
static char *rcsid =
"@(#)$Header: traceroute.c,v 1.17 89/02/28 21:01:13 van Exp $ (LBL)";
#endif
My understanding is that you do something like the following:
char buf[OPTLEN + FUDGE];
int s;
if ( (s = socket(AF_INET, SOCK_RAW, proto) ) < 0 ){
perror("socket");
exit(1);
}
construct_options(buf);
setsockopt(s, IPPROTO_IP, IP_OPTIONS, buf, sizeof(buf) );
What I am wondering is:
a) is the above the basic idea?
b) what do I put in buf?
For concreteness, suppose I want to set a two hop loose source
route with myself as 1.1.1.1, the next hop as 2.2.2.2 and the
destination as 3.3.3.3. I would infer that buf must contain the
following:
type len pointer route
131 16 4 1.1.1.1 2.2.2.2 3.3.3.3
Is that correct?
Finally, does anyone know if IP_OPTIONS is supported under UNICOS 6.0?
The man pages have not proven illuminating.
Thanks in advance,
--kt
PS I am not really sure what group this belongs in. It's a unix
question, not a tcp/ip question, so not comp.protocols.tcp-ip, but not
comp.unix.internals since I don't want to get inside the kernel, but
last time I posted this sort of question to comp.unix.programmers it
was like spitting in the wind.
--
Katy Kislitzin, ktk at nas.nasa.gov, ...!{ames, uunet}!nas.nasa.gov!ktk
[Moffett Field is in Mt. View California. I live in the Santa Cruz
Mtns, approx 37deg08'N, 121deg59'W, 550m ]
More information about the Comp.unix.wizards
mailing list