-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add protocol header for ICMPv6 Packet-Too-Big type
- Loading branch information
1 parent
b9da7ca
commit c7d772c
Showing
2 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
-- Use of this source code is governed by the Apache 2.0 license; see COPYING. | ||
|
||
module(..., package.seeall) | ||
local ffi = require("ffi") | ||
local C = ffi.C | ||
local lib = require("core.lib") | ||
local proto_header = require("lib.protocol.header") | ||
|
||
local ptb = subClass(proto_header) | ||
|
||
-- Class variables | ||
ptb._name = "packet too big" | ||
ptb._ulp = { method = nil } | ||
proto_header.init(ptb, | ||
{ | ||
-- The original packet follows the mtu. Because | ||
-- it is of variable size, it is considered as | ||
-- payload rather than part of the ICMP message | ||
-- so it can be retrieved with the datagram | ||
-- payload() method. | ||
[1] = ffi.typeof[[ | ||
struct { | ||
uint32_t mtu; | ||
} __attribute__((packed)) | ||
]] | ||
}) | ||
|
||
-- Instance methods | ||
|
||
function ptb:mtu (mtu) | ||
if mtu ~= nil then | ||
self:header().mtu = lib.htonl(mtu) | ||
end | ||
return lib.ntohl(self:header().mtu) | ||
end | ||
|
||
return ptb |