static int comxlapb_xmit(struct sk_buff *skb, struct net_device *dev)
{
	struct comx_channel *ch = dev->priv;
	struct sk_buff *skb2;

	if (!dev || !(ch = dev->priv) || !(dev->flags & (IFF_UP | IFF_RUNNING))) {
		return -ENODEV;
	}

	if (dev->type == ARPHRD_X25) { // first byte tells what to do 
		switch(skb->data[0]) {
			case 0x00:	
				break;	// transmit
			case 0x01:	
				lapb_connect_request(ch);
				kfree_skb(skb);
				return 0;
			case 0x02:	
				lapb_disconnect_request(ch);
			default:
				kfree_skb(skb);
				return 0;
		}
		skb_pull(skb,1);
	}

	netif_stop_queue(dev);
	
	if ((skb2 = skb_clone(skb, GFP_ATOMIC)) != NULL) {
		lapb_data_request(ch, skb2);
	}

	return FRAME_ACCEPTED;
}
Beispiel #2
0
static int hdlc_xmit(struct sk_buff *skb, struct net_device *dev)
{
	hdlc_device *hdlc = dev_to_hdlc(dev);

#ifdef CONFIG_HDLC_X25
	if (mode_is(hdlc, MODE_X25 | MODE_SOFT)) {
		int result;


		/* X.25 to LAPB */
		switch (skb->data[0]) {
		case 0:		/* Data to be transmitted */
			skb_pull(skb, 1);
			if ((result = lapb_data_request(hdlc, skb)) != LAPB_OK)
				dev_kfree_skb(skb);
			return 0;

		case 1:
			if ((result = lapb_connect_request(hdlc))!= LAPB_OK) {
				if (result == LAPB_CONNECTED) {
				/* Send connect confirm. msg to level 3 */
					x25_connected(hdlc, 0);
				} else {
					printk(KERN_ERR "%s: LAPB connect "
					       "request failed, error code = "
					       "%i\n", hdlc_to_name(hdlc),
					       result);
				}
			}
			break;

		case 2:
			if ((result=lapb_disconnect_request(hdlc))!=LAPB_OK) {
				if (result == LAPB_NOTCONNECTED) {
				/* Send disconnect confirm. msg to level 3 */
					x25_disconnected(hdlc, 0);
				} else {
					printk(KERN_ERR "%s: LAPB disconnect "
					       "request failed, error code = "
					       "%i\n", hdlc_to_name(hdlc),
					       result);
				}
			}
			break;

		default:
			/* to be defined */
			break;
		}

		dev_kfree_skb(skb);
		return 0;
	} /* MODE_X25 */
#endif /* CONFIG_HDLC_X25 */

	return hdlc->xmit(hdlc, skb);
}
Beispiel #3
0
static netdev_tx_t x25_asy_xmit(struct sk_buff *skb,
				      struct net_device *dev)
{
	struct x25_asy *sl = netdev_priv(dev);
	int err;

	if (!netif_running(sl->dev)) {
		netdev_err(dev, "xmit call when iface is down\n");
		kfree_skb(skb);
		return NETDEV_TX_OK;
	}

	switch (skb->data[0]) {
	case X25_IFACE_DATA:
		break;
	case X25_IFACE_CONNECT: /* Connection request .. do nothing */
		err = lapb_connect_request(dev);
		if (err != LAPB_OK)
			netdev_err(dev, "lapb_connect_request error: %d\n",
				   err);
		kfree_skb(skb);
		return NETDEV_TX_OK;
	case X25_IFACE_DISCONNECT: /* do nothing - hang up ?? */
		err = lapb_disconnect_request(dev);
		if (err != LAPB_OK)
			netdev_err(dev, "lapb_disconnect_request error: %d\n",
				   err);
		/* fall through */
	default:
		kfree_skb(skb);
		return NETDEV_TX_OK;
	}
	skb_pull(skb, 1);	/* Remove control byte */
	/*
	 * If we are busy already- too bad.  We ought to be able
	 * to queue things at this point, to allow for a little
	 * frame buffer.  Oh well...
	 * -----------------------------------------------------
	 * I hate queues in X.25 driver. May be it's efficient,
	 * but for me latency is more important. ;)
	 * So, no queues !
	 *        14 Oct 1994  Dmitry Gorodchanin.
	 */

	err = lapb_data_request(dev, skb);
	if (err != LAPB_OK) {
		netdev_err(dev, "lapb_data_request error: %d\n", err);
		kfree_skb(skb);
		return NETDEV_TX_OK;
	}
	return NETDEV_TX_OK;
}
static netdev_tx_t x25_asy_xmit(struct sk_buff *skb,
				      struct net_device *dev)
{
	struct x25_asy *sl = netdev_priv(dev);
	int err;

	if (!netif_running(sl->dev)) {
		netdev_err(dev, "xmit call when iface is down\n");
		kfree_skb(skb);
		return NETDEV_TX_OK;
	}

	switch (skb->data[0]) {
	case X25_IFACE_DATA:
		break;
	case X25_IFACE_CONNECT: /*                                  */
		err = lapb_connect_request(dev);
		if (err != LAPB_OK)
			netdev_err(dev, "lapb_connect_request error: %d\n",
				   err);
		kfree_skb(skb);
		return NETDEV_TX_OK;
	case X25_IFACE_DISCONNECT: /*                         */
		err = lapb_disconnect_request(dev);
		if (err != LAPB_OK)
			netdev_err(dev, "lapb_disconnect_request error: %d\n",
				   err);
	default:
		kfree_skb(skb);
		return NETDEV_TX_OK;
	}
	skb_pull(skb, 1);	/*                     */
	/*
                                                         
                                                        
                             
                                                         
                                                        
                                            
                   
                                           
  */

	err = lapb_data_request(dev, skb);
	if (err != LAPB_OK) {
		netdev_err(dev, "lapb_data_request error: %d\n", err);
		kfree_skb(skb);
		return NETDEV_TX_OK;
	}
	return NETDEV_TX_OK;
}
Beispiel #5
0
static int x25_asy_xmit(struct sk_buff *skb, struct net_device *dev)
{
	struct x25_asy *sl = netdev_priv(dev);
	int err;

	if (!netif_running(sl->dev)) {
		printk(KERN_ERR "%s: xmit call when iface is down\n",
			dev->name);
		kfree_skb(skb);
		return 0;
	}

	switch (skb->data[0]) {
	case 0x00:
		break;
	case 0x01: /* Connection request .. do nothing */
		err = lapb_connect_request(dev);
		if (err != LAPB_OK)
			printk(KERN_ERR "x25_asy: lapb_connect_request error - %d\n", err);
		kfree_skb(skb);
		return 0;
	case 0x02: /* Disconnect request .. do nothing - hang up ?? */
		err = lapb_disconnect_request(dev);
		if (err != LAPB_OK)
			printk(KERN_ERR "x25_asy: lapb_disconnect_request error - %d\n", err);
	default:
		kfree_skb(skb);
		return  0;
	}
	skb_pull(skb, 1);	/* Remove control byte */
	/*
	 * If we are busy already- too bad.  We ought to be able
	 * to queue things at this point, to allow for a little
	 * frame buffer.  Oh well...
	 * -----------------------------------------------------
	 * I hate queues in X.25 driver. May be it's efficient,
	 * but for me latency is more important. ;)
	 * So, no queues !
	 *        14 Oct 1994  Dmitry Gorodchanin.
	 */

	err = lapb_data_request(dev, skb);
	if (err != LAPB_OK) {
		printk(KERN_ERR "x25_asy: lapb_data_request error - %d\n", err);
		kfree_skb(skb);
		return 0;
	}
	return 0;
}
Beispiel #6
0
/*
 * 	Send a LAPB frame via an ethernet interface
 */
static int lapbeth_xmit(struct sk_buff *skb, struct net_device *dev)
{
	struct lapbethdev *lapbeth;
	int err;
	
	lapbeth = (struct lapbethdev *)dev->priv;

	/*
	 * Just to be *really* sure not to send anything if the interface
	 * is down, the ethernet device may have gone.
	 */
	if (!netif_running(dev)) {
		lapbeth_check_devices(dev);
		kfree_skb(skb);
		return -ENODEV;
	}

	switch (skb->data[0]) {
		case 0x00:
			break;
		case 0x01:
			if ((err = lapb_connect_request(lapbeth)) != LAPB_OK)
				printk(KERN_ERR "lapbeth: lapb_connect_request error - %d\n", err);
			kfree_skb(skb);
			return 0;
		case 0x02:
			if ((err = lapb_disconnect_request(lapbeth)) != LAPB_OK)
				printk(KERN_ERR "lapbeth: lapb_disconnect_request err - %d\n", err);
			kfree_skb(skb);
			return 0;
		default:
			kfree_skb(skb);
			return 0;
	}

	skb_pull(skb, 1);

	if ((err = lapb_data_request(lapbeth, skb)) != LAPB_OK) {
		printk(KERN_ERR "lapbeth: lapb_data_request error - %d\n", err);
		kfree_skb(skb);
		return -ENOMEM;
	}

	return 0;
}
Beispiel #7
0
static netdev_tx_t x25_xmit(struct sk_buff *skb, struct net_device *dev)
{
	int result;


	/* X.25 to LAPB */
	switch (skb->data[0]) {
	case X25_IFACE_DATA:	/* Data to be transmitted */
		skb_pull(skb, 1);
		if ((result = lapb_data_request(dev, skb)) != LAPB_OK)
			dev_kfree_skb(skb);
		return NETDEV_TX_OK;

	case X25_IFACE_CONNECT:
		if ((result = lapb_connect_request(dev))!= LAPB_OK) {
			if (result == LAPB_CONNECTED)
				/* Send connect confirm. msg to level 3 */
				x25_connected(dev, 0);
			else
				printk(KERN_ERR "%s: LAPB connect request "
				       "failed, error code = %i\n",
				       dev->name, result);
		}
		break;

	case X25_IFACE_DISCONNECT:
		if ((result = lapb_disconnect_request(dev)) != LAPB_OK) {
			if (result == LAPB_NOTCONNECTED)
				/* Send disconnect confirm. msg to level 3 */
				x25_disconnected(dev, 0);
			else
				printk(KERN_ERR "%s: LAPB disconnect request "
				       "failed, error code = %i\n",
				       dev->name, result);
		}
		break;

	default:		/* to be defined */
		break;
	}

	dev_kfree_skb(skb);
	return NETDEV_TX_OK;
}