Commit Graph

21 Commits

Author SHA1 Message Date
Thomas Bernard 210876f2a7 miniupnpd/natpmp.c: make indentation consistant and add a comment 2014-03-11 09:47:09 +01:00
Daniel Becker 4f160366bd miniupnpd/natpmp.c: remove obsolete assignment
The eport_first variable now gets initialized in the first
iteration of the while loop; the assignment right before the
loop should have been removed in the previous commit.
2014-03-10 11:14:49 -07:00
Daniel Becker f4f4573f53 miniupnpd: fix eport selection and error handling
The find_available_eport function that was intended to check if
at least one eport is allowed for a given iaddr/iport does not
work as intended; for example, it does not properly handle rule
precedence (i.e., it considers allow rules even if they are
effectively masked by earlier deny rules), and it also does not
handle the case where no rules are specified at all (which
should default to accept in order to be consistent with
check_upnp_rule_against_permissions). The present change removes
this function and instead integrates the check into the existing
while loop that iterates over all eports.
2014-03-10 00:32:23 -07:00
Thomas BERNARD 0ff8e67c26 Merge pull request #57 from razzfazz/natpmp_avoid_port_zero
miniupnpd/natpmp.c: skip port zero when finding free eport
2014-03-08 01:03:43 +01:00
Daniel Becker 1db670d6ff miniupnpd/natpmp.c: skip port zero when finding free eport
When skipping ports that are in use or not allowed, the existing
NAT-PMP code will consider port zero as a candidate eport after
wraparound occurs. Since this is not a legal port, we skip over it.

port zero as an eport value.
2014-03-07 11:02:04 -08:00
Daniel Becker ba04327bb0 miniupnpd/natpmp.c: remove redundant break statements
These two break statements are redundant: The subsequent continue
statement will cause the loop condition to be re-evaluated, at which
point the loop will terminate if resp[3] != 0.
2014-03-07 07:42:40 -08:00
Thomas Bernard e385db03b9 miniupnpd: improved permission checking for NAT-PMP
NAT-PMP now searches an allowed eport if the one from
request is not, instead of returning an error
2014-03-07 11:48:17 +01:00
Daniel Becker edd501f59c miniupnpd/natpmp.c: return correct error code when all external ports in use
Instead of returning code 3 ("Network Failure"), we should the
more appropriate code 4 ("Out of resources") when no external
port is available for a mapping.
2014-02-28 14:47:53 -08:00
Thomas Bernard 3c90f6a30d miniupnpd/natpmp.c: avoid hang when all external ports in use
reorganize a bit
2014-02-28 13:34:46 +01:00
Daniel Becker c6a8879c87 miniupnpd/natpmp.c: avoid hang when all external ports in use
The NAT-PMP code attempts to find a different eport if the
requested one is already in use. If all eports are in use, that
would previously cause the code to iterate through the range of
eports forever. To avoid this case, we keep track of the first
eport we attempted to use and abort the loop once we've cycled
through all possible values exactly once (which takes us back
to the initial eport).
2014-02-28 00:00:26 -08:00
Thomas Bernard c1e624ecd4 miniupnpd: use asyncsendto 2014-02-25 11:15:30 +01:00
Thomas Bernard 3712118bc4 miniupnpd: removed unused code
ScanNATPMPforExpiration() CleanExpiredNATPMP() are not used anymore
2014-02-03 10:45:59 +01:00
Thomas Bernard f774a54bac remove C++ style comments 2013-12-13 17:01:41 +01:00
Peter Tatrai 9e1ffd5cd9 Add initial PCP support 2013-07-11 09:38:55 +02:00
Thomas Bernard 961e1c35d3 miniupnpd: autodetect LAN interface netmask instead of defaulting to /24
Fix #23
2013-03-23 11:50:57 +01:00
Thomas Bernard 4cdc0b762e set natpmp socket non blocking 2012-05-28 01:18:06 +02:00
Thomas Bernard ad95793e93 Add UNUSED(arg) macro to remove unused argument warning. 2012-05-01 11:49:23 +02:00
Shawn Landen 5c224accbf remove trailing whitespace from miniupnpd 2012-02-29 17:48:41 -08:00
Thomas Bernard 9ee74defc8 Compile miniupnpd OK with -ansi flag. 2012-02-05 00:40:50 +01:00
Thomas Bernard 73ef11624a always handle EAGAIN, EWOULDBLOCK and EINTR after recv()/recvfrom() calls 2012-02-02 18:45:43 +01:00
Thomas Bernard 0d96346588 Adding miniupnpd 2011-09-28 21:13:20 +02:00