hdlc.c (102500) | hdlc.c (131327) |
---|---|
1/*- 2 * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org> 3 * based on work by Toshiharu OHNO <tony-o@iij.ad.jp> 4 * Internet Initiative Japan, Inc (IIJ) 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 11 unchanged lines hidden (view full) --- 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * | 1/*- 2 * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org> 3 * based on work by Toshiharu OHNO <tony-o@iij.ad.jp> 4 * Internet Initiative Japan, Inc (IIJ) 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 11 unchanged lines hidden (view full) --- 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * |
28 * $FreeBSD: head/usr.sbin/ppp/hdlc.c 102500 2002-08-27 20:11:58Z brian $ | 28 * $FreeBSD: head/usr.sbin/ppp/hdlc.c 131327 2004-06-30 12:24:56Z brian $ |
29 */ 30 31#include <sys/param.h> 32#include <sys/un.h> 33 34#include <stdarg.h> 35#include <stdio.h> 36#include <string.h> --- 276 unchanged lines hidden (view full) --- 313 314 if (!p) { 315 log_Printf(LogERROR, "Can't Pull a hdlc packet from a logical link\n"); 316 return bp; 317 } 318 319 log_DumpBp(LogHDLC, "hdlc_LayerPull:", bp); 320 | 29 */ 30 31#include <sys/param.h> 32#include <sys/un.h> 33 34#include <stdarg.h> 35#include <stdio.h> 36#include <string.h> --- 276 unchanged lines hidden (view full) --- 313 314 if (!p) { 315 log_Printf(LogERROR, "Can't Pull a hdlc packet from a logical link\n"); 316 return bp; 317 } 318 319 log_DumpBp(LogHDLC, "hdlc_LayerPull:", bp); 320 |
321 fcs = hdlc_Fcs(MBUF_CTOP(bp), bp->m_len); | 321 bp = m_pullup(bp); 322 len = m_length(bp); 323 fcs = hdlc_Fcs(MBUF_CTOP(bp), len); |
322 323 log_Printf(LogDEBUG, "%s: hdlc_LayerPull: fcs = %04x (%s)\n", 324 p->link.name, fcs, (fcs == GOODFCS) ? "good" : "BAD!"); 325 | 324 325 log_Printf(LogDEBUG, "%s: hdlc_LayerPull: fcs = %04x (%s)\n", 326 p->link.name, fcs, (fcs == GOODFCS) ? "good" : "BAD!"); 327 |
328 p->hdlc.lqm.ifInOctets += len + 1; /* plus 1 flag octet! */ 329 |
|
326 if (fcs != GOODFCS) { | 330 if (fcs != GOODFCS) { |
327 p->hdlc.lqm.SaveInErrors++; | 331 p->hdlc.lqm.ifInErrors++; |
328 p->hdlc.stats.badfcs++; 329 m_freem(bp); 330 return NULL; 331 } 332 | 332 p->hdlc.stats.badfcs++; 333 m_freem(bp); 334 return NULL; 335 } 336 |
333 p->hdlc.lqm.SaveInOctets += bp->m_len + 1; 334 p->hdlc.lqm.SaveInPackets++; | 337 /* Either done here or by the sync layer */ 338 p->hdlc.lqm.lqr.InGoodOctets += len + 1; /* plus 1 flag octet! */ 339 p->hdlc.lqm.ifInUniPackets++; |
335 | 340 |
336 len = m_length(bp); | |
337 if (len < 4) { /* rfc1662 section 4.3 */ 338 m_freem(bp); 339 bp = NULL; 340 } 341 342 bp = m_adj(bp, -2); /* discard the FCS */ 343 m_settype(bp, MB_HDLCIN); 344 --- 96 unchanged lines hidden --- | 341 if (len < 4) { /* rfc1662 section 4.3 */ 342 m_freem(bp); 343 bp = NULL; 344 } 345 346 bp = m_adj(bp, -2); /* discard the FCS */ 347 m_settype(bp, MB_HDLCIN); 348 --- 96 unchanged lines hidden --- |