Re: Finding all IPv4 addresses associated with INADDR_ANY (?)

From: Justin Walker (justin_at_mac.com)
Date: 02/24/04

  • Next message: Ronald F. Guilmette: "Two modest kernel features I wish I had"
    Date: Mon, 23 Feb 2004 19:41:35 -0800
    To: freebsd-net@freebsd.org
    
    

    On Monday, February 23, 2004, at 07:27 PM, Ronald F. Guilmette wrote:

    > Given a socket which has been properly created, opened, and then bound
    > to some port and the special INADDR_ANY ``wildcard'' address, I need
    > to be able to them programatically find all of the IPv4 addresses that
    > the socket was just bound to.
    >
    > Can anyone suggest a way to do this?
    >
    > Can anyone suggest a way to do this easily?
    >
    > Can anyone suggest a way to do this portably?

    So I understand what you want, I'll rephrase: you want to find all the
    IPv4 addresses that have been assigned to devices on the local host.
    To pick nits, that socket was just bound to INADDR_ANY, not "all the
    address" on the host. Once a connection is accepted, that socket is
    bound based, probably, on the interface that accepted the request, or
    the destination address of that request.

    You can find the addresses on the host, in recent BSDs and Linux
    (AFAIK) with 'getifaddrs()', which is fairly easy to use, and fairly
    portable (although it's relatively new). Check the man page. You
    don't need to fuss with sockets to do this (but I'm not sure that is
    important to you).

    Does that help?

    Regards,

    Justin

    --
    Justin C. Walker, Curmudgeon-At-Large  *
    Institute for General Semantics        |    Men are from Earth.
                                            |    Women are from Earth.
                                            |       Deal with it.
    *--------------------------------------*-------------------------------*
    _______________________________________________
    freebsd-net@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-net
    To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org"
    

  • Next message: Ronald F. Guilmette: "Two modest kernel features I wish I had"

    Relevant Pages

    • Re: more details
      ... and now, before accessing remoteadmn, if i try to access \\box from my host ... 00053CB0:00000004, NTLM ... on socket 15 ... on overlapped WSASend() ...
      (microsoft.public.windowsce.platbuilder)
    • RE: help: raw_ip socket and system implication
      ... Subject: help: raw_ip socket and system implication ... you can also borrow an unused ip address on the same subnet as the host you ... the same mac address as your source host). ...
      (Vuln-Dev)
    • Re: no route to host
      ... If you are saying that 'connect' returns 'no route to host', ... this step will give my socket a random source address. ... if(sockfd < 0) ...
      (comp.os.linux.development.apps)
    • Re: socket behavior - already bound
      ... This means that an incoming connection can be addressed to any address ... conflict you have is that the IPv6 ANY address includes IPv4 addresses. ... socket a new connection to an IPv4 address should go to. ...
      (comp.unix.programmer)
    • Re: dell axim VPN sync problems
      ... Error 10048 binding Socket: ... Listening on PROTOCOL 47 for incoming GRE packets... ... Obtaining host information... ... creating a socket to test GRE protocol traffic... ...
      (microsoft.public.windowsxp.work_remotely)