char dev[sizeof("32768\0")];
};
-void *port_init(char *str, int device, struct chan_opts *opts)
+static void *port_init(char *str, int device, struct chan_opts *opts)
{
struct port_chan *data;
void *kern_data;
return(NULL);
}
-void port_free(void *d)
+static void port_free(void *d)
{
struct port_chan *data = d;
kfree(data);
}
-int port_open(int input, int output, int primary, void *d, char **dev_out)
+static int port_open(int input, int output, int primary, void *d,
+ char **dev_out)
{
struct port_chan *data = d;
int fd, err;
return(fd);
}
-void port_close(int fd, void *d)
+static void port_close(int fd, void *d)
{
struct port_chan *data = d;
os_close_file(fd);
}
-int port_console_write(int fd, const char *buf, int n, void *d)
+static int port_console_write(int fd, const char *buf, int n, void *d)
{
struct port_chan *data = d;
int port_listen_fd(int port)
{
struct sockaddr_in addr;
- int fd, err;
+ int fd, err, arg;
fd = socket(PF_INET, SOCK_STREAM, 0);
if(fd == -1)
return(-errno);
+ arg = 1;
+ if(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &arg, sizeof(arg)) < 0){
+ err = -errno;
+ goto out;
+ }
+
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
addr.sin_addr.s_addr = htonl(INADDR_ANY);