Blame view
arch/um/drivers/pcap_kern.c
2.53 KB
1da177e4c Linux-2.6.12-rc2 |
1 |
/* |
cd1ae0e49 uml: network form... |
2 |
* Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
1da177e4c Linux-2.6.12-rc2 |
3 4 5 6 |
* Licensed under the GPL. */ #include "linux/init.h" |
cd1ae0e49 uml: network form... |
7 |
#include <linux/netdevice.h> |
1da177e4c Linux-2.6.12-rc2 |
8 |
#include "net_kern.h" |
1da177e4c Linux-2.6.12-rc2 |
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#include "pcap_user.h" struct pcap_init { char *host_if; int promisc; int optimize; char *filter; }; void pcap_init(struct net_device *dev, void *data) { struct uml_net_private *pri; struct pcap_data *ppri; struct pcap_init *init = data; |
17c324fa8 um: Kill directly... |
23 |
pri = netdev_priv(dev); |
1da177e4c Linux-2.6.12-rc2 |
24 25 26 27 28 |
ppri = (struct pcap_data *) pri->user; ppri->host_if = init->host_if; ppri->promisc = init->promisc; ppri->optimize = init->optimize; ppri->filter = init->filter; |
7d98230a7 uml: network and ... |
29 30 31 |
printk("pcap backend, host interface %s ", ppri->host_if); |
1da177e4c Linux-2.6.12-rc2 |
32 |
} |
b53f35a80 uml: network driv... |
33 |
static int pcap_read(int fd, struct sk_buff *skb, struct uml_net_private *lp) |
1da177e4c Linux-2.6.12-rc2 |
34 |
{ |
b53f35a80 uml: network driv... |
35 36 |
return pcap_user_read(fd, skb_mac_header(skb), skb->dev->mtu + ETH_HEADER_OTHER, |
7d98230a7 uml: network and ... |
37 |
(struct pcap_data *) &lp->user); |
1da177e4c Linux-2.6.12-rc2 |
38 |
} |
b53f35a80 uml: network driv... |
39 |
static int pcap_write(int fd, struct sk_buff *skb, struct uml_net_private *lp) |
1da177e4c Linux-2.6.12-rc2 |
40 |
{ |
7d98230a7 uml: network and ... |
41 |
return -EPERM; |
1da177e4c Linux-2.6.12-rc2 |
42 |
} |
5e7672ec3 [PATCH] uml: cons... |
43 |
static const struct net_kern_info pcap_kern_info = { |
1da177e4c Linux-2.6.12-rc2 |
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
.init = pcap_init, .protocol = eth_protocol, .read = pcap_read, .write = pcap_write, }; int pcap_setup(char *str, char **mac_out, void *data) { struct pcap_init *init = data; char *remain, *host_if = NULL, *options[2] = { NULL, NULL }; int i; *init = ((struct pcap_init) { .host_if = "eth0", .promisc = 1, .optimize = 0, .filter = NULL }); |
7d98230a7 uml: network and ... |
61 |
remain = split_if_spec(str, &host_if, &init->filter, |
0ba34e197 uml: pcap devices... |
62 |
&options[0], &options[1], mac_out, NULL); |
cd1ae0e49 uml: network form... |
63 |
if (remain != NULL) { |
1da177e4c Linux-2.6.12-rc2 |
64 65 66 |
printk(KERN_ERR "pcap_setup - Extra garbage on " "specification : '%s' ", remain); |
7d98230a7 uml: network and ... |
67 |
return 0; |
1da177e4c Linux-2.6.12-rc2 |
68 |
} |
cd1ae0e49 uml: network form... |
69 |
if (host_if != NULL) |
1da177e4c Linux-2.6.12-rc2 |
70 |
init->host_if = host_if; |
cd1ae0e49 uml: network form... |
71 72 |
for (i = 0; i < ARRAY_SIZE(options); i++) { if (options[i] == NULL) |
1da177e4c Linux-2.6.12-rc2 |
73 |
continue; |
cd1ae0e49 uml: network form... |
74 |
if (!strcmp(options[i], "promisc")) |
1da177e4c Linux-2.6.12-rc2 |
75 |
init->promisc = 1; |
cd1ae0e49 uml: network form... |
76 |
else if (!strcmp(options[i], "nopromisc")) |
1da177e4c Linux-2.6.12-rc2 |
77 |
init->promisc = 0; |
cd1ae0e49 uml: network form... |
78 |
else if (!strcmp(options[i], "optimize")) |
1da177e4c Linux-2.6.12-rc2 |
79 |
init->optimize = 1; |
cd1ae0e49 uml: network form... |
80 |
else if (!strcmp(options[i], "nooptimize")) |
1da177e4c Linux-2.6.12-rc2 |
81 |
init->optimize = 0; |
7d98230a7 uml: network and ... |
82 |
else { |
cd1ae0e49 uml: network form... |
83 84 85 |
printk(KERN_ERR "pcap_setup : bad option - '%s' ", options[i]); |
7d98230a7 uml: network and ... |
86 87 |
return 0; } |
1da177e4c Linux-2.6.12-rc2 |
88 |
} |
7d98230a7 uml: network and ... |
89 |
return 1; |
1da177e4c Linux-2.6.12-rc2 |
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
} static struct transport pcap_transport = { .list = LIST_HEAD_INIT(pcap_transport.list), .name = "pcap", .setup = pcap_setup, .user = &pcap_user_info, .kern = &pcap_kern_info, .private_size = sizeof(struct pcap_data), .setup_size = sizeof(struct pcap_init), }; static int register_pcap(void) { register_transport(&pcap_transport); |
f4c57a78e [PATCH] uml: fix ... |
105 |
return 0; |
1da177e4c Linux-2.6.12-rc2 |
106 |
} |
8210fd2a9 [PATCH] uml: use ... |
107 |
late_initcall(register_pcap); |