Example #1
0
static void x25_asy_bump(struct x25_asy *sl)
{
	struct net_device *dev = sl->dev;
	struct sk_buff *skb;
	int count;
	int err;

	count = sl->rcount;
	dev->stats.rx_bytes += count;

	skb = dev_alloc_skb(count+1);
	if (skb == NULL) {
		netdev_warn(sl->dev, "memory squeeze, dropping packet\n");
		dev->stats.rx_dropped++;
		return;
	}
	skb_push(skb, 1);	/* LAPB internal control */
	skb_put_data(skb, sl->rbuff, count);
	skb->protocol = x25_type_trans(skb, sl->dev);
	err = lapb_data_received(skb->dev, skb);
	if (err != LAPB_OK) {
		kfree_skb(skb);
		printk(KERN_DEBUG "x25_asy: data received err - %d\n", err);
	} else {
		netif_rx(skb);
		dev->stats.rx_packets++;
	}
}
Example #2
0
static void x25_asy_bump(struct x25_asy *sl)
{
	struct sk_buff *skb;
	int count;
	int err;

	count = sl->rcount;
	sl->stats.rx_bytes+=count;
	
	skb = dev_alloc_skb(count+1);
	if (skb == NULL)  
	{
		printk("%s: memory squeeze, dropping packet.\n", sl->dev->name);
		sl->stats.rx_dropped++;
		return;
	}
	skb_push(skb,1);	/* LAPB internal control */
	memcpy(skb_put(skb,count), sl->rbuff, count);
	skb->protocol = x25_type_trans(skb, sl->dev);
	if((err=lapb_data_received(skb->dev, skb))!=LAPB_OK)
	{
		kfree_skb(skb);
		printk(KERN_DEBUG "x25_asy: data received err - %d\n",err);
	}
	else
	{
		netif_rx(skb);
		sl->dev->last_rx = jiffies;
		sl->stats.rx_packets++;
	}
}
Example #3
0
/*
 *	Receive a LAPB frame via an ethernet interface.
 */
static int lapbeth_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *ptype)
{
	int len, err;
	struct lapbethdev *lapbeth;

	skb->sk = NULL;		/* Initially we don't know who it's for */
	
	dev = lapbeth_get_x25_dev(dev);

	if (dev == NULL || !netif_running(dev)) {
		kfree_skb(skb);
		return 0;
	}

	lapbeth = (struct lapbethdev *)dev->priv;

	lapbeth->stats.rx_packets++;

	len = skb->data[0] + skb->data[1] * 256;

	skb_pull(skb, 2);	/* Remove the length bytes */
	skb_trim(skb, len);	/* Set the length of the data */

	if ((err = lapb_data_received(lapbeth, skb)) != LAPB_OK) {
		kfree_skb(skb);
		printk(KERN_DEBUG "lapbether: lapb_data_received err - %d\n", err);
	}

	return 0;
}
static void comxlapb_rx(struct net_device *dev, struct sk_buff *skb) 
{
	if (!dev || !dev->priv) {
		dev_kfree_skb(skb);
	} else {
		lapb_data_received(dev->priv, skb);
	}
}
Example #5
0
static int x25_rx(struct sk_buff *skb)
{
	struct net_device *dev = skb->dev;

	if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL) {
		dev->stats.rx_dropped++;
		return NET_RX_DROP;
	}

	if (lapb_data_received(dev, skb) == LAPB_OK)
		return NET_RX_SUCCESS;

	dev->stats.rx_errors++;
	dev_kfree_skb_any(skb);
	return NET_RX_DROP;
}
Example #6
0
void hdlc_netif_rx(hdlc_device *hdlc, struct sk_buff *skb)
{
/* skb contains raw HDLC frame, in both hard- and software modes */
	skb->mac.raw = skb->data;

	switch(hdlc->mode & MODE_MASK) {
	case MODE_HDLC:
		skb->protocol = htons(ETH_P_IP);
		skb->dev = hdlc_to_dev(hdlc);
		netif_rx(skb);
		return;

	case MODE_FR:
		fr_netif(hdlc, skb);
		return;

	case MODE_CISCO:
		cisco_netif(hdlc, skb);
		return;

#ifdef CONFIG_HDLC_PPP
	case MODE_PPP:
#if 0
		sppp_input(hdlc_to_dev(hdlc), skb);
#else
		skb->protocol = htons(ETH_P_WAN_PPP);
		skb->dev = hdlc_to_dev(hdlc);
		netif_rx(skb);
#endif
		return;
#endif
#ifdef CONFIG_HDLC_X25
	case MODE_X25:
		skb->dev = hdlc_to_dev(hdlc);
		if (lapb_data_received(hdlc, skb) == LAPB_OK)
			return;
		break;
#endif
	}

	hdlc->stats.rx_errors++;
	dev_kfree_skb_any(skb);
}
Example #7
0
void new_data_received(char * data, int data_size) {
	int i = 0;
	_ushort * rcv_fcs;

	//hex_dump(data, data_size);

	if (AutomaticMode) {
		while (i < data_size) {
			if (data[i] == 0x7E) { /* Flag */
				if (data[i + 1] == 0x7E) {
					if (data_block) { /* Close flag */
						data_block = FALSE;
						block_size -= 2; /* 2 bytes for FCS */
						rcv_fcs = (_ushort *)&in_buffer[block_size];
						//lapb_debug(NULL, 0, "[PHYS_CB] data_received is called(%d bytes)", block_size);
						lapb_data_received(lapb_server, in_buffer, block_size, *rcv_fcs);
					} else {
						/* Open flag */
						bzero(in_buffer, 1024);
						block_size = 0;
						data_block = TRUE;
					};
					i += 2;
					continue;
				} else {
					if (data_block) {
						in_buffer[block_size] = data[i];
						block_size++;
					} else {
						lapb_debug(0, "[PHYS_CB] data error");
						break;
					};
				}

				i++;
			} else if (data_block) {
				in_buffer[block_size] = data[i];
				block_size++;
				i++;
			};
		};
	} else {
		printf("\nData received:");

		//bzero(buffer, 1024);
		while (i < data_size) {
			if (data[i] == 0x7E) { /* Flag */
				if (data_block) { /* Close flag */
					manual_received(in_buffer, block_size);
					data_block = FALSE;
					i++;
					continue;
				};
				/* Open flag */
				data_block = TRUE;
				bzero(in_buffer, 1024);
				block_size = 0;
				i++;
				continue;
			};
			if (data_block) {
				in_buffer[block_size] = data[i];
				block_size++;
			};
			i++;
		};


		printf("\n\n");
		print_man_commands();
	};
}