Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net add prototypes, validate ifm_change and ifm_status v...



details:   https://anonhg.NetBSD.org/src/rev/79a9c70f2fa7
branches:  trunk
changeset: 360782:79a9c70f2fa7
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Fri Mar 30 13:21:24 2018 +0000

description:
add prototypes, validate ifm_change and ifm_status vectors. NFC.

diffstat:

 sys/net/if_media.c |  23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)

diffs (61 lines):

diff -r 006e0e027a54 -r 79a9c70f2fa7 sys/net/if_media.c
--- a/sys/net/if_media.c        Fri Mar 30 13:14:25 2018 +0000
+++ b/sys/net/if_media.c        Fri Mar 30 13:21:24 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_media.c,v 1.35 2017/11/22 03:03:18 ozaki-r Exp $    */
+/*     $NetBSD: if_media.c,v 1.36 2018/03/30 13:21:24 mlelstv Exp $    */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.35 2017/11/22 03:03:18 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.36 2018/03/30 13:21:24 mlelstv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -89,6 +89,9 @@
 #include <net/if_media.h>
 #include <net/netisr.h>
 
+static void    ifmedia_status(struct ifmedia *, struct ifnet *, struct ifmediareq *);
+static int     _ifmedia_ioctl(struct ifnet *, struct ifreq *, struct ifmedia *, u_long);
+
 /*
  * Compile-time options:
  * IFMEDIA_DEBUG:
@@ -122,9 +125,22 @@
 int
 ifmedia_change(struct ifmedia *ifm, struct ifnet *ifp)
 {
+
+       if (ifm->ifm_change == NULL)
+               return -1;
        return (*ifm->ifm_change)(ifp);
 }
 
+static void
+ifmedia_status(struct ifmedia *ifm, struct ifnet *ifp,
+       struct ifmediareq *ifmr)
+{
+
+       if (ifm->ifm_status == NULL)
+               return;
+       (*ifm->ifm_status)(ifp, ifmr);
+}
+
 /*
  * Add a media configuration to the list of supported media
  * for a specific interface instance.
@@ -317,8 +333,7 @@
                    ifm->ifm_cur->ifm_media : IFM_NONE;
                ifmr->ifm_mask = ifm->ifm_mask;
                ifmr->ifm_status = 0;
-               /* ifmedia_status */
-               (*ifm->ifm_status)(ifp, ifmr);
+               ifmedia_status(ifm, ifp, ifmr);
 
                /*
                 * Count them so we know a-priori how much is the max we'll



Home | Main Index | Thread Index | Old Index