Re: NAT-PMP Broadcast Address?
Re: NAT-PMP Broadcast Address?
- Subject: Re: NAT-PMP Broadcast Address?
- From: Josh Graessley <email@hidden>
- Date: Tue, 11 Sep 2007 11:02:09 -0700
On Sep 11, 2007, at 10:49 AM, email@hidden wrote:
On Sep 10, 2007, at 12:35 PM, Matt Slot wrote:
On Sep 10, 2007, at 1:56 PM, email@hidden wrote:
I am just wondering if I am missing something, like maybe I have
to send a special discovery packet to get the address of the
router, and then pass that to NAT-PMP so it can query the router
address directly. Or, do I look in the system somewhere for the
router address as seen in system prefs?
Here's the code I use to discover the address of my upstream
router using BSD.
Hey thanx, you always seem to help me on this esoteric stuff :-P
I'm going to try it today on my friend's airport, so if I don't
respond to this thread, then the bsd code worked.
Just to add a bit. You don't discover base stations using multicast
or broadcast. This is one of the (many) flaws of using UPnP to create
port mappings. You already know the address of your default gateway
which is almost always your NAT device if your unfortunate enough to
be stuck behind a NAT. In the odd situations where you're behind a
NAT and the NAT isn't your immediate gateway, NAT-PMP is unlikely to
be supported. It is possible that a gateway could act as a proxy. At
any rate, there's no compelling reason to support discovery.
On Sep 11, 2007, at 4:16 AM, Quinn wrote:
At 14:35 -0400 10/9/07, Matt Slot wrote:
Here's the code I use to discover the address of my upstream
router using BSD.
Alternatively you could do this the same way that mDNSResponder
does it:
1. Use SCDynamicStoreCopyValue to get "State:/Network/Global/IPv4".
2. Extract the default router's IP using the "Router" key.
You can also use SCF notifications to learn about changes.
Ya I will listen for changes, maybe with just the notifications
that happen in the spec though. Also, I think I found a flaw in
NAT-PMP...because you can't query what ports your machine opened?
I want to be able to check a port and see what it is. But the only
way to do that is to basically try to remove the port. You will
get an error code if another machine is using the port. However,
if your computer had a port allocated, you just get an answer that
you successfully either got the port, or changed its timeout, which
for removal is a timeout of 0. There doesn't seem to be a way to
determine if the port was already open. I realize that is how the
spec is designed to work, so that multiple requests return multiple
success replies, but this still seems to be a pretty major thing to
overlook.
This is by design. Do your own book keeping :) If you need a mapping,
create it. Renew it periodically as a DHCP lease would be renewed
(about half way through). When you're done with it, dispose of it.
So is there any way to get a port list from an airport, maybe not
even with NAT-PMP?
No.
-josh
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden