commit 9887fadf490258ebd78f9e7390544e1bb6bebc4b
parent 0ce207018eb7537dda4e246cbe26c682474080b2
Author: Jesus Galan Lopez (yiyus) <yiyu.jgl@gmail.com>
Date: Sat, 5 Jun 2010 10:21:11 +0200
do not panic after an error initializing the network device
Diffstat:
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/src/9vx/etherve.c b/src/9vx/etherve.c
@@ -47,6 +47,13 @@ eafrom(char *ma)
return 0;
}
+static void *
+veerror(char* err)
+{
+ iprint("ve: %s\n", err);
+ return nil;
+}
+
static pcap_t *
setup(void)
{
@@ -57,20 +64,21 @@ setup(void)
bpf_u_int32 net;
bpf_u_int32 mask;
- if(macaddr)
+ if(macaddr){
if(strlen(macaddr)>17)
- panic("wrong mac address");
+ return veerror("wrong mac address");
else if(sprintf(filter, "ether dst %s", macaddr) == -1)
- panic("cannot create pcap filter");
+ return veerror("cannot create pcap filter");
+ }
if (!netdev && (netdev = pcap_lookupdev(errbuf)) == nil)
- panic("cannot find network device: %s", errbuf);
+ return veerror("cannot find network device");
if ((pd = pcap_open_live(netdev, 1514, 1, 1, errbuf)) == nil)
return nil;
if (macaddr && (eafrom(macaddr) == -1))
- panic("cannot read mac address");
+ return veerror("cannot read mac address");
pcap_lookupnet(netdev, &net, &mask, errbuf);
pcap_compile(pd, &prog, filter, 0, net);