Explicit NAT port-mapping plugin. Surfaces the gn.link.portmap
extension (sdk/extensions/portmap.h) so other plugins — primarily
the ICE agent before host-candidate gathering — can ask the local
router for a stable (ext_ip, ext_port) mapping when the host sits
behind a symmetric NAT that STUN cannot punch.
| Protocol | RFC | Status | Notes |
|---|---|---|---|
| NAT-PMP | RFC 6886 | implemented | 12-byte request / 16-byte response on UDP/5351. Default gateway resolved from /proc/net/route. |
| PCP — MAP opcode | RFC 6887 | implemented | 60-byte MAP request (24-byte common header + 36-byte body). Client IP carried as IPv4-mapped IPv6. PEER / FILTER opcodes are out of scope for v1. |
| UPnP IGD | IGD-D 1.0/2.0 | stub | try_upnp returns -1; the SSDP discovery + SOAP control codec is not in tree. |
The plugin probes PCP and NAT-PMP at first call and caches the
result. A failing request() invalidates the cache so the next call
re-probes — covers router reboots and link changes.
Successful mappings are stored with their granted lifetime; a
background renewal thread re-sends the MAP request at lifetime_s / 2
cadence (RFC 6886 §3.3). release(protocol, int_port) sends a delete
(lifetime = 0) under the same protocol the mapping was granted with
and drops the entry from the renewal table regardless of the router's
reply.
In-tree, alongside the kernel:
nix develop --command bash -c "cd build && ninja goodnet_link_portmap"
Stand-alone:
find_package(GoodNet REQUIRED)
add_subdirectory(plugins/links/portmap)