Skip to content

Commit

Permalink
Bump miniupnp to miniupnpc_2_3_0 (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
etan-status authored Jan 13, 2025
1 parent 53b5883 commit 213ac13
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 25 deletions.
61 changes: 39 additions & 22 deletions nat_traversal/miniupnpc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type
internalClient* {.importc: "internalClient".}: array[64, char]
description* {.importc: "description".}: array[64, char]
protocol* {.importc: "protocol".}: array[4, char]
enabled* {.importc: "enabled".}: cuchar
enabled* {.importc: "enabled".}: uint8

PortMappingParserData* {.importc: "struct PortMappingParserData",
header: "portlistingparse.h", bycopy.} = object
Expand Down Expand Up @@ -436,9 +436,18 @@ type
elt* {.importc: "elt".}: cstring
val* {.importc: "val".}: cstring

proc simpleUPnPcommand*(a1: cint; a2: cstring; a3: cstring; a4: cstring; a5: ptr UPNParg;
a6: ptr cint): cstring {.importc: "simpleUPnPcommand",
header: "miniupnpc.h".}
## simpleUPnPcommand :
## not so simple !
## return values :
## pointer - OK
## NULL - error
proc simpleUPnPcommand*(
url: cstring,
service: cstring,
action: cstring,
args: ptr UPNParg,
bufsize: ptr cint
): cstring {.importc: "simpleUPnPcommand", header: "miniupnpc.h".}

## upnpDiscover()
## discover UPnP devices on the network.
Expand All @@ -459,21 +468,21 @@ proc simpleUPnPcommand*(a1: cint; a2: cstring; a3: cstring; a4: cstring; a5: ptr
## if 0, the discovery will stop with the first type returning results.
## TTL should default to 2.
proc upnpDiscover*(delay: cint; multicastif: cstring; minissdpdsock: cstring;
localport: cint; ipv6: cint; ttl: cuchar; error: ptr cint): ptr UPNPDev {.
localport: cint; ipv6: cint; ttl: uint8; error: ptr cint): ptr UPNPDev {.
importc: "upnpDiscover", header: "miniupnpc.h".}

proc upnpDiscoverAll*(delay: cint; multicastif: cstring; minissdpdsock: cstring;
localport: cint; ipv6: cint; ttl: cuchar; error: ptr cint): ptr UPNPDev {.
localport: cint; ipv6: cint; ttl: uint8; error: ptr cint): ptr UPNPDev {.
importc: "upnpDiscoverAll", header: "miniupnpc.h".}

proc upnpDiscoverDevice*(device: cstring; delay: cint; multicastif: cstring;
minissdpdsock: cstring; localport: cint; ipv6: cint;
ttl: cuchar; error: ptr cint): ptr UPNPDev {.
ttl: uint8; error: ptr cint): ptr UPNPDev {.
importc: "upnpDiscoverDevice", header: "miniupnpc.h".}

proc upnpDiscoverDevices*(deviceTypes: ptr cstring; delay: cint; multicastif: cstring;
minissdpdsock: cstring; localport: cint; ipv6: cint;
ttl: cuchar; error: ptr cint; searchalltypes: cint): ptr UPNPDev {.
ttl: uint8; error: ptr cint; searchalltypes: cint): ptr UPNPDev {.
importc: "upnpDiscoverDevices", header: "miniupnpc.h".}

## structure used to get fast access to urls
Expand All @@ -490,21 +499,28 @@ type
controlURL_6FC* {.importc: "controlURL_6FC".}: cstring
rootdescURL* {.importc: "rootdescURL".}: cstring

const
UPNP_NO_IGD* = cint(0)
UPNP_CONNECTED_IGD* = cint(1)
UPNP_PRIVATEIP_IGD* = cint(2)
UPNP_DISCONNECTED_IGD* = cint(3)
UPNP_UNKNOWN_DEVICE* = cint(4)

## UPNP_GetValidIGD() :
## return values :
## -1 = Internal error
## 0 = NO IGD found
## 1 = A valid connected IGD has been found
## 0 = NO IGD found (UPNP_NO_IGD)
## 1 = A valid connected IGD has been found (UPNP_CONNECTED_IGD)
## 2 = A valid connected IGD has been found but its
## IP address is reserved (non routable)
## IP address is reserved (non routable) (UPNP_PRIVATEIP_IGD)
## 3 = A valid IGD has been found but it reported as
## not connected
## not connected (UPNP_DISCONNECTED_IGD)
## 4 = an UPnP device has been found but was not recognized as an IGD
## (UPNP_UNKNOWN_DEVICE)
##
## In any non-zero return case, the urls and data structures
## passed as parameters are set. Don't forget to call freeUPNPUrls(urls) to
## In any positive non zero return case, the urls and data structures
## passed as parameters are set. Don't forget to call FreeUPNPUrls(urls) to
## free allocated memory.
##
proc UPNP_GetValidIGD*(devlist: ptr UPNPDev; urls: ptr UPNPUrls; data: ptr IGDdatas;
lanaddr: cstring; lanaddrlen: cint;
wanaddr: cstring; wanaddrlen: cint): cint {.
Expand Down Expand Up @@ -542,7 +558,7 @@ type Miniupnp* = ref object
miniSsdpdSocket*: string
localPort*: cint
ipv6*: cint
ttl*: cuchar
ttl*: uint8
error*: cint
lanAddr*: string
wanAddr*: string
Expand All @@ -554,8 +570,9 @@ proc close*(x: Miniupnp) =
freeUPNPUrls(addr(x.urls))

proc newMiniupnp*(): Miniupnp =
doAssert MINIUPNPC_API_VERSION == 19
new(result)
result.ttl = 2.cuchar
result.ttl = 2.uint8

proc `=deepCopy`*(x: Miniupnp): Miniupnp =
doAssert(false, "not implemented")
Expand Down Expand Up @@ -593,11 +610,11 @@ proc discover*(self: Miniupnp): Result[int, cstring] =
result.err(upnpError(self.error))

type SelectIGDResult* = enum
IGDNotFound = 0
IGDFound = 1
IGDIpNotRoutable = 2
IGDNotConnected = 3
NotAnIGD = 4
IGDNotFound = UPNP_NO_IGD.int
IGDFound = UPNP_CONNECTED_IGD.int
IGDIpNotRoutable = UPNP_PRIVATEIP_IGD.int
IGDNotConnected = UPNP_DISCONNECTED_IGD.int
NotAnIGD = UPNP_UNKNOWN_DEVICE.int

proc selectIGD*(self: Miniupnp): SelectIGDResult =
let addrLen = 40.cint
Expand Down
3 changes: 1 addition & 2 deletions nat_traversal/natpmp.nim
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type
s* {.importc: "s".}: cint ## socket
gateway* {.importc: "gateway".}: culong ## default gateway (IPv4)
has_pending_request* {.importc: "has_pending_request".}: cint
pending_request* {.importc: "pending_request".}: array[12, cuchar]
pending_request* {.importc: "pending_request".}: array[12, uint8]
pending_request_len* {.importc: "pending_request_len".}: cint
try_number* {.importc: "try_number".}: cint
retry_time* {.importc: "retry_time".}: Timeval
Expand Down Expand Up @@ -298,4 +298,3 @@ proc addPortMapping*(self: NatPmp, eport: cushort, iport: cushort, protocol: Nat

proc deletePortMapping*(self: NatPmp, eport: cushort, iport: cushort, protocol: NatPmpProtocol): Result[cushort, string] =
return self.doMapping(eport, iport, protocol, 0)

2 changes: 1 addition & 1 deletion vendor/miniupnp
Submodule miniupnp updated 46 files
+6 −0 .github/workflows/miniupnpc_wheels.yml
+1 −0 README
+2 −2 miniupnpc/CMakeLists.txt
+10 −1 miniupnpc/Changelog.txt
+6 −0 miniupnpc/DESCRIPTION
+1 −1 miniupnpc/Makefile
+1 −1 miniupnpc/VERSION
+6 −1 miniupnpc/apiversions.txt
+15 −9 miniupnpc/include/miniupnpc.h
+2 −0 miniupnpc/setup.py
+9 −1 miniupnpc/setupmingw32.py
+13 −13 miniupnpc/src/miniupnpc.c
+9 −9 miniupnpc/src/upnpc.c
+37 −37 miniupnpc/src/upnpcommands.c
+24 −1 miniupnpd/Changelog.txt
+14 −2 miniupnpd/INSTALL
+14 −31 miniupnpd/Makefile.bsd
+62 −127 miniupnpd/Makefile.linux
+65 −108 miniupnpd/Makefile.linux_nft
+1 −1 miniupnpd/VERSION
+17 −2 miniupnpd/bsd/getroute.c
+32 −0 miniupnpd/common.mk
+253 −73 miniupnpd/configure
+8 −3 miniupnpd/gitrev.mk
+26 −0 miniupnpd/linux/miniupnpd.iptables.service
+26 −0 miniupnpd/linux/miniupnpd.nft.service
+0 −11 miniupnpd/linux/miniupnpd.service
+18 −2 miniupnpd/minissdp.c
+5 −6 miniupnpd/miniupnpd.8
+66 −7 miniupnpd/miniupnpd.c
+12 −8 miniupnpd/miniupnpd.conf
+18 −5 miniupnpd/netfilter_nft/nftnlrdr.c
+6 −3 miniupnpd/netfilter_nft/nftnlrdr_misc.c
+5 −0 miniupnpd/objects.mk
+2 −2 miniupnpd/options.h
+26 −4 miniupnpd/pcpserver.c
+15 −4 miniupnpd/pf/Makefile
+337 −95 miniupnpd/pf/obsdrdr.c
+236 −64 miniupnpd/pf/pfpinhole.c
+3 −3 miniupnpd/pf/testobsdrdr.c
+7 −3 miniupnpd/pf/testpfpinhole.c
+33 −3 miniupnpd/upnpevents.c
+7 −2 miniupnpd/upnpevents.h
+0 −7 miniupnpd/upnphttp.c
+32 −0 miniupnpd/upnpsoap.c
+7 −2 miniupnpd/upnputils.c

0 comments on commit 213ac13

Please sign in to comment.