static int ppp_open(struct net_device *dev) { hdlc_device *hdlc = dev_to_hdlc(dev); int (*old_ioctl)(struct net_device *, struct ifreq *, int); int result; dev->ml_priv = &state(hdlc)->syncppp_ptr; state(hdlc)->syncppp_ptr = &state(hdlc)->pppdev; state(hdlc)->pppdev.dev = dev; old_ioctl = dev->do_ioctl; state(hdlc)->old_change_mtu = dev->change_mtu; sppp_attach(&state(hdlc)->pppdev); /* sppp_attach nukes them. We don't need syncppp's ioctl */ dev->do_ioctl = old_ioctl; state(hdlc)->pppdev.sppp.pp_flags &= ~PP_CISCO; dev->type = ARPHRD_PPP; result = sppp_open(dev); if (result) { sppp_detach(dev); return result; } return 0; }
static int syncppp_init(struct net_device *dev) { struct comx_channel *ch = dev->priv; struct ppp_device *pppdev = (struct ppp_device *)ch->if_ptr; ch->LINE_privdata = kmalloc(sizeof(struct syncppp_data), GFP_KERNEL); if (!ch->LINE_privdata) return -ENOMEM; pppdev->dev = dev; sppp_attach(pppdev); if(ch->protocol == &hdlc_protocol) { pppdev->sppp.pp_flags |= PP_CISCO; dev->type = ARPHRD_HDLC; } else { pppdev->sppp.pp_flags &= ~PP_CISCO; dev->type = ARPHRD_PPP; } ch->LINE_rx = sppp_input; ch->LINE_tx = syncppp_tx; ch->LINE_status = syncppp_status; ch->LINE_open = syncppp_open; ch->LINE_close = syncppp_close; ch->LINE_xmit = syncppp_xmit; ch->LINE_header = NULL; ch->LINE_statistics = syncppp_statistics; MOD_INC_USE_COUNT; return 0; }
static int ppp_open(hdlc_device *hdlc) { struct net_device *dev = hdlc_to_dev(hdlc); void *old_ioctl; int result; dev->priv = &hdlc->state.ppp.syncppp_ptr; hdlc->state.ppp.syncppp_ptr = &hdlc->state.ppp.pppdev; hdlc->state.ppp.pppdev.dev = dev; old_ioctl = dev->do_ioctl; hdlc->state.ppp.old_change_mtu = dev->change_mtu; sppp_attach(&hdlc->state.ppp.pppdev); /* sppp_attach nukes them. We don't need syncppp's ioctl */ dev->do_ioctl = old_ioctl; hdlc->state.ppp.pppdev.sppp.pp_flags &= ~PP_CISCO; dev->type = ARPHRD_PPP; result = sppp_open(dev); if (result) { sppp_detach(dev); return result; } return 0; }
int wanpipe_generic_register(sdla_t *card, struct ifnet *ifp, char *ifname) { wanpipe_common_t* common = WAN_IFP_TO_COMMON(ifp); if (ifname == NULL || strlen(ifname) > IFNAMSIZ) return (EINVAL); else bcopy(ifname, ifp->if_xname, strlen(ifname)); IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN); IFQ_SET_READY(&ifp->if_snd); ifp->if_mtu = PP_MTU; ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST; common->protocol = IF_PROTO_CISCO; ((struct sppp *)ifp)->pp_flags |= PP_CISCO; ((struct sppp *)ifp)->pp_flags |= PP_KEEPALIVE; ((struct sppp *)ifp)->pp_framebytes = 3; ifp->if_ioctl = wanpipe_generic_ioctl; /* Will set from new_if() */ ifp->if_start = wanpipe_generic_start; ifp->if_watchdog = wanpipe_generic_watchdog; if_attach(ifp); if_alloc_sadl(ifp); sppp_attach(ifp); #if NBPFILTER > 0 bpfattach(&ifp->if_bpf, ifp, DLT_PPP, PPP_HEADER_LEN); #endif /* NBPFILTER > 0 */ return (0); }
static int hdlc_open(struct device *dev) { hdlc_device *hdlc=dev_to_hdlc(dev); int result; if (hdlc->mode==MODE_NONE) return -ENOSYS; memset(&(hdlc->stats), 0, sizeof(struct net_device_stats)); if (mode_is(hdlc, MODE_FR | MODE_SOFT) || mode_is(hdlc, MODE_CISCO | MODE_SOFT)) fr_cisco_open(hdlc); else if (mode_is(hdlc, MODE_PPP | MODE_SOFT)) { sppp_attach(&hdlc->pppdev); /* sppp_attach nukes them. We don't need syncppp's ioctl */ /* Anyway, I'm going to replace it with ppp_synctty.c */ dev->do_ioctl = hdlc_ioctl; hdlc->pppdev.sppp.pp_flags&=~PP_CISCO; dev->type=ARPHRD_PPP; result = sppp_open(dev); if (result) { sppp_detach(dev); return result; } } result=hdlc->open(hdlc); if (result) { if (mode_is(hdlc, MODE_FR | MODE_SOFT) || mode_is(hdlc, MODE_CISCO | MODE_SOFT)) fr_cisco_close(hdlc); else if (mode_is(hdlc, MODE_PPP | MODE_SOFT)) { sppp_close(dev); sppp_detach(dev); dev->rebuild_header=NULL; dev->change_mtu=hdlc_change_mtu; dev->mtu=HDLC_MAX_MTU; dev->hard_header_len=16; } } return result; }
static int hdlc_open(struct net_device *dev) { hdlc_device *hdlc = dev_to_hdlc(dev); int result; if (hdlc->mode == MODE_NONE) return -ENOSYS; memset(&(hdlc->stats), 0, sizeof(struct net_device_stats)); if (mode_is(hdlc, MODE_FR | MODE_SOFT) || mode_is(hdlc, MODE_CISCO | MODE_SOFT)) fr_cisco_open(hdlc); #ifdef CONFIG_HDLC_PPP else if (mode_is(hdlc, MODE_PPP | MODE_SOFT)) { sppp_attach(&hdlc->pppdev); /* sppp_attach nukes them. We don't need syncppp's ioctl */ dev->do_ioctl = hdlc_ioctl; hdlc->pppdev.sppp.pp_flags &= ~PP_CISCO; dev->type = ARPHRD_PPP; result = sppp_open(dev); if (result) { sppp_detach(dev); return result; } } #endif #ifdef CONFIG_HDLC_X25 else if (mode_is(hdlc, MODE_X25)) { struct lapb_register_struct cb; cb.connect_confirmation = x25_connected; cb.connect_indication = x25_connected; cb.disconnect_confirmation = x25_disconnected; cb.disconnect_indication = x25_disconnected; cb.data_indication = x25_data_indication; cb.data_transmit = x25_data_transmit; result = lapb_register(hdlc, &cb); if (result != LAPB_OK) return result; } #endif result = hdlc->open(hdlc); if (result) { if (mode_is(hdlc, MODE_FR | MODE_SOFT) || mode_is(hdlc, MODE_CISCO | MODE_SOFT)) fr_cisco_close(hdlc); #ifdef CONFIG_HDLC_PPP else if (mode_is(hdlc, MODE_PPP | MODE_SOFT)) { sppp_close(dev); sppp_detach(dev); dev->rebuild_header = NULL; dev->change_mtu = hdlc_change_mtu; dev->mtu = HDLC_MAX_MTU; dev->hard_header_len = 16; } #endif #ifdef CONFIG_HDLC_X25 else if (mode_is(hdlc, MODE_X25)) lapb_unregister(hdlc); #endif } return result; }