hdlc.c (46686) | hdlc.c (47695) |
---|---|
1/* 2 * PPP High Level Link Control (HDLC) Module 3 * 4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp) 5 * 6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd. 7 * 8 * Redistribution and use in source and binary forms are permitted 9 * provided that the above copyright notice and this paragraph are 10 * duplicated in all such forms and that any documentation, 11 * advertising materials, and other materials related to such 12 * distribution and use acknowledge that the software was developed 13 * by the Internet Initiative Japan, Inc. The name of the 14 * IIJ may not be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 * | 1/* 2 * PPP High Level Link Control (HDLC) Module 3 * 4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp) 5 * 6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd. 7 * 8 * Redistribution and use in source and binary forms are permitted 9 * provided that the above copyright notice and this paragraph are 10 * duplicated in all such forms and that any documentation, 11 * advertising materials, and other materials related to such 12 * distribution and use acknowledge that the software was developed 13 * by the Internet Initiative Japan, Inc. The name of the 14 * IIJ may not be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 * |
20 * $Id: hdlc.c,v 1.41 1999/04/03 11:54:00 brian Exp $ | 20 * $Id: hdlc.c,v 1.42 1999/05/08 11:06:36 brian Exp $ |
21 * 22 * TODO: 23 */ 24#include <sys/param.h> 25#include <netinet/in.h> 26#include <netinet/in_systm.h> 27#include <netinet/ip.h> 28#include <sys/un.h> --- 124 unchanged lines hidden (view full) --- 153static struct mbuf * 154hdlc_LayerPush(struct bundle *bundle, struct link *l, struct mbuf *bp, 155 int pri, u_short *proto) 156{ 157 struct mbuf *last; 158 u_char *cp; 159 u_short fcs; 160 | 21 * 22 * TODO: 23 */ 24#include <sys/param.h> 25#include <netinet/in.h> 26#include <netinet/in_systm.h> 27#include <netinet/ip.h> 28#include <sys/un.h> --- 124 unchanged lines hidden (view full) --- 153static struct mbuf * 154hdlc_LayerPush(struct bundle *bundle, struct link *l, struct mbuf *bp, 155 int pri, u_short *proto) 156{ 157 struct mbuf *last; 158 u_char *cp; 159 u_short fcs; 160 |
161 mbuf_SetType(bp, MB_HDLCOUT); |
|
161 fcs = HdlcFcsBuf(INITFCS, bp); 162 fcs = ~fcs; 163 164 for (last = bp; last->next; last = last->next) 165 ; 166 167 if (last->size - last->offset - last->cnt >= 2) { 168 cp = MBUF_CTOP(last) + last->cnt; --- 170 unchanged lines hidden (view full) --- 339 340 len = mbuf_Length(bp); 341 if (len < 4) { /* rfc1662 section 4.3 */ 342 mbuf_Free(bp); 343 bp = NULL; 344 } 345 346 bp = mbuf_Truncate(bp, len - 2); /* discard the FCS */ | 162 fcs = HdlcFcsBuf(INITFCS, bp); 163 fcs = ~fcs; 164 165 for (last = bp; last->next; last = last->next) 166 ; 167 168 if (last->size - last->offset - last->cnt >= 2) { 169 cp = MBUF_CTOP(last) + last->cnt; --- 170 unchanged lines hidden (view full) --- 340 341 len = mbuf_Length(bp); 342 if (len < 4) { /* rfc1662 section 4.3 */ 343 mbuf_Free(bp); 344 bp = NULL; 345 } 346 347 bp = mbuf_Truncate(bp, len - 2); /* discard the FCS */ |
348 mbuf_SetType(bp, MB_HDLCIN); |
|
347 348 return bp; 349} 350 | 349 350 return bp; 351} 352 |
351/* 352 * Detect a HDLC frame 353 */ | 353/* Detect a HDLC frame */ |
354 355static const struct frameheader { 356 const u_char *data; 357 int len; 358} FrameHeaders[] = { 359 { "\176\377\003\300\041", 5 }, 360 { "\176\377\175\043\300\041", 6 }, 361 { "\176\177\175\043\100\041", 6 }, --- 84 unchanged lines hidden --- | 354 355static const struct frameheader { 356 const u_char *data; 357 int len; 358} FrameHeaders[] = { 359 { "\176\377\003\300\041", 5 }, 360 { "\176\377\175\043\300\041", 6 }, 361 { "\176\177\175\043\100\041", 6 }, --- 84 unchanged lines hidden --- |