You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
455 B

  1. package ber
  2. import "io"
  3. func readByte(reader io.Reader) (byte, error) {
  4. bytes := make([]byte, 1, 1)
  5. _, err := io.ReadFull(reader, bytes)
  6. if err != nil {
  7. if err == io.EOF {
  8. return 0, io.ErrUnexpectedEOF
  9. }
  10. return 0, err
  11. }
  12. return bytes[0], nil
  13. }
  14. func isEOCPacket(p *Packet) bool {
  15. return p != nil &&
  16. p.Tag == TagEOC &&
  17. p.ClassType == ClassUniversal &&
  18. p.TagType == TypePrimitive &&
  19. len(p.ByteValue) == 0 &&
  20. len(p.Children) == 0
  21. }