 i++;				/* Skip length field */  reptype = skb->data[i++];  if (skb->data[i]!= ((hdlc->state.fr.settings.lmi == LMI_CCITT) ? LMI_CCITT_ALIVE : LMI_ALIVE)) { printk(KERN_INFO "%s: Unsupported status element=%x\n", dev->name, skb->data[i]); return 1; } i++;  i++;			/* Skip length field */ 
static int fr_lmi_recv(struct net_device *dev, struct sk_buff *skb){	hdlc_device *hdlc = dev_to_hdlc(dev);	int stat_len;	pvc_device *pvc;	int reptype = -1, error, no_ram;	u8 rxseq, txseq;	int i;	if (skb->len < ((hdlc->state.fr.settings.lmi == LMI_ANSI)			? LMI_ANSI_LENGTH : LMI_LENGTH)) {		printk(KERN_INFO "%s: Short LMI frame\n", dev->name);		return 1;	}	if (skb->data[5] != (!hdlc->state.fr.settings.dce ?			     LMI_STATUS : LMI_STATUS_ENQUIRY)) {		printk(KERN_INFO "%s: LMI msgtype=%x, Not LMI status %s\n",		       dev->name, skb->data[2],		       hdlc->state.fr.settings.dce ? "enquiry" : "reply");		return 1;	}	i = (hdlc->state.fr.settings.lmi == LMI_ANSI) ? 7 : 6;	if (skb->data[i] !=	    ((hdlc->state.fr.settings.lmi == LMI_CCITT)	     ? LMI_CCITT_REPTYPE : LMI_REPTYPE)) {		printk(KERN_INFO "%s: Not a report type=%x\n",		       dev->name, skb->data[i]);		return 1;	}	i++;	i++;				/* Skip length field */	reptype = skb->data[i++];	if (skb->data[i]!=	    ((hdlc->state.fr.settings.lmi == LMI_CCITT)	     ? LMI_CCITT_ALIVE : LMI_ALIVE)) {		printk(KERN_INFO "%s: Unsupported status element=%x\n",		       dev->name, skb->data[i]);		return 1;	}	i++;	i++;			/* Skip length field */	hdlc->state.fr.rxseq = skb->data[i++]; /* TX sequence from peer */	rxseq = skb->data[i++];	/* Should confirm our sequence */	txseq = hdlc->state.fr.txseq;	if (hdlc->state.fr.settings.dce) {		if (reptype != LMI_FULLREP && reptype != LMI_INTEGRITY) {			printk(KERN_INFO "%s: Unsupported report type=%x\n",			       dev->name, reptype);			return 1;		}		hdlc->state.fr.last_poll = jiffies;	}	error = 0;	if (!hdlc->state.fr.reliable)		error = 1;	if (rxseq == 0 || rxseq != txseq) {		hdlc->state.fr.n391cnt = 0; /* Ask for full report next time */		error = 1;	}	if (hdlc->state.fr.settings.dce) {		if (hdlc->state.fr.fullrep_sent && !error) {/* Stop sending full report - the last one has been confirmed by DTE */			hdlc->state.fr.fullrep_sent = 0;			pvc = hdlc->state.fr.first_pvc;			while (pvc) {				if (pvc->state.new) {					pvc->state.new = 0;/* Tell DTE that new PVC is now active */					hdlc->state.fr.dce_changed = 1;				}				pvc = pvc->next;			}		}		if (hdlc->state.fr.dce_changed) {			reptype = LMI_FULLREP;			hdlc->state.fr.fullrep_sent = 1;			hdlc->state.fr.dce_changed = 0;		}		fr_lmi_send(dev, reptype == LMI_FULLREP ? 1 : 0);		return 0;	}	/* DTE */	hdlc->state.fr.request = 0; /* got response, no request pending */	if (error)		return 0;	if (reptype != LMI_FULLREP)		return 0;	stat_len = 3;	pvc = hdlc->state.fr.first_pvc;	while (pvc) {		pvc->state.deleted = 1;		pvc = pvc->next;	}	no_ram = 0;	while (skb->len >= i + 2 + stat_len) {		u16 dlci;		unsigned int active, new;		if (skb->data[i] != ((hdlc->state.fr.settings.lmi == LMI_CCITT)				     ? LMI_CCITT_PVCSTAT : LMI_PVCSTAT)) {			printk(KERN_WARNING "%s: Invalid PVCSTAT ID: %x\n",			       dev->name, skb->data[i]);			return 1;		}		i++;		if (skb->data[i] != stat_len) {			printk(KERN_WARNING "%s: Invalid PVCSTAT length: %x\n",			       dev->name, skb->data[i]);			return 1;		}		i++;		dlci = status_to_dlci(skb->data + i, &active, &new);		pvc = add_pvc(dev, dlci);		if (!pvc && !no_ram) {			printk(KERN_WARNING			       "%s: Memory squeeze on fr_lmi_recv()\n",			       dev->name);			no_ram = 1;		}		if (pvc) {			pvc->state.exist = 1;			pvc->state.deleted = 0;			if (active != pvc->state.active ||			    new != pvc->state.new ||			    !pvc->state.exist) {				pvc->state.new = new;				pvc->state.active = active;				pvc_carrier(active, pvc);				fr_log_dlci_active(pvc);			}		}		i += stat_len;	}	pvc = hdlc->state.fr.first_pvc;	while (pvc) {		if (pvc->state.deleted && pvc->state.exist) {			pvc_carrier(0, pvc);			pvc->state.active = pvc->state.new = 0;			pvc->state.exist = 0;			fr_log_dlci_active(pvc);		}		pvc = pvc->next;	}	/* Next full report after N391 polls */	hdlc->state.fr.n391cnt = hdlc->state.fr.settings.n391;	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/b3dd65f958354226275522b5a64157834bdc5415/hdlc_fr.c/clean/drivers/net/wan/hdlc_fr.c