2 * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL.
6 #include <linux/init.h>
7 #include <linux/netdevice.h>
18 void pcap_init(struct net_device *dev, void *data)
20 struct uml_net_private *pri;
21 struct pcap_data *ppri;
22 struct pcap_init *init = data;
24 pri = netdev_priv(dev);
25 ppri = (struct pcap_data *) pri->user;
26 ppri->host_if = init->host_if;
27 ppri->promisc = init->promisc;
28 ppri->optimize = init->optimize;
29 ppri->filter = init->filter;
31 printk("pcap backend, host interface %s\n", ppri->host_if);
34 static int pcap_read(int fd, struct sk_buff *skb, struct uml_net_private *lp)
36 return pcap_user_read(fd, skb_mac_header(skb),
37 skb->dev->mtu + ETH_HEADER_OTHER,
38 (struct pcap_data *) &lp->user);
41 static int pcap_write(int fd, struct sk_buff *skb, struct uml_net_private *lp)
46 static const struct net_kern_info pcap_kern_info = {
48 .protocol = eth_protocol,
53 int pcap_setup(char *str, char **mac_out, void *data)
55 struct pcap_init *init = data;
56 char *remain, *host_if = NULL, *options[2] = { NULL, NULL };
59 *init = ((struct pcap_init)
65 remain = split_if_spec(str, &host_if, &init->filter,
66 &options[0], &options[1], mac_out, NULL);
68 printk(KERN_ERR "pcap_setup - Extra garbage on "
69 "specification : '%s'\n", remain);
74 init->host_if = host_if;
76 for (i = 0; i < ARRAY_SIZE(options); i++) {
77 if (options[i] == NULL)
79 if (!strcmp(options[i], "promisc"))
81 else if (!strcmp(options[i], "nopromisc"))
83 else if (!strcmp(options[i], "optimize"))
85 else if (!strcmp(options[i], "nooptimize"))
88 printk(KERN_ERR "pcap_setup : bad option - '%s'\n",
97 static struct transport pcap_transport = {
98 .list = LIST_HEAD_INIT(pcap_transport.list),
101 .user = &pcap_user_info,
102 .kern = &pcap_kern_info,
103 .private_size = sizeof(struct pcap_data),
104 .setup_size = sizeof(struct pcap_init),
107 static int register_pcap(void)
109 register_transport(&pcap_transport);
113 late_initcall(register_pcap);