2 * Copyright (C) 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL.
10 #include "kern_constants.h"
16 static int slirp_user_init(void *data
, void *dev
)
18 struct slirp_data
*pri
= data
;
24 struct slirp_pre_exec_data
{
29 static void slirp_pre_exec(void *arg
)
31 struct slirp_pre_exec_data
*data
= arg
;
33 if (data
->stdin
!= -1)
35 if (data
->stdout
!= -1)
36 dup2(data
->stdout
, 1);
39 static int slirp_tramp(char **argv
, int fd
)
41 struct slirp_pre_exec_data pe_data
;
46 pid
= run_helper(slirp_pre_exec
, &pe_data
, argv
);
51 static int slirp_open(void *data
)
53 struct slirp_data
*pri
= data
;
56 err
= os_pipe(fds
, 1, 1);
60 err
= slirp_tramp(pri
->argw
.argv
, fds
[1]);
62 printk(UM_KERN_ERR
"slirp_tramp failed - errno = %d\n", -err
);
79 static void slirp_close(int fd
, void *data
)
81 struct slirp_data
*pri
= data
;
90 printk(UM_KERN_ERR
"slirp_close: no child process to shut "
96 if (kill(pri
->pid
, SIGHUP
)<0) {
97 printk(UM_KERN_ERR
"slirp_close: sending hangup to %d failed "
98 "(%d)\n", pri
->pid
, errno
);
101 err
= helper_wait(pri
->pid
, 1, "slirp_close");
108 int slirp_user_read(int fd
, void *buf
, int len
, struct slirp_data
*pri
)
110 return slip_proto_read(fd
, buf
, len
, &pri
->slip
);
113 int slirp_user_write(int fd
, void *buf
, int len
, struct slirp_data
*pri
)
115 return slip_proto_write(fd
, buf
, len
, &pri
->slip
);
118 const struct net_user_info slirp_user_info
= {
119 .init
= slirp_user_init
,
121 .close
= slirp_close
,
124 .delete_address
= NULL
,
126 .max_packet
= BUF_SIZE
,