Skip to content

Commit

Permalink
Raise exception on error
Browse files Browse the repository at this point in the history
  • Loading branch information
dpino committed Dec 8, 2015
1 parent 8ebd725 commit b4d6f08
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/apps/socket/raw.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ function RawSocket:new (ifname)
assert(ifname)
local tp = h.htons(c.ETH_P["ALL"])
local sock, err = S.socket(c.AF.PACKET, bit.bor(c.SOCK.RAW, c.SOCK.NONBLOCK), tp)
if not sock then return nil, err end
if not sock then error(err) end
local index, err = S.util.if_nametoindex(ifname, sock)
if err then
S.close(sock)
return nil, err
error(err)
end
local addr = t.sockaddr_ll{sll_family = c.AF.PACKET, sll_ifindex = index, sll_protocol = tp}
local ok, err = S.bind(sock, addr)
if not ok then
S.close(sock)
return nil, err
error(err)
end
return setmetatable({sock = sock}, {__index = RawSocket})
end
Expand Down

0 comments on commit b4d6f08

Please sign in to comment.