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
;
33 printk("pcap backend, host interface %s\n", ppri
->host_if
);
36 static int pcap_read(int fd
, struct sk_buff
**skb
,
37 struct uml_net_private
*lp
)
39 *skb
= ether_adjust_skb(*skb
, ETH_HEADER_OTHER
);
43 return pcap_user_read(fd
, skb_mac_header(*skb
),
44 (*skb
)->dev
->mtu
+ ETH_HEADER_OTHER
,
45 (struct pcap_data
*) &lp
->user
);
48 static int pcap_write(int fd
, struct sk_buff
**skb
, struct uml_net_private
*lp
)
53 static const struct net_kern_info pcap_kern_info
= {
55 .protocol
= eth_protocol
,
60 int pcap_setup(char *str
, char **mac_out
, void *data
)
62 struct pcap_init
*init
= data
;
63 char *remain
, *host_if
= NULL
, *options
[2] = { NULL
, NULL
};
66 *init
= ((struct pcap_init
)
72 remain
= split_if_spec(str
, &host_if
, &init
->filter
,
73 &options
[0], &options
[1], mac_out
, NULL
);
75 printk(KERN_ERR
"pcap_setup - Extra garbage on "
76 "specification : '%s'\n", remain
);
81 init
->host_if
= host_if
;
83 for(i
= 0; i
< ARRAY_SIZE(options
); i
++){
84 if(options
[i
] == NULL
)
86 if(!strcmp(options
[i
], "promisc"))
88 else if(!strcmp(options
[i
], "nopromisc"))
90 else if(!strcmp(options
[i
], "optimize"))
92 else if(!strcmp(options
[i
], "nooptimize"))
95 printk("pcap_setup : bad option - '%s'\n", options
[i
]);
103 static struct transport pcap_transport
= {
104 .list
= LIST_HEAD_INIT(pcap_transport
.list
),
107 .user
= &pcap_user_info
,
108 .kern
= &pcap_kern_info
,
109 .private_size
= sizeof(struct pcap_data
),
110 .setup_size
= sizeof(struct pcap_init
),
113 static int register_pcap(void)
115 register_transport(&pcap_transport
);
119 late_initcall(register_pcap
);