2 * Copyright (C) 2002 Jeff Dike <jdike@karaya.com>
3 * Licensed under the GPL.
6 #include "linux/init.h"
7 #include "linux/netdevice.h"
8 #include "linux/etherdevice.h"
11 #include "pcap_user.h"
20 void pcap_init(struct net_device *dev, void *data)
22 struct uml_net_private *pri;
23 struct pcap_data *ppri;
24 struct pcap_init *init = data;
27 ppri = (struct pcap_data *) pri->user;
28 ppri->host_if = init->host_if;
29 ppri->promisc = init->promisc;
30 ppri->optimize = init->optimize;
31 ppri->filter = init->filter;
34 static int pcap_read(int fd, struct sk_buff **skb,
35 struct uml_net_private *lp)
37 *skb = ether_adjust_skb(*skb, ETH_HEADER_OTHER);
38 if(*skb == NULL) return(-ENOMEM);
39 return(pcap_user_read(fd, (*skb)->mac.raw,
40 (*skb)->dev->mtu + ETH_HEADER_OTHER,
41 (struct pcap_data *) &lp->user));
44 static int pcap_write(int fd, struct sk_buff **skb, struct uml_net_private *lp)
49 static struct net_kern_info pcap_kern_info = {
51 .protocol = eth_protocol,
56 int pcap_setup(char *str, char **mac_out, void *data)
58 struct pcap_init *init = data;
59 char *remain, *host_if = NULL, *options[2] = { NULL, NULL };
62 *init = ((struct pcap_init)
68 remain = split_if_spec(str, &host_if, &init->filter,
69 &options[0], &options[1], NULL);
71 printk(KERN_ERR "pcap_setup - Extra garbage on "
72 "specification : '%s'\n", remain);
77 init->host_if = host_if;
79 for(i = 0; i < sizeof(options)/sizeof(options[0]); i++){
80 if(options[i] == NULL)
82 if(!strcmp(options[i], "promisc"))
84 else if(!strcmp(options[i], "nopromisc"))
86 else if(!strcmp(options[i], "optimize"))
88 else if(!strcmp(options[i], "nooptimize"))
90 else printk("pcap_setup : bad option - '%s'\n", options[i]);
96 static struct transport pcap_transport = {
97 .list = LIST_HEAD_INIT(pcap_transport.list),
100 .user = &pcap_user_info,
101 .kern = &pcap_kern_info,
102 .private_size = sizeof(struct pcap_data),
103 .setup_size = sizeof(struct pcap_init),
106 static int register_pcap(void)
108 register_transport(&pcap_transport);
112 __initcall(register_pcap);