add a -b option to allow sending to broadcast addresses

This commit is contained in:
Mike Frysinger 2018-01-11 03:38:27 +00:00
parent 5236e1513f
commit 3c58093fdc
1 changed files with 12 additions and 1 deletions

View File

@ -169,6 +169,7 @@ unsigned char * stage = NULL; /* hexdump line buffer */
/* global cmd flags: */
USHORT o_alla = 0;
USHORT o_allowbroad = 0;
unsigned int o_interval = 0;
USHORT o_listen = 0;
USHORT o_nflag = 0;
@ -663,6 +664,13 @@ newskt:
rr = setsockopt (nnetfd, SOL_SOCKET, SO_REUSEADDR, &x, sizeof (x));
if (rr == -1)
holler ("nnetfd reuseaddr failed"); /* ??? */
#ifdef SO_BROADCAST
if (o_allowbroad) {
rr = setsockopt (nnetfd, SOL_SOCKET, SO_BROADCAST, &x, sizeof (x));
if (rr == -1)
holler ("nnetfd reuseaddr failed"); /* ??? */
}
#endif
#ifdef SO_REUSEPORT /* doesnt exist everywhere... */
rr = setsockopt (nnetfd, SOL_SOCKET, SO_REUSEPORT, &x, sizeof (x));
if (rr == -1)
@ -1356,6 +1364,7 @@ options:");
-e filename program to exec after connect [dangerous!!]");
#endif
holler ("\
-b allow broadcasts\n\
-g gateway source-routing hop point[s], up to 8\n\
-G num source-routing pointer: 4, 8, 12, ...\n\
-h this cruft\n\
@ -1480,12 +1489,14 @@ main (argc, argv)
/* If your shitbox doesn't have getopt, step into the nineties already. */
/* optarg, optind = next-argv-component [i.e. flag arg]; optopt = last-char */
while ((x = getopt (argc, argv, "ac:e:g:G:hi:lno:p:rs:tuvw:z")) != EOF) {
while ((x = getopt (argc, argv, "abc:e:g:G:hi:lno:p:rs:tuvw:z")) != EOF) {
/* Debug (("in go: x now %c, optarg %x optind %d", x, optarg, optind)) */
switch (x) {
case 'a':
bail ("all-A-records NIY");
o_alla++; break;
case 'b':
o_allowbroad++; break;
#ifdef GAPING_SECURITY_HOLE
case 'c': /* shell commands to exec */
pr00gie = optarg;