Fixes for manually specified network interfaces

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@9218 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 2001-02-23 10:11:32 +00:00
parent b85ec772ba
commit 2a87318eae
2 changed files with 43 additions and 9 deletions

View file

@ -1,3 +1,8 @@
2001-02-23 Richard Frith-Macdonald <rfm@gnu.org>
* Tools/gdomap.c: Fixed bug in handling '-a' option and enhanced
to support multicast probing of networks specified in '-a' file.
2001-02-22 Nicola Pero <n.pero@mi.flashnet.it>
* Headers/gnustep/base/NSBundle.h: Added three new localization

View file

@ -1137,13 +1137,13 @@ init_iface()
exit(1);
}
if (addr != 0) free(addr);
addr = (struct in_addr*)malloc(num_iface*IASIZE);
addr = (struct in_addr*)malloc((num_iface+1)*IASIZE);
if (bcok != 0) free(bcok);
bcok = (char*)malloc(num_iface*sizeof(char));
bcok = (char*)malloc((num_iface+1)*sizeof(char));
if (bcst != 0) free(bcst);
bcst = (struct in_addr*)malloc(num_iface*IASIZE);
bcst = (struct in_addr*)malloc((num_iface+1)*IASIZE);
if (mask != 0) free(mask);
mask = (struct in_addr*)malloc(num_iface*IASIZE);
mask = (struct in_addr*)malloc((num_iface+1)*IASIZE);
final = (struct ifreq*)&ifc.ifc_buf[ifc.ifc_len];
for (ifr = ifc.ifc_req; ifr < final; ifr++)
@ -1326,14 +1326,22 @@ load_iface(const char* from)
fprintf(stderr, "No address mask pairs found in file.\n");
exit(1);
}
addr = (struct in_addr*)malloc(num_iface*IASIZE);
mask = (struct in_addr*)malloc(num_iface*IASIZE);
bcok = (char*)malloc(num_iface*sizeof(char));
bcst = (struct in_addr*)malloc(num_iface*IASIZE);
num_iface++;
addr = (struct in_addr*)malloc((num_iface+1)*IASIZE);
mask = (struct in_addr*)malloc((num_iface+1)*IASIZE);
bcok = (char*)malloc((num_iface+1)*sizeof(char));
bcst = (struct in_addr*)malloc((num_iface+1)*IASIZE);
addr[interfaces].s_addr = inet_addr("127.0.0.1");
mask[interfaces].s_addr = inet_addr("255.255.255.0");
bcok[interfaces] = 0;
bcst[interfaces].s_addr = inet_addr("127.0.0.255");
interfaces++;
while (fgets(buf, sizeof(buf), fptr) != 0)
{
char *ptr = buf;
char *msk;
/*
* Strip leading white space.
@ -1376,6 +1384,15 @@ load_iface(const char* from)
}
ptr = buf;
while (*ptr && (isdigit(*ptr) || (*ptr == '.')))
{
ptr++;
}
while (isspace(*ptr))
{
*ptr++ = '\0';
}
msk = ptr;
while (*ptr && (isdigit(*ptr) || (*ptr == '.')))
{
ptr++;
@ -1385,7 +1402,17 @@ load_iface(const char* from)
*ptr++ = '\0';
}
addr[interfaces].s_addr = inet_addr(buf);
mask[interfaces].s_addr = inet_addr(ptr);
mask[interfaces].s_addr = inet_addr(msk);
if (isdigit(*ptr))
{
bcok[interfaces] = 1;
bcst[interfaces].s_addr = inet_addr(ptr);
}
else
{
bcok[interfaces] = 0;
bcst[interfaces].s_addr = inet_addr("0.0.0.0");
}
if (addr[interfaces].s_addr == -1)
{
fprintf(stderr, "'%s' is not as valid address\n", buf);
@ -3893,6 +3920,8 @@ printf(
"option. The file named with '-a' should contain a series of lines with\n"
"space separated pairs of addresses and masks in 'dot' notation.\n"
"You must NOT include loopback interfaces in this list.\n"
"If you want to support broadcasting of probe information on a network,\n"
"you may supply the broadcast address as a third item on the line.\n"
"If your operating system has some other method of giving you a list of\n"
"network interfaces and masks, please send me example code so that I can\n"
"implement it in gdomap.\n");