(hdr)
| 508 | |
| 509 | |
| 510 | def header_to_binary(hdr): |
| 511 | b = [] |
| 512 | b.append(struct.pack("<3ss", hdr.MessageType, hdr.ChunkType)) |
| 513 | size = hdr.body_size + 8 |
| 514 | if hdr.MessageType in (ua.MessageType.SecureOpen, ua.MessageType.SecureClose, ua.MessageType.SecureMessage): |
| 515 | size += 4 |
| 516 | b.append(Primitives.UInt32.pack(size)) |
| 517 | if hdr.MessageType in (ua.MessageType.SecureOpen, ua.MessageType.SecureClose, ua.MessageType.SecureMessage): |
| 518 | b.append(Primitives.UInt32.pack(hdr.ChannelId)) |
| 519 | return b"".join(b) |
| 520 | |
| 521 | |
| 522 | def header_from_binary(data): |
no test coverage detected