コード例 #1
0
ファイル: network.c プロジェクト: RTEMS/rtems
static int minimac_ioctl(struct ifnet *ifp, ioctl_command_t command,
  caddr_t data)
{
  int error;
  
  error = 0;
  switch (command) {
    case SIOCGIFADDR:
    case SIOCSIFADDR:
      ether_ioctl(ifp, command, data);
      break;

    case SIOCSIFFLAGS:
      switch(ifp->if_flags & (IFF_UP | IFF_RUNNING)) {
        case IFF_RUNNING:
          minimac_stop();
          break;
        case IFF_UP:
          minimac_init(NULL);
          break;
        case IFF_UP | IFF_RUNNING:
          minimac_stop();
          minimac_init(NULL);
          break;
        default:
          break;
      }
      break;

    default:
      error = EINVAL;
      break;
  }
  return error;
}
コード例 #2
0
ファイル: if_vether.c プロジェクト: mohsenV1980/yamsff
/*
 * Media types can't be changed.
 */
static int
vether_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
{
	struct vether_softc *sc = ifp->if_softc;	
	struct ifreq *ifr = (struct ifreq *)data;
	int error = 0;
 
	switch (cmd) {
	case SIOCSIFMTU:
		if (ifr->ifr_mtu > ETHER_MAX_LEN_JUMBO) 
			error = EINVAL;
		else 
			ifp->if_mtu = ifr->ifr_mtu;	
		break;
	case SIOCSIFMEDIA:
	case SIOCGIFMEDIA:
		error = ifmedia_ioctl(ifp, ifr, &sc->sc_ifm, cmd);
		break;
	case SIOCSIFFLAGS:
	case SIOCADDMULTI:
	case SIOCDELMULTI:
		break;
	case SIOCSIFPHYS:
		error = EOPNOTSUPP;
		break;
	default:
		error = ether_ioctl(ifp, cmd, data);
		break;
	}
	return (error);
} 
コード例 #3
0
/*
 * Process an ioctl request. This code needs some work - it looks
 *	pretty ugly.
 */
static int
el_ioctl(struct ifnet *ifp, u_long command, caddr_t data, struct ucred *cr)
{
	int error = 0;

	switch (command) {
	case SIOCSIFFLAGS:
		/*
		 * If interface is marked down and it is running, then stop it
		 */
		if (((ifp->if_flags & IFF_UP) == 0) &&
		    (ifp->if_flags & IFF_RUNNING)) {
			el_stop(ifp->if_softc);
			ifp->if_flags &= ~IFF_RUNNING;
		} else {
		/*
		 * If interface is marked up and it is stopped, then start it
		 */
			if ((ifp->if_flags & IFF_UP) &&
		    	    ((ifp->if_flags & IFF_RUNNING) == 0))
				el_init(ifp->if_softc);
		}
		break;
	default:
		error = ether_ioctl(ifp, command, data);
		break;
	}
	return (error);
}
コード例 #4
0
ファイル: if_axgbe.c プロジェクト: 2trill2spill/freebsd
static int
axgbe_ioctl(struct ifnet *ifp, unsigned long command, caddr_t data)
{
	struct axgbe_softc *sc = ifp->if_softc;
	struct ifreq *ifr = (struct ifreq *)data;
	int error;

	switch(command) {
	case SIOCSIFMTU:
		if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > ETHERMTU_JUMBO)
			error = EINVAL;
		else
			error = xgbe_change_mtu(ifp, ifr->ifr_mtu);
		break;
	case SIOCSIFFLAGS:
		error = 0;
		break;
	case SIOCSIFMEDIA:
	case SIOCGIFMEDIA:
		error = ifmedia_ioctl(ifp, ifr, &sc->media, command);
		break;
	default:
		error = ether_ioctl(ifp, command, data);
		break;
	}

	return (error);
}
コード例 #5
0
ファイル: if_tap.c プロジェクト: ryo/netbsd-src
/*
 * A typical driver will only contain the following handlers for
 * ioctl calls, except SIOCSIFPHYADDR.
 * The latter is a hack I used to set the Ethernet address of the
 * faked device.
 *
 * Note that both ifmedia_ioctl() and ether_ioctl() have to be
 * called under splnet().
 */
static int
tap_ioctl(struct ifnet *ifp, u_long cmd, void *data)
{
	struct tap_softc *sc = (struct tap_softc *)ifp->if_softc;
	struct ifreq *ifr = (struct ifreq *)data;
	int s, error;

	s = splnet();

	switch (cmd) {
#ifdef OSIOCSIFMEDIA
	case OSIOCSIFMEDIA:
#endif
	case SIOCSIFMEDIA:
	case SIOCGIFMEDIA:
		error = ifmedia_ioctl(ifp, ifr, &sc->sc_im, cmd);
		break;
	case SIOCSIFPHYADDR:
		error = tap_lifaddr(ifp, cmd, (struct ifaliasreq *)data);
		break;
	default:
		error = ether_ioctl(ifp, cmd, data);
		if (error == ENETRESET)
			error = 0;
		break;
	}

	splx(s);

	return (error);
}
コード例 #6
0
ファイル: t4_tracer.c プロジェクト: JabirTech/Source
static int
tracer_ioctl(struct ifnet *ifp, unsigned long cmd, caddr_t data)
{
	int rc = 0;
	struct adapter *sc;
	struct ifreq *ifr = (struct ifreq *)data;

	switch (cmd) {
	case SIOCSIFMTU:
	case SIOCSIFFLAGS:
	case SIOCADDMULTI:
	case SIOCDELMULTI:
	case SIOCSIFCAP:
		break;
	case SIOCSIFMEDIA:
	case SIOCGIFMEDIA:
		sx_xlock(&t4_trace_lock);
		sc = ifp->if_softc;
		if (sc == NULL)
			rc = EIO;
		else
			rc = ifmedia_ioctl(ifp, ifr, &sc->media, cmd);
		sx_xunlock(&t4_trace_lock);
		break;
	default:
		rc = ether_ioctl(ifp, cmd, data);
	}

	return (rc);
}
コード例 #7
0
ファイル: if_ntb.c プロジェクト: ele7enxxh/dtrace-pf
static int
ntb_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
{
	struct ntb_netdev *nt = ifp->if_softc;
	struct ifreq *ifr = (struct ifreq *)data;
	int error = 0;

	switch (command) {
	case SIOCSIFMTU:
	    {
		if (ifr->ifr_mtu > ntb_transport_max_size(nt->qp) -
		    ETHER_HDR_LEN - ETHER_CRC_LEN) {
			error = EINVAL;
			break;
		}

		ifp->if_mtu = ifr->ifr_mtu;
		break;
	    }
	default:
		error = ether_ioctl(ifp, command, data);
		break;
	}

	return (error);
}
コード例 #8
0
int
dme_ioctl(struct ifnet *ifp, u_long cmd, void *data)
{
    struct dme_softc *sc = ifp->if_softc;
    struct ifreq *ifr = data;
    int s, error = 0;

    s = splnet();

    switch(cmd) {
    case SIOCGIFMEDIA:
    case SIOCSIFMEDIA:
        error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
        break;
    default:
        error = ether_ioctl(ifp, cmd, data);
        if (error == ENETRESET) {
            if (ifp->if_flags && IFF_RUNNING) {
                /* Address list has changed, reconfigure
                   filter */
                dme_set_addr_filter(sc);
            }
            error = 0;
        }
        break;
    }

    splx(s);
    return error;
}
コード例 #9
0
ファイル: smc83c170.c プロジェクト: orumin/openbsd-efivars
/*
 * Handle control requests from the operator.
 * [ifnet interface function]
 */
int
epic_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
{
	struct epic_softc *sc = ifp->if_softc;
	struct ifaddr *ifa = (struct ifaddr *)data;
	struct ifreq *ifr = (struct ifreq *)data;
	int s, error = 0;

	s = splnet();

	switch (cmd) {
	case SIOCSIFADDR:
		ifp->if_flags |= IFF_UP;

		switch (ifa->ifa_addr->sa_family) {
		case AF_INET:
			epic_init(ifp);
			arp_ifinit(&sc->sc_arpcom, ifa);
			break;
		default:
			epic_init(ifp);
			break;
		}
		break;

	case SIOCSIFFLAGS:
		/*
		 * If interface is marked up and not running, then start it.
		 * If it is marked down and running, stop it.
		 * XXX If it's up then re-initialize it. This is so flags
		 * such as IFF_PROMISC are handled.
		 */
		if (ifp->if_flags & IFF_UP)
			epic_init(ifp);
		else if (ifp->if_flags & IFF_RUNNING)
			epic_stop(ifp, 1);
		break;

	case SIOCSIFMEDIA:
	case SIOCGIFMEDIA:
		error = ifmedia_ioctl(ifp, ifr, &sc->sc_mii.mii_media, cmd);
		break;

	default:
		error = ether_ioctl(ifp, &sc->sc_arpcom, cmd, data);
	}

	if (error == ENETRESET) {
		if (ifp->if_flags & IFF_RUNNING) {
			mii_pollstat(&sc->sc_mii);
			epic_set_mchash(sc);
		}
		error = 0;
	}

	splx(s);
	return (error);
}
コード例 #10
0
ファイル: if_vtbe.c プロジェクト: jashank/freebsd
static int
vtbe_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
{
	struct ifmediareq *ifmr;
	struct vtbe_softc *sc;
	struct ifreq *ifr;
	int mask, error;

	sc = ifp->if_softc;
	ifr = (struct ifreq *)data;

	error = 0;
	switch (cmd) {
	case SIOCSIFFLAGS:
		VTBE_LOCK(sc);
		if (ifp->if_flags & IFF_UP) {
			pio_enable_irq(sc, 1);

			if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
				vtbe_init_locked(sc);
			}
		} else {
			pio_enable_irq(sc, 0);

			if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
				vtbe_stop_locked(sc);
			}
		}
		sc->if_flags = ifp->if_flags;
		VTBE_UNLOCK(sc);
		break;
	case SIOCADDMULTI:
	case SIOCDELMULTI:
		break;
	case SIOCSIFMEDIA:
	case SIOCGIFMEDIA:
		ifmr = (struct ifmediareq *)data;
		ifmr->ifm_count = 1;
		ifmr->ifm_status = (IFM_AVALID | IFM_ACTIVE);
		ifmr->ifm_active = (IFM_ETHER | IFM_10G_T | IFM_FDX);
		ifmr->ifm_current = ifmr->ifm_active;
		break;
	case SIOCSIFCAP:
		mask = ifp->if_capenable ^ ifr->ifr_reqcap;
		if (mask & IFCAP_VLAN_MTU) {
			ifp->if_capenable ^= IFCAP_VLAN_MTU;
		}
		break;

	case SIOCSIFADDR:
		pio_enable_irq(sc, 1);
	default:
		error = ether_ioctl(ifp, cmd, data);
		break;
	}

	return (error);
}
コード例 #11
0
ファイル: if_mc.c プロジェクト: bradla/OpenBSD-Hammer2
int
mc_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
{
	struct mc_softc *sc = ifp->if_softc;
	struct ifaddr *ifa = (struct ifaddr *)data;
	int s, err = 0;

	s = splnet();

	switch (cmd) {
	case SIOCSIFADDR:
		ifp->if_flags |= IFF_UP;
		if (!(ifp->if_flags & IFF_RUNNING))
			mc_init(sc);
#ifdef INET
		if (ifa->ifa_addr->sa_family == AF_INET)
			arp_ifinit(&sc->sc_arpcom, ifa);
#endif
		break;

	case SIOCSIFFLAGS:
		if ((ifp->if_flags & IFF_UP) == 0 &&
		    (ifp->if_flags & IFF_RUNNING) != 0) {
			/*
			 * If interface is marked down and it is running,
			 * then stop it.
			 */
			mc_stop(sc);
		} else if ((ifp->if_flags & IFF_UP) != 0 &&
		    (ifp->if_flags & IFF_RUNNING) == 0) {
			/*
			 * If interface is marked up and it is stopped,
			 * then start it.
			 */
			mc_init(sc);
		} else {
			/*
			 * reset the interface to pick up any other changes
			 * in flags
			 */
			mc_reset(sc);
			mc_start(ifp);
		}
		break;

	default:
		err = ether_ioctl(ifp, &sc->sc_arpcom, cmd, data);
	}

	if (err == ENETRESET) {
		if (ifp->if_flags & IFF_RUNNING)
			mc_reset(sc);
		err = 0;
	}

	splx(s);
	return (err);
}
コード例 #12
0
ファイル: xiltemac.c プロジェクト: AlexShiLucky/rtems
int xilTemacIoctl(struct ifnet* ifp, ioctl_command_t   aCommand, caddr_t aData)
{
  struct XilTemac* xilTemac = ifp->if_softc;
  int32_t error = 0;

  switch(aCommand) {
    case SIOCGIFADDR:
    case SIOCSIFADDR:
      ether_ioctl(ifp, aCommand, aData);
      break;

    case SIOCSIFFLAGS:
      switch(ifp->if_flags & (IFF_UP | IFF_RUNNING))
      {
        case IFF_RUNNING:
          xilTemacStop(ifp);
          break;

        case IFF_UP:
          xilTemacStart(ifp);
          break;

        case IFF_UP | IFF_RUNNING:
          xilTemacReset(ifp);
          break;

        default:
          break;
      }
      break;

    case SIOCADDMULTI:
    case SIOCDELMULTI: {
        struct ifreq* ifr = (struct ifreq*) aData;
        error = ((aCommand == SIOCADDMULTI) ?
                 ( ether_addmulti(ifr, &(xilTemac->iArpcom)) ) :
                 ( ether_delmulti(ifr, &(xilTemac->iArpcom)))
           );
        /* ENETRESET indicates that driver should update its multicast filters */
        if(error == ENETRESET)
        {
            error = xilTemacSetMulticastFilter( ifp );
        }
        break;
    }

    case SIO_RTEMS_SHOW_STATS:
      xilTemacPrintStats( ifp );
      break;

    default:
      error = EINVAL;
      break;
  }
  return error;
}
コード例 #13
0
ファイル: if_fwe.c プロジェクト: MarginC/kame
static int
fwe_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
{
	struct fwe_softc *fwe = ((struct fwe_eth_softc *)ifp->if_softc)->fwe;
	struct ifstat *ifs = NULL;
	int s, error, len;

	switch (cmd) {
		case SIOCSIFFLAGS:
			s = splimp();
			if (ifp->if_flags & IFF_UP) {
				if (!(ifp->if_flags & IFF_RUNNING))
					fwe_init(&fwe->eth_softc);
			} else {
				if (ifp->if_flags & IFF_RUNNING)
					fwe_stop(fwe);
			}
			/* XXX keep promiscoud mode */
			ifp->if_flags |= IFF_PROMISC;
			splx(s);
			break;
		case SIOCADDMULTI:
		case SIOCDELMULTI:
			break;

		case SIOCGIFSTATUS:
			s = splimp();
			ifs = (struct ifstat *)data;
			len = strlen(ifs->ascii);
			if (len < sizeof(ifs->ascii))
				snprintf(ifs->ascii + len,
					sizeof(ifs->ascii) - len,
					"\tch %d dma %d\n",
						fwe->stream_ch, fwe->dma_ch);
			splx(s);
			break;
#if __FreeBSD_version >= 500000
		default:
#else
		case SIOCSIFADDR:
		case SIOCGIFADDR:
		case SIOCSIFMTU:
#endif
			s = splimp();
			error = ether_ioctl(ifp, cmd, data);
			splx(s);
			return (error);
#if __FreeBSD_version < 500000
		default:
			return (EINVAL);
#endif
	}

	return (0);
}
コード例 #14
0
static int
virtif_ioctl(struct ifnet *ifp, u_long cmd, void *data)
{
	int s, rv;

	s = splnet();
	rv = ether_ioctl(ifp, cmd, data);
	splx(s);

	return rv;
}
コード例 #15
0
ファイル: if_ep.c プロジェクト: Gwenio/DragonFlyBSD
static int
ep_if_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data, struct ucred *cr)
{
	struct ep_softc *	sc = ifp->if_softc;
	struct ifreq *		ifr = (struct ifreq *)data;
	int error = 0;

	crit_enter();

	switch (cmd) {
	case SIOCSIFFLAGS:
		if (((ifp->if_flags & IFF_UP) == 0) &&
		    (ifp->if_flags & IFF_RUNNING)) {
			ifp->if_flags &= ~IFF_RUNNING;
			epstop(sc);
		} else {
			/* reinitialize card on any parameter change */
			ep_if_init(sc);
		}
		break;
#ifdef notdef
	case SIOCGHWADDR:
		bcopy((caddr_t) sc->sc_addr, (caddr_t) & ifr->ifr_data,
		      sizeof(sc->sc_addr));
		break;
#endif
	case SIOCADDMULTI:
	case SIOCDELMULTI:
		/*
		 * The Etherlink III has no programmable multicast
		 * filter.  We always initialize the card to be
		 * promiscuous to multicast, since we're always a
		 * member of the ALL-SYSTEMS group, so there's no
		 * need to process SIOC*MULTI requests.
		 */
		error = 0;
		break;
	case SIOCSIFMEDIA:
	case SIOCGIFMEDIA:
		if (!sc->epb.mii_trans) {
			error = ifmedia_ioctl(ifp, ifr, &sc->ifmedia, cmd);
		} else {
			error = EINVAL;
		}
		break;
	default:
		error = ether_ioctl(ifp, cmd, data);
		break;
	}

	crit_exit();

	return (error);
}
コード例 #16
0
ファイル: imxenet.c プロジェクト: appleorange1/bitrig
int
imxenet_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
{
	struct imxenet_softc *sc = ifp->if_softc;
	struct ifreq *ifr = (struct ifreq *)data;
	struct ifaddr *ifa = (struct ifaddr *)data;
	int s, error = 0;

	s = splnet();

	switch (cmd) {
	case SIOCSIFADDR:
		if (!(ifp->if_flags & IFF_UP)) {
			ifp->if_flags |= IFF_UP;
			imxenet_init(sc);
		}
#ifdef INET
		if (ifa->ifa_addr->sa_family == AF_INET)
			arp_ifinit(&sc->sc_ac, ifa);
#endif
		break;

	case SIOCSIFFLAGS:
		if (ifp->if_flags & IFF_UP) {
			if (ifp->if_flags & IFF_RUNNING)
				error = ENETRESET;
			else
				imxenet_init(sc);
		} else {
			if (ifp->if_flags & IFF_RUNNING)
				imxenet_stop(sc);
		}
		break;

	case SIOCGIFMEDIA:
	case SIOCSIFMEDIA:
		error = ifmedia_ioctl(ifp, ifr, &sc->sc_mii.mii_media, cmd);
		break;

	default:
		error = ether_ioctl(ifp, &sc->sc_ac, cmd, data);
	}

	if (error == ENETRESET) {
		if (ifp->if_flags & IFF_RUNNING)
			imxenet_iff(sc);
		error = 0;
	}

	splx(s);
	return(error);
}
コード例 #17
0
ファイル: if_de.c プロジェクト: avsm/openbsd-xen-sys
/*
 * Process an ioctl request.
 */
int
deioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
{
	int s, error = 0;

	s = splnet();

	error = ether_ioctl(ifp, cmd, data);
	if (error == ENETRESET)
		error = 0;

	splx(s);
	return (error);
}
コード例 #18
0
ファイル: if_eg.c プロジェクト: darksoul42/bitrig
int
egioctl(register struct ifnet *ifp, u_long cmd, caddr_t data)
{
	struct eg_softc *sc = ifp->if_softc;
	int s, error = 0;

	s = splnet();

	switch (cmd) {
	case SIOCSIFADDR:
		ifp->if_flags |= IFF_UP;
		eginit(sc);
		break;

	case SIOCSIFFLAGS:
		if ((ifp->if_flags & IFF_UP) == 0 &&
		    (ifp->if_flags & IFF_RUNNING) != 0) {
			/*
			 * If interface is marked down and it is running, then
			 * stop it.
			 */
			egstop(sc);
			ifp->if_flags &= ~IFF_RUNNING;
		} else if ((ifp->if_flags & IFF_UP) != 0 &&
			   (ifp->if_flags & IFF_RUNNING) == 0) {
			/*
			 * If interface is marked up and it is stopped, then
			 * start it.
			 */
			eginit(sc);
		} else {
			sc->eg_pcb[0] = EG_CMD_GETSTATS;
			sc->eg_pcb[1] = 0;
			if (egwritePCB(sc) != 0)
				DPRINTF(("write error\n"));
			/*
			 * XXX deal with flags changes:
			 * IFF_MULTICAST, IFF_PROMISC,
			 * IFF_LINK0, IFF_LINK1,
			 */
		}
		break;

	default:
		error = ether_ioctl(ifp, &sc->sc_arpcom, cmd, data);
	}

	splx(s);
	return (error);
}
コード例 #19
0
ファイル: if_ugl.c プロジェクト: appleorange1/bitrig
int
ugl_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
{
	struct ugl_softc	*sc = ifp->if_softc;
	struct ifaddr 		*ifa = (struct ifaddr *)data;
	int			s, error = 0;

	if (usbd_is_dying(sc->sc_udev))
		return (EIO);

	DPRINTFN(5,("%s: %s: cmd=0x%08lx\n",
		    sc->sc_dev.dv_xname, __func__, command));

	s = splnet();

	switch(command) {
	case SIOCSIFADDR:
		ifp->if_flags |= IFF_UP;
		if (!(ifp->if_flags & IFF_RUNNING))
			ugl_init(sc);
#ifdef INET
		if (ifa->ifa_addr->sa_family == AF_INET)
			arp_ifinit(&sc->sc_arpcom, ifa);
#endif
		break;

	case SIOCSIFFLAGS:
		if (ifp->if_flags & IFF_UP) {
			if (ifp->if_flags & IFF_RUNNING)
				error = ENETRESET;
			else
				ugl_init(sc);
		} else {
			if (ifp->if_flags & IFF_RUNNING)
				ugl_stop(sc);
		}
		break;

	default:
		error = ether_ioctl(ifp, &sc->sc_arpcom, command, data);
		break;
	}

	if (error == ENETRESET)
		error = 0;

	splx(s);
	return (error);
}
コード例 #20
0
ファイル: if_tsec.c プロジェクト: bradla/OpenBSD-Hammer2
int
tsec_ioctl(struct ifnet *ifp, u_long cmd, caddr_t addr)
{
	struct tsec_softc *sc = ifp->if_softc;
	struct ifaddr *ifa = (struct ifaddr *)addr;
	struct ifreq *ifr = (struct ifreq *)addr;
	int error = 0, s;

	s = splnet();

	switch (cmd) {
	case SIOCSIFADDR:
		ifp->if_flags |= IFF_UP;
#ifdef INET
		if (ifa->ifa_addr->sa_family == AF_INET)
			arp_ifinit(&sc->sc_ac, ifa);
#endif
		/* FALLTHROUGH */
	case SIOCSIFFLAGS:
		if (ifp->if_flags & IFF_UP) {
			if (ifp->if_flags & IFF_RUNNING)
				error = ENETRESET;
			else
				tsec_up(sc);
		} else {
			if (ifp->if_flags & IFF_RUNNING)
				tsec_down(sc);
		}
		break;

	case SIOCGIFMEDIA:
	case SIOCSIFMEDIA:
		error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
		break;

	default:
		error = ether_ioctl(ifp, &sc->sc_ac, cmd, addr);
		break;
	}

	if (error == ENETRESET) {
		if (ifp->if_flags & IFF_RUNNING)
			tsec_iff(sc);
		error = 0;
	}

	splx(s);
	return (error);
}
コード例 #21
0
static int
vhost_if_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
{
    struct ifreq *ifr;
    int error;

    ifr = (struct ifreq *)data;
    switch (cmd) {
    default:
        error = ether_ioctl(ifp, cmd, data);
        break;
    }

    return (error);
}
コード例 #22
0
ファイル: network.c プロジェクト: epicsdeb/rtems
/*  Driver ioctl handler */
static int
at91rm9200_emac_ioctl (struct ifnet *ifp, ioctl_command_t command, caddr_t data)
{
    at91rm9200_emac_softc_t *sc = ifp->if_softc;
    int error = 0;

    switch (command) {
    case SIOCGIFADDR:
    case SIOCSIFADDR:
        ether_ioctl (ifp, command, data);
        break;

    case SIOCSIFFLAGS:
        switch (ifp->if_flags & (IFF_UP | IFF_RUNNING))
        {
        case IFF_RUNNING:
            at91rm9200_emac_stop (sc);
            break;

        case IFF_UP:
            at91rm9200_emac_init (sc);
            break;

        case IFF_UP | IFF_RUNNING:
            at91rm9200_emac_stop (sc);
            at91rm9200_emac_init (sc);
            break;

        default:
            break;
        } /* switch (if_flags) */
        break;

    case SIO_RTEMS_SHOW_STATS:
        at91rm9200_emac_stats (sc);
        break;

        /*
         * FIXME: All sorts of multicast commands need to be added here!
         */
    default:
        error = EINVAL;
        break;
    } /* switch (command) */
    return error;
}
コード例 #23
0
ファイル: if_cpsw.c プロジェクト: orumin/openbsd-efivars
int
cpsw_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
{
	struct cpsw_softc *sc = ifp->if_softc;
	struct ifaddr *ifa = (struct ifaddr *)data;
	struct ifreq *ifr = (struct ifreq *)data;
	int s = splnet();
	int error = 0;

	switch (cmd) {
	case SIOCSIFADDR:
		ifp->if_flags |= IFF_UP;
		if (ifa->ifa_addr->sa_family == AF_INET)
			arp_ifinit(&sc->sc_ac, ifa);

	case SIOCSIFFLAGS:
		if (ifp->if_flags & IFF_UP) {
			if (ifp->if_flags & IFF_RUNNING)
				error = ENETRESET;
			else
				cpsw_init(ifp);
		} else {
			if (ifp->if_flags & IFF_RUNNING)
				cpsw_stop(ifp);
		}
		break;
	case SIOCSIFMEDIA:
		ifr->ifr_media &= ~IFM_ETH_FMASK;
		/* FALLTHROUGH */
	case SIOCGIFMEDIA:
		error = ifmedia_ioctl(ifp, ifr, &sc->sc_mii.mii_media, cmd);
		break;
	default:
		error = ether_ioctl(ifp, &sc->sc_ac, cmd, data);
		break;
	}
	if (error == ENETRESET) {
		if (ifp->if_flags & IFF_RUNNING)
			cpsw_init(ifp);
		error = 0;
	}

	splx(s);

	return error;
}
コード例 #24
0
ファイル: if_bce.c プロジェクト: eyberg/rumpkernel-netbsd-src
/* handle media, and ethernet requests */
static int
bce_ioctl(struct ifnet *ifp, u_long cmd, void *data)
{
	int		s, error;

	s = splnet();
	error = ether_ioctl(ifp, cmd, data);
	if (error == ENETRESET) {
		/* change multicast list */
		error = 0;
	}

	/* Try to get more packets going. */
	bce_start(ifp);

	splx(s);
	return error;
}
コード例 #25
0
ファイル: if_sq.c プロジェクト: MarginC/kame
int
sq_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
{
	int s, error = 0;

	s = splnet();

	error = ether_ioctl(ifp, cmd, data);
	if (error == ENETRESET) {
		/*
		 * Multicast list has changed; set the hardware filter
		 * accordingly.
		 */
		error = sq_init(ifp);
	}

	splx(s);
	return (error);
}
コード例 #26
0
int
cdcef_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
{
    struct cdcef_softc	*sc = ifp->if_softc;
    struct ifaddr		*ifa = (struct ifaddr *)data;
    int			 s, error = 0;

    s = splnet();

    switch (command) {
    case SIOCSIFADDR:
        ifp->if_flags |= IFF_UP;
        if (!(ifp->if_flags & IFF_RUNNING))
            cdcef_init(sc);
#ifdef INET
        if (ifa->ifa_addr->sa_family == AF_INET)
            arp_ifinit(&sc->sc_arpcom, ifa);
#endif
        break;

    case SIOCSIFFLAGS:
        if (ifp->if_flags & IFF_UP) {
            if (ifp->if_flags & IFF_RUNNING)
                error = ENETRESET;
            else
                cdcef_init(sc);
        } else {
            if (ifp->if_flags & IFF_RUNNING)
                cdcef_stop(sc);
        }
        break;

    default:
        error = ether_ioctl(ifp, &sc->sc_arpcom, command, data);
    }

    if (error == ENETRESET)
        error = 0;

    splx(s);
    return (error);
}
コード例 #27
0
ファイル: uinet_if_netmap.c プロジェクト: decland/libuinet
static int
if_netmap_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
{
	int error = 0;
	struct if_netmap_softc *sc = ifp->if_softc;

	switch (cmd) {
	case SIOCSIFFLAGS:
		if (ifp->if_flags & IFF_UP)
			if_netmap_init(sc);
		else if (ifp->if_drv_flags & IFF_DRV_RUNNING)
			if_netmap_stop(sc);
		break;
	default:
		error = ether_ioctl(ifp, cmd, data);
		break;
	}

	return (error);
}
コード例 #28
0
int
smap_ioctl(struct ifnet *ifp, u_long command, void *data)
{
	struct smap_softc *sc = ifp->if_softc;
	struct ifreq *ifr = (struct ifreq *) data;
	int error, s;

	s = splnet();

	error = ether_ioctl(ifp, command, data);

	if (error == ENETRESET) {
		if (ifp->if_flags & IFF_RUNNING)
			emac3_setmulti(&sc->emac3, &sc->ethercom);
		error = 0;
	}

	splx(s);

	return (error);
}
コード例 #29
0
/* driver ioctl handler */
static int ethernetIoctl(struct ifnet *ifp, ioctl_command_t command,
                         caddr_t data) {
  int result;
  struct bfin_ethernetSoftc *sc = ifp->if_softc;

  result = 0;
  switch (command) {
  case SIOCGIFADDR:
  case SIOCSIFADDR:
    ether_ioctl(ifp, command, data);
    break;
  case SIOCSIFFLAGS:
    switch (ifp->if_flags & (IFF_UP | IFF_RUNNING)) {
    case IFF_RUNNING:
      ethernetStop(sc);
      break;
    case IFF_UP:
      ethernetInit(sc);
      break;
    case IFF_UP | IFF_RUNNING:
      ethernetStop(sc);
      ethernetInit(sc);
      break;
    default:
      break;
    }
    break;
  case SIO_RTEMS_SHOW_STATS:
    bfin_ethernetStats(sc);
    break;
  case SIOCADDMULTI:
  case SIOCDELMULTI:
  default:
    result = EINVAL;
    break;
  }

  return result;
}
コード例 #30
0
ファイル: if_edsc.c プロジェクト: BillTheBest/libuinet
/*
 * Network interfaces are controlled via the ioctl(2) syscall.
 */
static int
edsc_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
{
	struct ifreq		*ifr = (struct ifreq *)data;

	switch (cmd) {
	case SIOCSIFCAP:
#if 1
		/*
		 * Just turn on any capabilities requested.
		 * The generic ifioctl() function has already made sure
		 * that they are supported, i.e., set in if_capabilities.
		 */
		ifp->if_capenable = ifr->ifr_reqcap;
#else
		/*
		 * A h/w driver would need to analyze the requested
		 * bits and program the hardware, e.g.:
		 */
		mask = ifp->if_capenable ^ ifr->ifr_reqcap;

		if (mask & IFCAP_VLAN_HWTAGGING) {
			ifp->if_capenable ^= IFCAP_VLAN_HWTAGGING;

			if (ifp->if_capenable & IFCAP_VLAN_HWTAGGING)
				/* blah-blah-blah */
			else
				/* etc-etc-etc */
		}
#endif
		break;

	default:
		/*
		 * Offload the rest onto the common Ethernet handler.
		 */
		return (ether_ioctl(ifp, cmd, data));
	}