fix error handling in pcap creation
This commit is contained in:
1 parent
1a41df1edf
commit
7b85049e0b
1 file changed
+6
-6
@@ -24,26 +24,26 @@ func newPcapIO(ifName string, promisc bool, snaplen int, bufSz int) (handle *Pca
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer inactive.CleanUp()
|
defer inactive.CleanUp()
|
||||||
if inactive.SetPromisc(promisc) != nil {
|
if err = inactive.SetPromisc(promisc); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if inactive.SetSnapLen(snaplen) != nil {
|
if err = inactive.SetSnapLen(snaplen); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if inactive.SetTimeout(-1) != nil {
|
if err = inactive.SetTimeout(-1); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if inactive.SetImmediateMode(true) != nil {
|
if err = inactive.SetImmediateMode(true); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if inactive.SetBufferSize(bufSz) != nil {
|
if err = inactive.SetBufferSize(bufSz); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
active, err := inactive.Activate()
|
active, err := inactive.Activate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if active.SetDirection(pcap.DirectionIn) != nil {
|
if err = active.SetDirection(pcap.DirectionIn); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return &PcapIO{handle: active}, nil
|
return &PcapIO{handle: active}, nil
|
||||||
|
|||||||
Reference in new issue
Block a user