hdlcsync: Suppress 0x55 and 0xAA and duplicate Flag

This commit is contained in:
Harald Welte 2011-02-09 12:02:50 +01:00
parent c8441065cd
commit ef8d16bcb3
1 changed files with 12 additions and 4 deletions

View File

@ -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;
}
}
}