13 #include <sys/socket.h>
20 #define MAX_PACKET ETH_MAX_PACKET
22 static int etap_user_init(
void *
data,
void *
dev)
36 static void etap_change(
int op,
unsigned char *
addr,
unsigned char *netmask,
47 if (n !=
sizeof(change)) {
53 output =
uml_kmalloc(UM_KERN_PAGE_SIZE, UM_GFP_KERNEL);
64 static void etap_open_addr(
unsigned char *addr,
unsigned char *netmask,
67 etap_change(
ADD_ADDR, addr, netmask, *((
int *) arg));
70 static void etap_close_addr(
unsigned char *addr,
unsigned char *netmask,
73 etap_change(
DEL_ADDR, addr, netmask, *((
int *) arg));
82 static void etap_pre_exec(
void *arg)
96 char version_buf[
sizeof(
"nnnnn\0")];
97 char data_fd_buf[
sizeof(
"nnnnnn\0")];
98 char gate_buf[
sizeof(
"nnn.nnn.nnn.nnn\0")];
99 char *setup_args[] = {
"uml_net", version_buf,
"ethertap",
dev,
100 data_fd_buf, gate_buf,
NULL };
101 char *nosetup_args[] = {
"uml_net", version_buf,
"ethertap",
105 sprintf(data_fd_buf,
"%d", data_remote);
111 else args = nosetup_args;
117 pid =
run_helper(etap_pre_exec, &pe_data, args);
122 close(control_remote);
124 if (n !=
sizeof(c)) {
137 static int etap_open(
void *
data)
141 int data_fds[2], control_fds[2],
err, output_len;
151 "err = %d\n", errno);
159 "err = %d\n", errno);
164 control_fds[1], data_fds[0], data_fds[1]);
165 output_len = UM_KERN_PAGE_SIZE;
179 goto out_close_control;
188 close(control_fds[0]);
189 close(control_fds[1]);
196 static void etap_close(
int fd,
void *data)
205 "errno = %d\n", errno);
209 "failed, errno = %d\n", errno);
217 static void etap_add_addr(
unsigned char *addr,
unsigned char *netmask,
225 etap_open_addr(addr, netmask, &pri->
control_fd);
228 static void etap_del_addr(
unsigned char *addr,
unsigned char *netmask,
236 etap_close_addr(addr, netmask, &pri->
control_fd);
240 .init = etap_user_init,
244 .add_address = etap_add_addr,
245 .delete_address = etap_del_addr,