Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Nov 1998 22:03:07 -0800 (PST)
From:      "Jonathan M. Bresler" <jmb>
To:        hackers
Subject:   tun interfaces not returned by SIOCGIFCONF ??
Message-ID:  <199811290603.WAA27066@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help
	kernel info: 3.0-CURRENT FreeBSD 3.0-CURRENT #10: Fri Nov 27 12:00:05 

	tried nmap over ppp on a tun interface.
	nmap claims it cant find the source address (my address on tun0).
	nmap uses SIOCGIFCONF to get a ifconf (/sys/net/if.h) which
	contains a list of ifreq structures.  neither tun0 nor ppp0
	appear on the list. (ifconfig -a uses a sysctl to get the list,
	by the way).

	is it a bug or a misconfiguration on my part?

~~~~~~~~~~~~~~~~~~~~
in this code snippit, i always call inet_ntoa() eventhough the argument
may no be an address but rather other data.

code from nmap (printf()'s are my additions):
        for (ifr = (struct ifreq *) pbuf;
           ifr && *((char *) ifr) && ((char *) ifr) < pbuf + ifc.ifc_len;
             ((*(char **) &ifr) += sizeof(ifr->ifr_name) + len)) {
                sin = (struct sockaddr_in *) & ifr->ifr_addr;
printf("ifc_len: %d (currently at %u)\n", ifc.ifc_len, (char *)ifr - pbuf);
printf("trying: %s: %s\n", ifr->ifr_name, inet_ntoa(sin->sin_addr));
                if (sin->sin_addr.s_addr == addr->s_addr) {
                        /*
                         * Stevens does this in UNP, so it may be useful in
                         * some cases
                         */
                        if ((p = strchr(ifr->ifr_name, ':')))
                                *p = '\0';
                        /*
                         * If an app gives me less than 64 bytes, they
                         * deserve to be overflowed!
                         */ 
                        strncpy(dev, ifr->ifr_name, 63);
                        dev[63] = '\0';
                        return 1;
                }
        }
if (!ifr)
        printf("ifr\n");
else if (!(*((char *)ifr))) 
        printf("*((char *)ifr)\n");
else if (!((char *)ifr < pbuf + ifc.ifc_len))
        printf("(char *) ifr < pbuf + ifc.ifc_len\n");
~~~~~~~~~~~~~~~~~~~~
nmap shows:
Aspen:[399] ./nmap -s -D -n -v -S 207.172.87.229 .......
Starting nmap V. 1.51 by Fyodor (fyodor@dhp.com, www.dhp.com/~fyodor/nmap/)
ifc_len: 412 (currently at 0)
trying: lp0: 34.3.0.0
ifc_len: 412 (currently at 36)
trying: ep0: 6.3.6.0
ifc_len: 412 (currently at 72)
trying: ep0: 192.168.250.10
*((char *)ifr)
Could not figure out what device to send the packet out on!  You might possibly want to try -S (but this is probably a bigger problem)
~~~~~~~~~~~~~~~~~~~~
ifconfig -a shows:
Aspen:[400] ifconfig -a  
lp0: flags=8810<POINTOPOINT,SIMPLEX,MULTICAST> mtu 1500
ep0: flags=c843<UP,BROADCAST,RUNNING,SIMPLEX,LINK2,MULTICAST> mtu 1500
        inet 192.168.250.10 netmask 0xffffff00 broadcast 192.168.250.255
        ether 00:60:8c:79:b5:4a 
tun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1006
        inet 10.0.0.1 --> 10.0.0.2 netmask 0xff000000 
        inet 207.172.87.115 --> 255.255.255.255 netmask 0xffffffff 
        inet 207.172.87.229 --> 10.11.64.66 netmask 0xffffff00 
tun1: flags=8010<POINTOPOINT,MULTICAST> mtu 1500
sl0: flags=c010<POINTOPOINT,LINK2,MULTICAST> mtu 552
sl1: flags=c010<POINTOPOINT,LINK2,MULTICAST> mtu 552
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
        inet 127.0.0.1 netmask 0xff000000 
~~~~~~~~~~~~~~~~~~~~
jmb
-- 
Jonathan M. Bresler      FreeBSD Core Team, Postmaster       jmb@FreeBSD.ORG
FreeBSD--The Power to Serve                          http://www.freebsd.org/
PGP 2.6.2 Fingerprint:      31 57 41 56 06 C1 40 13  C5 1C E3 E5 DC 62 0E FB

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199811290603.WAA27066>