From ef8d16bcb3dfc3f6d919aba7adeac5090a839c9f Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Wed, 9 Feb 2011 12:02:50 +0100 Subject: [PATCH] hdlcsync: Suppress 0x55 and 0xAA and duplicate Flag --- hdlc/hdlcsync.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/hdlc/hdlcsync.c b/hdlc/hdlcsync.c index ff236ea..f33f53f 100644 --- a/hdlc/hdlcsync.c +++ b/hdlc/hdlcsync.c @@ -102,13 +102,21 @@ static int process_raw_hdlc(struct hdlc_proc *hdlc, uint8_t *data, unsigned int { unsigned int i; int out; + static int last_out; for (i = 0; i < len; i ++) { out = process_hdlc_bit(hdlc, data[i]); - if (out == -123) - printf("F "); - else if (out >= 0) - printf("%02x ", out); + if (out == -123) { + /* suppress repeating Flag characters */ + if (last_out != out) + printf("\nF "); + last_out = out; + } else if (out >= 0) { + /* suppress 0xAA and 0x55 bit pattern */ + if (out != 0xaa && out != 0x55) + printf("%02x ", out); + last_out = out; + } } }