[ale] Help on eth0 config.
Joe Steele
joe at madewell.com
Tue Dec 18 20:28:43 EST 2001
Are you sure you are wanting to set SIOCSIFDSTADDR,
and not SIOCSIFADDR instead?
I think SIOCSIFDSTADDR may be setting the destination
address of PPP interfaces.
--Joe
-----Original Message-----
From: Chris Fowler [SMTP:cfowler at outpostsentinel.com]
Sent: Tuesday, December 18, 2001 1:36 PM
To: ale at ale.org
Subject: [ale] Help on eth0 config.
My understanding on these things are bleak. I'm having a problem with this section of code. When I set the destination address, I get
can bind address. ip2sip is a function that converts my 32bit stored number to a string of "A.B.C.D" My problem could be in INET_Resolv.
void
do_net(void)
{
struct ifreq ifr;
struct sockaddr_in sa;
struct sockaddr sa2;
char host[128];
int sockfd;
/* Create a channel to the NET kernel. */
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
err_quit("create socket");
bzero(&ifr, sizeof(struct ifreq));
strcpy(ifr.ifr_name, INTERFACE);
ifr.ifr_flags |= (IFF_UP | IFF_RUNNING);
if (ioctl(sockfd, SIOCSIFFLAGS, &ifr) == -1)
perror("SIOCSIFFLAGS");
/* Destination */
INET_resolve((char *)ip2sip(cfg.ip), &sa);
memcpy((char *)&ifr.ifr_dstaddr, (char *)&sa, SOCKSIZE);
if(ioctl(sockfd, SIOCSIFDSTADDR, &ifr) == -1)
err_quit("SIOCSIFDSTADDR");
/* Netmask */
INET_resolve((char *)ip2sip(cfg.nm), &sa);
memcpy((char *)&ifr.ifr_netmask, (char *)&sa, SOCKSIZE);
if(ioctl(sockfd, SIOCSIFNETMASK, &ifr) == -1)
err_quit("SIOCSIFNETMASK");
/* Set broadcast address */
INET_resolve((char *)ip2sip(cfg.br), &sa);
memcpy((char *)&ifr.ifr_broadaddr, (char *)&sa, SOCKSIZE);
if(ioctl(sockfd,SIOCSIFBRDADDR, &ifr) == -1)
err_quit("SIOCSIFBRDADDR");
/* Network should be functionla
* We need to set the system hostmane!
*/
set_host_name();
return;
}
void
INET_resolve(char *host, struct sockaddr_in *sin)
{
sin->sin_family = AF_INET;
sin->sin_port = 0;
// Convert "A.B.C.D to network address.
inet_aton(host, &sin->sin_addr);
return;
}
---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be
sent to listmaster at ale dot org.
---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be
sent to listmaster at ale dot org.
More information about the Ale
mailing list