Combined the interface set into the datalink_init for all the datalink layers. Changed all the demo programs to use datalink_init instead of specific datalink functions.

This commit is contained in:
skarg
2007-05-25 01:08:42 +00:00
parent 076ee5f3ca
commit 8026dc003b
29 changed files with 123 additions and 295 deletions
+4 -1
View File
@@ -178,7 +178,10 @@ static int arcnet_bind(char *interface_name)
bool arcnet_init(char *interface_name)
{
ARCNET_Sock_FD = arcnet_bind(interface_name);
if (interface_name)
ARCNET_Sock_FD = arcnet_bind(interface_name);
else
ARCNET_Sock_FD = arcnet_bind("arc0");
return arcnet_valid();
}
+6 -2
View File
@@ -71,7 +71,9 @@ static int get_local_address_ioctl(char *ifname,
return rv;
}
void bip_set_interface(char *ifname)
/* on Linux, ifname is eth0, ath0, arc0, and others. */
static void bip_set_interface(char *ifname)
{
struct in_addr local_address;
struct in_addr broadcast_address;
@@ -91,13 +93,15 @@ void bip_set_interface(char *ifname)
#endif
}
bool bip_init(void)
bool bip_init(char *ifname)
{
int status = 0; /* return from socket lib calls */
struct sockaddr_in sin;
int sockopt = 0;
int sock_fd = -1;
if (ifname)
bip_set_interface(ifname);
/* assumes that the driver has already been initialized */
sock_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
bip_set_socket(sock_fd);
+7 -2
View File
@@ -170,8 +170,13 @@ static int get_local_hwaddr(const char *ifname, unsigned char *mac)
bool ethernet_init(char *interface_name)
{
get_local_hwaddr(interface_name, Ethernet_MAC_Address);
eth802_sockfd = ethernet_bind(&eth_addr, interface_name);
if (interface_name) {
get_local_hwaddr(interface_name, Ethernet_MAC_Address);
eth802_sockfd = ethernet_bind(&eth_addr, interface_name);
} else {
get_local_hwaddr("eth0", Ethernet_MAC_Address);
eth802_sockfd = ethernet_bind(&eth_addr, "eth0");
}
return ethernet_valid();
}