Changeset View
Changeset View
Standalone View
Standalone View
head/stand/common/dev_net.c
Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | |||||
* This opens the low-level device and sets f->f_devdata. | * This opens the low-level device and sets f->f_devdata. | ||||
* This is declared with variable arguments... | * This is declared with variable arguments... | ||||
*/ | */ | ||||
static int | static int | ||||
net_open(struct open_file *f, ...) | net_open(struct open_file *f, ...) | ||||
{ | { | ||||
struct iodesc *d; | struct iodesc *d; | ||||
va_list args; | va_list args; | ||||
char *devname; /* Device part of file name (or NULL). */ | struct devdesc *dev; | ||||
const char *devname; /* Device part of file name (or NULL). */ | |||||
int error = 0; | int error = 0; | ||||
va_start(args, f); | va_start(args, f); | ||||
devname = va_arg(args, char*); | dev = va_arg(args, struct devdesc *); | ||||
va_end(args); | va_end(args); | ||||
devname = dev->d_dev->dv_name; | |||||
/* Before opening another interface, close the previous one first. */ | /* Before opening another interface, close the previous one first. */ | ||||
if (netdev_sock >= 0 && strcmp(devname, netdev_name) != 0) | if (netdev_sock >= 0 && strcmp(devname, netdev_name) != 0) | ||||
net_cleanup(); | net_cleanup(); | ||||
/* On first open, do netif open, mount, etc. */ | /* On first open, do netif open, mount, etc. */ | ||||
if (netdev_opens == 0) { | if (netdev_opens == 0) { | ||||
/* Find network interface. */ | /* Find network interface. */ | ||||
if (netdev_sock < 0) { | if (netdev_sock < 0) { | ||||
netdev_sock = netif_open(devname); | netdev_sock = netif_open(dev); | ||||
if (netdev_sock < 0) { | if (netdev_sock < 0) { | ||||
printf("net_open: netif_open() failed\n"); | printf("net_open: netif_open() failed\n"); | ||||
return (ENXIO); | return (ENXIO); | ||||
} | } | ||||
netdev_name = strdup(devname); | netdev_name = strdup(devname); | ||||
#ifdef NETIF_DEBUG | #ifdef NETIF_DEBUG | ||||
if (debug) | if (debug) | ||||
printf("net_open: netif_open() succeeded\n"); | printf("net_open: netif_open() succeeded\n"); | ||||
▲ Show 20 Lines • Show All 287 Lines • Show Last 20 Lines |