summaryrefslogtreecommitdiffstats
path: root/sys/net
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1996-08-04 10:54:13 +0000
committerphk <phk@FreeBSD.org>1996-08-04 10:54:13 +0000
commitb66887b753becbfa885b773ad8eee174d7b7c3a9 (patch)
treecd6c6bb677800206647caee7792d7d992bc75967 /sys/net
parentc6621914ec6c3d2cd7c4b6ed5a8978eca30f3aa7 (diff)
downloadFreeBSD-src-b66887b753becbfa885b773ad8eee174d7b7c3a9.zip
FreeBSD-src-b66887b753becbfa885b773ad8eee174d7b7c3a9.tar.gz
Add a callback pointer to the interfaces "init" routine.
Add ether_ioctl() which can take care of the SIOC[SG]IFADDR cases for most (ethernet) drivers.
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if.h7
-rw-r--r--sys/net/if_ethersubr.c86
2 files changed, 91 insertions, 2 deletions
diff --git a/sys/net/if.h b/sys/net/if.h
index 4171ca9..c5b303a 100644
--- a/sys/net/if.h
+++ b/sys/net/if.h
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)if.h 8.1 (Berkeley) 6/10/93
- * $Id: if.h,v 1.31 1996/07/23 14:44:46 wollman Exp $
+ * $Id: if.h,v 1.32 1996/07/30 19:17:00 wollman Exp $
*/
#ifndef _NET_IF_H_
@@ -160,9 +160,13 @@ struct ifnet {
__P((struct ifnet *));
void (*if_poll_slowinput) /* input routine for slow devices */
__P((struct ifnet *, struct mbuf *));
+ void (*if_init) /* Init routine */
+ __P((void *));
struct ifqueue if_snd; /* output queue */
struct ifqueue *if_poll_slowq; /* input queue for slow devices */
};
+typedef void if_init_f_t __P((void *));
+
#define if_mtu if_data.ifi_mtu
#define if_type if_data.ifi_type
#define if_physical if_data.ifi_physical
@@ -414,6 +418,7 @@ void ether_ifattach __P((struct ifnet *));
void ether_input __P((struct ifnet *, struct ether_header *, struct mbuf *));
int ether_output __P((struct ifnet *,
struct mbuf *, struct sockaddr *, struct rtentry *));
+void ether_ioctl __P((struct ifnet *, int , caddr_t ));
void if_attach __P((struct ifnet *));
void if_down __P((struct ifnet *));
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index 33ae5ee..d9c282d 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)if_ethersubr.c 8.1 (Berkeley) 6/10/93
- * $Id: if_ethersubr.c,v 1.20 1996/06/13 02:54:03 davidg Exp $
+ * $Id: if_ethersubr.c,v 1.21 1996/06/19 01:50:10 julian Exp $
*/
#include <sys/param.h>
@@ -785,3 +785,87 @@ ether_delmulti(ifr, ac)
}
SYSCTL_NODE(_net_link, IFT_ETHER, ether, CTLFLAG_RW, 0, "Ethernet");
+
+void
+ether_ioctl(struct ifnet *ifp, int command, caddr_t data)
+{
+ struct ifaddr *ifa = (struct ifaddr *) data;
+ struct ifreq *ifr = (struct ifreq *) data;
+
+ switch (command) {
+ case SIOCSIFADDR:
+ ifp->if_flags |= IFF_UP;
+
+ switch (ifa->ifa_addr->sa_family) {
+#ifdef INET
+ case AF_INET:
+ ifp->if_init(ifp->if_softc); /* before arpwhohas */
+ arp_ifinit((struct arpcom *)ifp, ifa);
+ break;
+#endif
+#ifdef IPX
+ /*
+ * XXX - This code is probably wrong
+ */
+ case AF_IPX:
+ {
+ register struct ipx_addr *ina = &(IA_SIPX(ifa)->sipx_addr);
+
+ if (ipx_nullhost(*ina))
+ ina->x_host =
+ *(union ipx_host *) (sc->arpcom.ac_enaddr);
+ else {
+ bcopy((caddr_t) ina->x_host.c_host,
+ (caddr_t) sc->arpcom.ac_enaddr,
+ sizeof(sc->arpcom.ac_enaddr));
+ }
+
+ /*
+ * Set new address
+ */
+ ifp->if_init(ifp->if_softc);
+ break;
+ }
+#endif
+#ifdef NS
+ /*
+ * XXX - This code is probably wrong
+ */
+ case AF_NS:
+ {
+ register struct ns_addr *ina = &(IA_SNS(ifa)->sns_addr);
+
+ if (ns_nullhost(*ina))
+ ina->x_host =
+ *(union ns_host *) (sc->arpcom.ac_enaddr);
+ else {
+ bcopy((caddr_t) ina->x_host.c_host,
+ (caddr_t) sc->arpcom.ac_enaddr,
+ sizeof(sc->arpcom.ac_enaddr));
+ }
+
+ /*
+ * Set new address
+ */
+ ifp->if_init(ifp->if_softc);
+ break;
+ }
+#endif
+ default:
+ ifp->if_init(ifp->if_softc);
+ break;
+ }
+ break;
+
+ case SIOCGIFADDR:
+ {
+ struct sockaddr *sa;
+
+ sa = (struct sockaddr *) & ifr->ifr_data;
+ bcopy((caddr_t) ifp->if_softc,
+ (caddr_t) sa->sa_data, ETHER_ADDR_LEN);
+ }
+ break;
+ }
+ return;
+}
OpenPOWER on IntegriCloud