diff options
Diffstat (limited to 'arch/um/drivers/pcap_user.c')
-rw-r--r-- | arch/um/drivers/pcap_user.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/arch/um/drivers/pcap_user.c b/arch/um/drivers/pcap_user.c index dc0a903ef9a6..483aa15222a4 100644 --- a/arch/um/drivers/pcap_user.c +++ b/arch/um/drivers/pcap_user.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include "pcap_user.h" | 13 | #include "pcap_user.h" |
14 | #include "user.h" | 14 | #include "user.h" |
15 | #include "um_malloc.h" | 15 | #include "um_malloc.h" |
16 | #include "kern_constants.h" | ||
16 | 17 | ||
17 | #define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER) | 18 | #define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER) |
18 | 19 | ||
@@ -26,8 +27,8 @@ static int pcap_user_init(void *data, void *dev) | |||
26 | 27 | ||
27 | p = pcap_open_live(pri->host_if, MAX_PACKET, pri->promisc, 0, errors); | 28 | p = pcap_open_live(pri->host_if, MAX_PACKET, pri->promisc, 0, errors); |
28 | if(p == NULL){ | 29 | if(p == NULL){ |
29 | printk("pcap_user_init : pcap_open_live failed - '%s'\n", | 30 | printk(UM_KERN_ERR "pcap_user_init : pcap_open_live failed - " |
30 | errors); | 31 | "'%s'\n", errors); |
31 | return -EINVAL; | 32 | return -EINVAL; |
32 | } | 33 | } |
33 | 34 | ||
@@ -48,13 +49,13 @@ static int pcap_open(void *data) | |||
48 | if(pri->filter != NULL){ | 49 | if(pri->filter != NULL){ |
49 | err = dev_netmask(pri->dev, &netmask); | 50 | err = dev_netmask(pri->dev, &netmask); |
50 | if(err < 0){ | 51 | if(err < 0){ |
51 | printk("pcap_open : dev_netmask failed\n"); | 52 | printk(UM_KERN_ERR "pcap_open : dev_netmask failed\n"); |
52 | return -EIO; | 53 | return -EIO; |
53 | } | 54 | } |
54 | 55 | ||
55 | pri->compiled = um_kmalloc(sizeof(struct bpf_program)); | 56 | pri->compiled = um_kmalloc(sizeof(struct bpf_program)); |
56 | if(pri->compiled == NULL){ | 57 | if(pri->compiled == NULL){ |
57 | printk("pcap_open : kmalloc failed\n"); | 58 | printk(UM_KERN_ERR "pcap_open : kmalloc failed\n"); |
58 | return -ENOMEM; | 59 | return -ENOMEM; |
59 | } | 60 | } |
60 | 61 | ||
@@ -62,15 +63,15 @@ static int pcap_open(void *data) | |||
62 | (struct bpf_program *) pri->compiled, | 63 | (struct bpf_program *) pri->compiled, |
63 | pri->filter, pri->optimize, netmask); | 64 | pri->filter, pri->optimize, netmask); |
64 | if(err < 0){ | 65 | if(err < 0){ |
65 | printk("pcap_open : pcap_compile failed - '%s'\n", | 66 | printk(UM_KERN_ERR "pcap_open : pcap_compile failed - " |
66 | pcap_geterr(pri->pcap)); | 67 | "'%s'\n", pcap_geterr(pri->pcap)); |
67 | return -EIO; | 68 | return -EIO; |
68 | } | 69 | } |
69 | 70 | ||
70 | err = pcap_setfilter(pri->pcap, pri->compiled); | 71 | err = pcap_setfilter(pri->pcap, pri->compiled); |
71 | if(err < 0){ | 72 | if(err < 0){ |
72 | printk("pcap_open : pcap_setfilter failed - '%s'\n", | 73 | printk(UM_KERN_ERR "pcap_open : pcap_setfilter " |
73 | pcap_geterr(pri->pcap)); | 74 | "failed - '%s'\n", pcap_geterr(pri->pcap)); |
74 | return -EIO; | 75 | return -EIO; |
75 | } | 76 | } |
76 | } | 77 | } |
@@ -85,7 +86,8 @@ static void pcap_remove(void *data) | |||
85 | if(pri->compiled != NULL) | 86 | if(pri->compiled != NULL) |
86 | pcap_freecode(pri->compiled); | 87 | pcap_freecode(pri->compiled); |
87 | 88 | ||
88 | pcap_close(pri->pcap); | 89 | if(pri->pcap != NULL) |
90 | pcap_close(pri->pcap); | ||
89 | } | 91 | } |
90 | 92 | ||
91 | struct pcap_handler_data { | 93 | struct pcap_handler_data { |
@@ -114,7 +116,8 @@ int pcap_user_read(int fd, void *buffer, int len, struct pcap_data *pri) | |||
114 | 116 | ||
115 | n = pcap_dispatch(pri->pcap, 1, handler, (u_char *) &hdata); | 117 | n = pcap_dispatch(pri->pcap, 1, handler, (u_char *) &hdata); |
116 | if(n < 0){ | 118 | if(n < 0){ |
117 | printk("pcap_dispatch failed - %s\n", pcap_geterr(pri->pcap)); | 119 | printk(UM_KERN_ERR "pcap_dispatch failed - %s\n", |
120 | pcap_geterr(pri->pcap)); | ||
118 | return -EIO; | 121 | return -EIO; |
119 | } | 122 | } |
120 | else if(n == 0) | 123 | else if(n == 0) |