Lines 184-197
Link Here
|
184 |
{ |
184 |
{ |
185 |
struct timeval last, intvl; |
185 |
struct timeval last, intvl; |
186 |
struct hostent *hp; |
186 |
struct hostent *hp; |
187 |
struct sockaddr_in *to; |
187 |
struct sockaddr_in *to, sin; |
188 |
struct termios ts; |
188 |
struct termios ts; |
189 |
register int i; |
189 |
register int i; |
190 |
int ch, hold, packlen, preload, sockerrno, almost_done = 0; |
190 |
int ch, hold, packlen, preload, sockerrno, almost_done = 0; |
191 |
struct in_addr ifaddr; |
191 |
struct in_addr ifaddr; |
192 |
unsigned char ttl, loop; |
192 |
unsigned char ttl, loop; |
193 |
u_char *datap, *packet; |
193 |
u_char *datap, *packet; |
194 |
char *target, hnamebuf[MAXHOSTNAMELEN]; |
194 |
char *source = NULL, *target, hnamebuf[MAXHOSTNAMELEN]; |
195 |
char *ep; |
195 |
char *ep; |
196 |
u_long ultmp; |
196 |
u_long ultmp; |
197 |
#ifdef IP_OPTIONS |
197 |
#ifdef IP_OPTIONS |
Lines 217-223
Link Here
|
217 |
preload = 0; |
217 |
preload = 0; |
218 |
|
218 |
|
219 |
datap = &outpack[8 + sizeof(struct timeval)]; |
219 |
datap = &outpack[8 + sizeof(struct timeval)]; |
220 |
while ((ch = getopt(argc, argv, "I:LQRT:c:adfi:l:np:qrs:v")) != -1) { |
220 |
while ((ch = getopt(argc, argv, "I:LQRS:T:c:adfi:l:np:qrs:v")) != -1) { |
221 |
switch(ch) { |
221 |
switch(ch) { |
222 |
case 'a': |
222 |
case 'a': |
223 |
options |= F_AUDIBLE; |
223 |
options |= F_AUDIBLE; |
Lines 301-306
Link Here
|
301 |
optarg); |
301 |
optarg); |
302 |
datalen = ultmp; |
302 |
datalen = ultmp; |
303 |
break; |
303 |
break; |
|
|
304 |
case 'S': |
305 |
source = optarg; |
306 |
break; |
304 |
case 'T': /* multicast TTL */ |
307 |
case 'T': /* multicast TTL */ |
305 |
ultmp = strtoul(optarg, &ep, 0); |
308 |
ultmp = strtoul(optarg, &ep, 0); |
306 |
if (*ep || ep == optarg || ultmp > 255) |
309 |
if (*ep || ep == optarg || ultmp > 255) |
Lines 322-327
Link Here
|
322 |
usage(argv[0]); |
325 |
usage(argv[0]); |
323 |
target = argv[optind]; |
326 |
target = argv[optind]; |
324 |
|
327 |
|
|
|
328 |
if (source) { |
329 |
bzero((char *)&sin, sizeof(sin)); |
330 |
sin.sin_family = AF_INET; |
331 |
if (inet_aton(source, &sin.sin_addr) == 0) { |
332 |
hp = gethostbyname2(source, AF_INET); |
333 |
if (!hp) |
334 |
errx(EX_NOHOST, "cannot resolve %s: %s", |
335 |
source, hstrerror(h_errno)); |
336 |
|
337 |
sin.sin_len = sizeof sin; |
338 |
if (hp->h_length > sizeof(sin.sin_addr)) |
339 |
errx(1,"gethostbyname2 returned an illegal address"); |
340 |
memcpy(&sin.sin_addr, hp->h_addr_list[0], sizeof sin.sin_addr); |
341 |
} |
342 |
if (bind(s, (struct sockaddr *)&sin, sizeof sin) == -1) |
343 |
err(1, "bind"); |
344 |
} |
345 |
|
325 |
bzero((char *)&whereto, sizeof(struct sockaddr)); |
346 |
bzero((char *)&whereto, sizeof(struct sockaddr)); |
326 |
to = (struct sockaddr_in *)&whereto; |
347 |
to = (struct sockaddr_in *)&whereto; |
327 |
to->sin_family = AF_INET; |
348 |
to->sin_family = AF_INET; |
Lines 1251-1256
Link Here
|
1251 |
fprintf(stderr, |
1272 |
fprintf(stderr, |
1252 |
"usage: %s [-QRadfnqrv] [-c count] [-i wait] [-l preload] " |
1273 |
"usage: %s [-QRadfnqrv] [-c count] [-i wait] [-l preload] " |
1253 |
"[-p pattern]\n [-s packetsize] " |
1274 |
"[-p pattern]\n [-s packetsize] " |
|
|
1275 |
"[-S src_addr]\n " |
1254 |
"[host | [-L] [-I iface] [-T ttl] mcast-group]\n", |
1276 |
"[host | [-L] [-I iface] [-T ttl] mcast-group]\n", |
1255 |
argv0); |
1277 |
argv0); |
1256 |
exit(EX_USAGE); |
1278 |
exit(EX_USAGE); |