Re: hello; first impressions

Karl Lehenbauer (karl@sugar.NeoSoft.COM)
Mon, 4 Oct 1993 21:09:47 -0500 (CDT)

I think I have determined why many people can't get IP discovery to work.

On many systems setsockopt has to be called to set some socket options
to get ntping to work right.

Here is an experimental patch that will fix it on systems on which the
defines are available. This is based on some study of traceroute.

It runs on BSDI BSD/386 now, mostly, and can do IP route discovery and the
like.

Oh, unless I set the default packet size down to 44 or so in scotty's icmp.c,
I get a "message too large" error when trying to trace a route, too...

*** ntping.c.save Mon Oct 4 21:04:28 1993
--- ntping.c Mon Oct 4 21:05:31 1993
***************
*** 778,784 ****
ip->ip_dst = sto->sin_addr; /* needed for linux (no bind) */

udph->uh_sport = htons (job->id);
! udph->uh_dport = htons (job->port);
udph->uh_ulen = htons ((u_short) (data_len - sizeof (struct ip)));
udph->uh_sum = 0;

--- 778,784 ----
ip->ip_dst = sto->sin_addr; /* needed for linux (no bind) */

udph->uh_sport = htons (job->id);
! udph->uh_dport = htons (job->port + job->cur_seq); /* karl +job_no */
udph->uh_ulen = htons ((u_short) (data_len - sizeof (struct ip)));
udph->uh_sum = 0;

***************
*** 795,800 ****
--- 795,801 ----
for (i = sizeof (struct timeval) + 2, j = 'A'; i < data_len; i++, j++)
datap [i] = j;

+ /* fprintf(stderr, "data_len %d\n", data_len); /* karl */
i = sendto (ipsock, (char *) outpack, data_len, 0,
(struct sockaddr *) sto, sizeof (struct sockaddr_in));

***************
*** 1408,1413 ****
--- 1409,1415 ----

while (tmp == fgets (tmp, sizeof (tmp), stdin))
{
+ /* fprintf(stderr,"got '%s'\n", tmp); /* karl */
tmp [102400-1] = 0;

ptr = scan_options (tmp);
***************
*** 1439,1444 ****
--- 1441,1447 ----
{
struct protoent *proto;
struct sockaddr_in maddr;
+ int on = 1; /* karl */

if ((proto = getprotobyname ("icmp")) == NULL)
{
***************
*** 1456,1461 ****
--- 1459,1480 ----
perror ("ntping: cannot get ip socket; reason");
return 0;
}
+
+ #ifdef SO_SNDBUF
+ if (setsockopt(ipsock, SOL_SOCKET, SO_SNDBUF, (char *)&data_len,
+ sizeof(data_len)) < 0) {
+ perror("traceroute: SO_SNDBUF");
+ exit(6);
+ }
+ #endif
+
+ #ifdef IP_HDRINCL
+ if (setsockopt(ipsock, IPPROTO_IP, IP_HDRINCL, (char *)&on,
+ sizeof(on)) < 0) {
+ perror("traceroute: IP_HDRINCL");
+ exit(6);
+ }
+ #endif

bzero ((char *) &maddr, sizeof (maddr));
maddr.sin_family = AF_INET;