summaryrefslogtreecommitdiffstats
path: root/loader2
diff options
context:
space:
mode:
authorDavid Cantrell <dcantrell@redhat.com>2006-05-08 17:50:34 +0000
committerDavid Cantrell <dcantrell@redhat.com>2006-05-08 17:50:34 +0000
commitd0141ca3ad8b0fec1d75a5be7f03a269120551dc (patch)
tree2b87be6c1c4c748a6a4f91d1819c58da59a3f157 /loader2
parent98cbc5a2216027dfeb064af16a8a937c5e482fef (diff)
downloadanaconda-d0141ca3ad8b0fec1d75a5be7f03a269120551dc.tar.gz
anaconda-d0141ca3ad8b0fec1d75a5be7f03a269120551dc.tar.xz
anaconda-d0141ca3ad8b0fec1d75a5be7f03a269120551dc.zip
Not very exciting IPv6 stuff yet.
Diffstat (limited to 'loader2')
-rw-r--r--loader2/ftp.c4
-rw-r--r--loader2/net.c78
-rw-r--r--loader2/nfsinstall.c2
3 files changed, 51 insertions, 33 deletions
diff --git a/loader2/ftp.c b/loader2/ftp.c
index aae7ffd25..6efd6a2cd 100644
--- a/loader2/ftp.c
+++ b/loader2/ftp.c
@@ -210,7 +210,7 @@ int ftpCommand(int sock, char * command, ...) {
static int getHostAddress(const char * host, struct in_addr * address) {
if (isdigit(host[0])) {
- if (!inet_aton(host, address)) {
+ if (!inet_pton(AF_INET, host, address)) {
return FTPERR_BAD_HOST_ADDR;
}
} else {
@@ -346,7 +346,7 @@ int ftpGetFileDesc(int sock, char * remotename) {
if (*chptr == ',') *chptr = '.';
}
- if (!inet_aton(passReply, &dataAddress.sin_addr))
+ if (!inet_pton(AF_INET, passReply, &dataAddress.sin_addr))
return FTPERR_PASSIVE_ERROR;
dataSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
diff --git a/loader2/net.c b/loader2/net.c
index 5a4d12e81..e3876e7fd 100644
--- a/loader2/net.c
+++ b/loader2/net.c
@@ -19,6 +19,8 @@
*
*/
+#include <sys/types.h>
+#include <sys/socket.h>
#include <arpa/inet.h>
#include <errno.h>
#include <popt.h>
@@ -62,34 +64,50 @@ static int setupWireless(struct networkDeviceConfig *dev);
static void ipCallback(newtComponent co, void * dptr) {
struct intfconfig_s * data = dptr;
- struct in_addr ipaddr, nmaddr, addr;
+ struct in_addr ipaddr, nmaddr, addr, naddr;
char * ascii;
int broadcast, network;
+ int af = AF_INET; /* accept as a parameter */
if (co == data->ipEntry) {
if (strlen(data->ip) && !strlen(data->nm)) {
- if (inet_aton(data->ip, &ipaddr)) {
+ if (inet_pton(af, data->ip, &ipaddr)) {
ipaddr.s_addr = ntohl(ipaddr.s_addr);
- ascii = "255.255.255.0";
- newtEntrySet(data->nmEntry, ascii, 1);
+ switch (af) {
+ case AF_INET:
+ ascii = "255.255.255.0";
+ /* does this line need to be for each case? */
+ newtEntrySet(data->nmEntry, ascii, 1);
+ break;
+ case AF_INET6:
+ /* FIXME: writeme */
+ break;
+ }
}
}
} else if (co == data->nmEntry) {
if (!strlen(data->ip) || !strlen(data->nm)) return;
- if (!inet_aton(data->ip, &ipaddr)) return;
- if (!inet_aton(data->nm, &nmaddr)) return;
-
- network = ipaddr.s_addr & nmaddr.s_addr;
- broadcast = (ipaddr.s_addr & nmaddr.s_addr) | (~nmaddr.s_addr);
-
- if (!strlen(data->gw)) {
- addr.s_addr = htonl(ntohl(broadcast) - 1);
- newtEntrySet(data->gwEntry, inet_ntoa(addr), 1);
- }
+ if (!inet_pton(af, data->ip, &ipaddr)) return;
+ if (!inet_pton(af, data->nm, &nmaddr)) return;
+
+ if (af == AF_INET) {
+ network = ipaddr.s_addr & nmaddr.s_addr;
+ broadcast = (ipaddr.s_addr & nmaddr.s_addr) | (~nmaddr.s_addr) ;
+
+ if (!strlen(data->gw)) {
+ char gw[INET_ADDRSTRLEN];
+ addr.s_addr = htonl(ntohl(broadcast) - 1);
+ inet_ntop(af, &addr, gw, sizeof(gw));
+ newtEntrySet(data->gwEntry, gw, 1);
+ }
- if (!strlen(data->ns)) {
- addr.s_addr = htonl(ntohl(network) + 1);
- newtEntrySet(data->nsEntry, inet_ntoa(addr), 1);
+ if (!strlen(data->ns)) {
+ char ns[INET_ADDRSTRLEN];
+ naddr.s_addr = network;
+ naddr.s_addr |= htonl(1);
+ inet_ntop(af, &naddr, ns, sizeof(ns));
+ newtEntrySet(data->nsEntry, ns, 1);
+ }
}
}
}
@@ -103,7 +121,7 @@ static void fillInIpInfo(struct networkDeviceConfig * cfg) {
nm = "255.255.255.0";
- inet_aton(nm, &cfg->dev.netmask);
+ inet_pton(AF_INET, nm, &cfg->dev.netmask);
cfg->dev.set |= PUMP_INTFINFO_HAS_NETMASK;
}
@@ -186,9 +204,9 @@ void initLoopback(void) {
struct pumpNetIntf dev;
strcpy(dev.device, "lo");
- inet_aton("127.0.0.1", &dev.ip);
- inet_aton("255.0.0.0", &dev.netmask);
- inet_aton("127.0.0.0", &dev.network);
+ inet_pton(AF_INET, "127.0.0.1", &dev.ip);
+ inet_pton(AF_INET, "255.0.0.0", &dev.netmask);
+ inet_pton(AF_INET, "127.0.0.0", &dev.network);
dev.set = PUMP_INTFINFO_HAS_NETMASK | PUMP_INTFINFO_HAS_IP
| PUMP_INTFINFO_HAS_NETWORK;
@@ -272,7 +290,7 @@ static int getDnsServers(struct networkDeviceConfig * cfg) {
if (rc == 2) return LOADER_BACK;
- if (ns && *ns && !inet_aton(ns, &cfg->dev.dnsServers[0])) {
+ if (ns && *ns && !inet_pton(AF_INET, ns, &cfg->dev.dnsServers[0])) {
newtWinMessage(_("Invalid IP Information"), _("Retry"),
_("You entered an invalid IP address."));
rc = 2;
@@ -368,7 +386,7 @@ void setupNetworkDeviceConfig(struct networkDeviceConfig * cfg,
cfg->isDynamic = 1;
cfg->preset = 1;
- } else if (inet_aton(loaderData->ip, &addr)) {
+ } else if (inet_pton(AF_INET, loaderData->ip, &addr)) {
cfg->dev.ip = addr;
cfg->dev.set |= PUMP_INTFINFO_HAS_IP;
cfg->isDynamic = 0;
@@ -379,12 +397,12 @@ void setupNetworkDeviceConfig(struct networkDeviceConfig * cfg,
}
}
- if (loaderData->netmask && (inet_aton(loaderData->netmask, &addr))) {
+ if (loaderData->netmask && (inet_pton(AF_INET, loaderData->netmask, &addr))) {
cfg->dev.netmask = addr;
cfg->dev.set |= PUMP_INTFINFO_HAS_NETMASK;
}
- if (loaderData->gateway && (inet_aton(loaderData->gateway, &addr))) {
+ if (loaderData->gateway && (inet_pton(AF_INET, loaderData->gateway, &addr))) {
cfg->dev.gateway = addr;
cfg->dev.set |= PUMP_NETINFO_HAS_GATEWAY;
}
@@ -396,7 +414,7 @@ void setupNetworkDeviceConfig(struct networkDeviceConfig * cfg,
/* Scan the dns parameter for multiple comma-separated IP addresses */
c = strtok(buf, ",");
while ((cfg->dev.numDns < MAX_DNS_SERVERS) && (c != NULL) &&
- (inet_aton(c,&addr))) {
+ (inet_pton(AF_INET, c, &addr))) {
cfg->dev.dnsServers[cfg->dev.numDns] = addr;
cfg->dev.numDns++;
logMessage(DEBUGLVL, "adding %s", inet_ntoa(addr));
@@ -573,19 +591,19 @@ int readNetConfig(char * device, struct networkDeviceConfig * cfg,
if (dhcpChoice == ' ') {
i = 0;
memset(&newCfg, 0, sizeof(newCfg));
- if (*c.ip && inet_aton(c.ip, &addr)) {
+ if (*c.ip && inet_pton(AF_INET, c.ip, &addr)) {
i++;
newCfg.dev.ip = addr;
newCfg.dev.set |= PUMP_INTFINFO_HAS_IP;
}
- if (*c.nm && inet_aton(c.nm, &addr)) {
+ if (*c.nm && inet_pton(AF_INET, c.nm, &addr)) {
i++;
newCfg.dev.netmask = addr;
newCfg.dev.set |= PUMP_INTFINFO_HAS_NETMASK;
}
- if (c.ns && *c.ns && inet_aton(c.ns, &addr)) {
+ if (c.ns && *c.ns && inet_pton(AF_INET, c.ns, &addr)) {
cfg->dev.dnsServers[0] = addr;
if (cfg->dev.numDns < 1)
cfg->dev.numDns = 1;
@@ -641,7 +659,7 @@ int readNetConfig(char * device, struct networkDeviceConfig * cfg,
fillInIpInfo(cfg);
if (!(cfg->dev.set & PUMP_NETINFO_HAS_GATEWAY)) {
- if (c.gw && *c.gw && inet_aton(c.gw, &addr)) {
+ if (c.gw && *c.gw && inet_pton(AF_INET, c.gw, &addr)) {
cfg->dev.gateway = addr;
cfg->dev.set |= PUMP_NETINFO_HAS_GATEWAY;
}
diff --git a/loader2/nfsinstall.c b/loader2/nfsinstall.c
index 5d8644470..10904c2d5 100644
--- a/loader2/nfsinstall.c
+++ b/loader2/nfsinstall.c
@@ -123,7 +123,7 @@ char * mountNfsImage(struct installMethod * method,
char * buf;
struct in_addr ip;
- if (loaderData->noDns && !(inet_aton(host, &ip))) {
+ if (loaderData->noDns && !(inet_pton(AF_INET, host, &ip))) {
newtWinMessage(_("Error"), _("OK"),
_("Hostname specified with no DNS configured"));
if (loaderData->method) {