[vbox-dev] [PATCH] Implement media state for host-only interface
Alexander Eichner
Alexander.Eichner at oracle.com
Wed Sep 26 04:19:41 PDT 2012
Hi Ed,
applied the patch with minor modifications, thanks!
Regards,
Alexander Eichner
On 30.08.2012 23:23, Ed Maste wrote:
> I have an application that issues SIOCGIFMEDIA to check interface media
> status, and logs an error when that fails on a vboxnet interface.
>
> This change is based on the same support added to FreeBSD's if_tap
> interface in SVN r238183, which is in turn based on DragonFly BSD commit
> 70d9a675bf5441cc854a843ead702d08928c37f3. Sponsored by ADARA Networks.
>
> Ideally status would report 'active' only when a VM is attached to the
> host-only interface, but I don't see a straightforward way to do so with
> the decoupling between VBoxNetFlt and VBoxNetAdp -- so consider this a
> query for further information on this point as well. As it stands it
> reports 'active' always.
>
> Patch released under the MIT license.
>
> diff --git a/src/VBox/HostDrivers/VBoxNetAdp/freebsd/VBoxNetAdp-freebsd.c b/src/VBox/HostDrivers/VBoxNetAdp/freebsd/VBoxNetAdp-freebsd.c
> index 1b65cc4..42cdd3e 100644
> --- a/src/VBox/HostDrivers/VBoxNetAdp/freebsd/VBoxNetAdp-freebsd.c
> +++ b/src/VBox/HostDrivers/VBoxNetAdp/freebsd/VBoxNetAdp-freebsd.c
> @@ -48,6 +48,7 @@
> #include <net/if_var.h>
> #include <net/route.h>
> #include <net/if_dl.h>
> +#include <net/if_media.h>
> #include <net/if_types.h>
> #include <net/ethernet.h>
> #include <net/bpf.h>
> @@ -246,6 +247,10 @@ static void VBoxNetAdpFreeBSDNetstart(struct ifnet *ifp)
> */
> static int VBoxNetAdpFreeBSDNetioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
> {
> + struct ifmediareq *ifmr;
> + int count;
> + int error = 0;
> +
> switch (cmd)
> {
> case SIOCSIFFLAGS:
> @@ -260,10 +265,23 @@ static int VBoxNetAdpFreeBSDNetioctl(struct ifnet *ifp, u_long cmd, caddr_t data
> ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
> }
> break;
> + case SIOCGIFMEDIA:
> + ifmr = (struct ifmediareq *)data;
> + count = ifmr->ifm_count;
> + ifmr->ifm_count = 1;
> + ifmr->ifm_status = IFM_AVALID;
> + ifmr->ifm_active = IFM_ETHER;
> + ifmr->ifm_status |= IFM_ACTIVE;
> + ifmr->ifm_current = ifmr->ifm_active;
> + if (count >= 1) {
> + int media = IFM_ETHER;
> + error = copyout(&media, ifmr->ifm_ulist, sizeof(int));
> + }
> + break;
> default:
> return ether_ioctl(ifp, cmd, data);
> }
> - return 0;
> + return error;
> }
>
> int vboxNetAdpOsInit(PVBOXNETADP pThis)
>
>
> _______________________________________________
> vbox-dev mailing list
> vbox-dev at virtualbox.org
> https://www.virtualbox.org/mailman/listinfo/vbox-dev
ORACLE Deutschland B.V. & Co. KG Alexander Eichner
Werkstrasse 24 Engineer, VirtualBox
71384 Weinstadt, Germany mailto:alexander.eichner at oracle.com
Hauptverwaltung: Riesstr. 25, D-80992 München
Registergericht: Amtsgericht München, HRA 95603
Geschäftsführer: Jürgen Kunz
Komplementärin: ORACLE Deutschland Verwaltung B.V.
Rijnzathe 6, 3454PV De Meern, Niederlande
Handelsregister der Handelskammer Midden-Niederlande, Nr. 30143697
Geschäftsführer: Alexander van der Ven, Astrid Kepper, Val Maher
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.virtualbox.org/pipermail/vbox-dev/attachments/20120926/0798976f/attachment-0002.html
More information about the vbox-dev
mailing list