Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Feb 2016 18:02:47 +0000 (UTC)
From:      Pallav Bose <pallav_bose@yahoo.com>
To:        "freebsd-net@freebsd.org" <freebsd-net@freebsd.org>
Cc:        "rpokala@mac.com" <rpokala@mac.com>
Subject:   Re: C program API to determine negotiated link speed of a network interface?
Message-ID:  <604939402.3154674.1455300167449.JavaMail.yahoo@mail.yahoo.com>
In-Reply-To: <249322925.1631277.1455058288002.JavaMail.yahoo@mail.yahoo.com>
References:  <249322925.1631277.1455058288002.JavaMail.yahoo.ref@mail.yahoo.com> <249322925.1631277.1455058288002.JavaMail.yahoo@mail.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi Ravi,
That information you provided was very useful, thanks!=20
=C2=A0Regards,
Pallav=20

    On Tuesday, February 9, 2016 2:51 PM, Pallav Bose <pallav_bose@yahoo.co=
m> wrote:
=20

 Hi,
I'm writing a C program to list all available interfaces and their link spe=
ed. I can use getifaddrs(3) to obtain a list of network interfaces in a str=
uct ifaddrs, but none of the fields in this struct gives me information abo=
ut the negotiated link speed. From the man page of getifaddrs(3):
The ifaddrs structure contains at least the following entries:

=C2=A0=C2=A0=C2=A0 =C2=A0struct=C2=A0=C2=A0=C2=A0 ifaddrs=C2=A0=C2=A0=C2=A0=
 *ifa_next;=C2=A0=C2=A0=C2=A0 =C2=A0 /* Pointer to next struct */
=C2=A0=C2=A0=C2=A0 =C2=A0char=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 *ifa_name;=C2=A0=C2=A0=C2=A0 =
=C2=A0 /* Interface name */
=C2=A0=C2=A0=C2=A0 =C2=A0u_int=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ifa_flags;=C2=A0=C2=A0=C2=A0 =
=C2=A0 /* Interface flags=C2=A0=C2=A0=C2=A0 */
=C2=A0=C2=A0=C2=A0 =C2=A0struct=C2=A0=C2=A0=C2=A0 sockaddr=C2=A0 *ifa_addr;=
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 /* Interface address */
=C2=A0=C2=A0=C2=A0 =C2=A0struct=C2=A0=C2=A0=C2=A0 sockaddr=C2=A0 *ifa_netma=
sk;=C2=A0=C2=A0=C2=A0 /* Interface netmask */
=C2=A0=C2=A0=C2=A0 =C2=A0struct=C2=A0=C2=A0=C2=A0 sockaddr=C2=A0 *ifa_broad=
addr;=C2=A0 /* Interface broadcast address */
=C2=A0=C2=A0=C2=A0 =C2=A0struct=C2=A0=C2=A0=C2=A0 sockaddr=C2=A0 *ifa_dstad=
dr;=C2=A0=C2=A0=C2=A0 /* P2P interface destination */
=C2=A0=C2=A0=C2=A0 =C2=A0void=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 *ifa_data;=C2=A0=C2=A0=C2=A0 =C2=A0=C2=
=A0 /* Address specific data */

Running truss on ifconfig(8) tells me that the ioctl SIOCGIFMEDIA can be us=
ed, but it is not clear to me how. Is there an API in C which does this alr=
eady?
# truss ifconfig em0....<snipped>....
ioctl(3,SIOCGIFMAC,0xffffe210)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ERR#22 'Inv=
alid argument'
ioctl(3,SIOCGIFMEDIA,0xffffe1f0)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D 0 (0x0)
ioctl(3,SIOCGIFMEDIA,0xffffe1f0)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D 0 (0x0)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 media: Ethernet autoselect (1000=
baseT <full-duplex>)
write(1,"\tmedia: Ethernet autoselect (10"...,54) =3D 54 (0x36)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 status: active
write(1,"\tstatus: active\n",16)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D 16 (0x10)

Thanks,Pallav


  
From owner-freebsd-net@freebsd.org  Fri Feb 12 21:02:10 2016
Return-Path: <owner-freebsd-net@freebsd.org>
Delivered-To: freebsd-net@mailman.ysv.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by mailman.ysv.freebsd.org (Postfix) with ESMTP id 94EE2AA748A
 for <freebsd-net@mailman.ysv.freebsd.org>;
 Fri, 12 Feb 2016 21:02:10 +0000 (UTC)
 (envelope-from bugzilla-noreply@freebsd.org)
Received: from kenobi.freebsd.org (kenobi.freebsd.org
 [IPv6:2001:1900:2254:206a::16:76])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (Client did not present a certificate)
 by mx1.freebsd.org (Postfix) with ESMTPS id 86385F80
 for <freebsd-net@FreeBSD.org>; Fri, 12 Feb 2016 21:02:10 +0000 (UTC)
 (envelope-from bugzilla-noreply@freebsd.org)
Received: from bugs.freebsd.org ([127.0.1.118])
 by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id u1CL29kQ041577
 for <freebsd-net@FreeBSD.org>; Fri, 12 Feb 2016 21:02:10 GMT
 (envelope-from bugzilla-noreply@freebsd.org)
From: bugzilla-noreply@freebsd.org
To: freebsd-net@FreeBSD.org
Subject: [Bug 207087] kernel: r295285 in 10.2-STABLE breaks OpenVPN
 functionality
Date: Fri, 12 Feb 2016 21:02:09 +0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: Base System
X-Bugzilla-Component: kern
X-Bugzilla-Version: 10.2-STABLE
X-Bugzilla-Keywords: regression
X-Bugzilla-Severity: Affects Only Me
X-Bugzilla-Who: g_amanakis@yahoo.com
X-Bugzilla-Status: New
X-Bugzilla-Resolution: 
X-Bugzilla-Priority: ---
X-Bugzilla-Assigned-To: gnn@FreeBSD.org
X-Bugzilla-Flags: 
X-Bugzilla-Changed-Fields: attachments.created
Message-ID: <bug-207087-2472-eV1DQWNv11@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-207087-2472@https.bugs.freebsd.org/bugzilla/>
References: <bug-207087-2472@https.bugs.freebsd.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-BeenThere: freebsd-net@freebsd.org
X-Mailman-Version: 2.1.20
Precedence: list
List-Id: Networking and TCP/IP with FreeBSD <freebsd-net.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/freebsd-net>,
 <mailto:freebsd-net-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-net/>;
List-Post: <mailto:freebsd-net@freebsd.org>
List-Help: <mailto:freebsd-net-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/freebsd-net>,
 <mailto:freebsd-net-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Fri, 12 Feb 2016 21:02:10 -0000

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D207087

--- Comment #19 from g_amanakis@yahoo.com ---
Created attachment 166908
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D166908&action=
=3Dedit
wan.pcap

--=20
You are receiving this mail because:
You are on the CC list for the bug.=



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