-
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.
apps.ipv6.nd_static fills in static src/dst MAC addresses in packets transmitted on a L3 port. Together with the nd_light and ns_responder apps, it covers all cases of bidirectional dynamic ND, inbound dynamic, outbound static and bidirectional static neighbor discovery. The ns_responder app has been adapted to optionally fill in the src/dst MAC addresses as well to allow for upper-layer protocols to be agnostic of MAC addresses no matter which ND discipline is being used on the interface.
- Loading branch information
1 parent
0f5f76e
commit 244b0a2
Showing
2 changed files
with
53 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
-- Use of this source code is governed by the Apache 2.0 license; see COPYING. | ||
|
||
-- This app relays packets between its "nort" and "south" links and | ||
-- copies fixed src and dst MAC addresses to the Ethernet header of | ||
-- all packets coming in from "north". | ||
|
||
module(..., package.seeall) | ||
local ffi = require("ffi") | ||
local link = require("core.link") | ||
local ethernet = require("lib.protocol.ethernet") | ||
|
||
nd_static = subClass(nil) | ||
nd_static._name = "static ND" | ||
|
||
function nd_static:new (config) | ||
assert(config and config.local_mac and config.remote_mac) | ||
local o = nd_static:superClass().new(self) | ||
o._eth = ethernet:new({ src = config.local_mac, | ||
dst = config.remote_mac }) | ||
o._header = o._eth:header() | ||
return o | ||
end | ||
|
||
local empty, receive, transmit = link.empty, link.receive, link.transmit | ||
function nd_static:push() | ||
local l_in = self.input.north | ||
local l_out = self.output.south | ||
if l_in and l_out then | ||
while not empty(l_in) do | ||
-- Insert the static MAC addresses | ||
local p = receive(l_in) | ||
ffi.copy(p.data, self._header, 12) | ||
transmit(l_out, p) | ||
end | ||
end | ||
l_in = self.input.south | ||
l_out = self.output.north | ||
while not empty(l_in) do | ||
-- Pass all packets unchanged souh -> north | ||
transmit(l_out, receive(l_in)) | ||
end | ||
end |
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