zaninime/go-hdlc

Do not escape/remove octet with value less than 0x20 if not flagged in ACCM

Closed this issue · 1 comments

Relevant code

  • decoder.go, L61:

    } else if b < 0x20 {
      // skip byte introduced by DCE
    }
  • encoder.go, L65

    if (b) < 0x20 || ((b)&0x7f) == 0x7d || ((b)&0x7f) == 0x7e {
      // ...
    }

Relevant Documentation

  • RFC 1662, section 4.2 Transparency:

    After FCS computation, the transmitter examines the entire frame
    between the two Flag Sequences. Each Flag Sequence, Control Escape
    octet, and any octet which is flagged in the sending Async-Control-
    Character-Map (ACCM)
    , is replaced by a two octet sequence consisting
    of the Control Escape octet followed by the original octet
    exclusive-or'd with hexadecimal 0x20.

    On reception, prior to FCS computation, each octet with value less
    than hexadecimal 0x20 is checked. If it is flagged in the receiving
    ACCM, it is simply removed
    (it may have been inserted by intervening
    data communications equipment). Each Control Escape octet is also
    removed, and the following octet is exclusive-or'd with hexadecimal
    0x20, unless it is the Flag Sequence (which aborts a frame).

  • pppd man page:

    If no asyncmap option is given, the default is zero, so pppd will ask the peer not to escape any control characters.

Thanks for opening this issue. I think this would be easily solvable by adding the ACCM flag in the encoder / decoder structs, and alter the behaviour based on it.

I currently don't have time to maintain this project, however I am more than happy to review and merge any incoming PRs.