Example #1
0
class Response(schema.BinarySchema):
    vn = schema.MustEqual(schema.Bytes(1), b"\x00")
    rep = schema.SizedIntEnum(schema.uint8, Rep)
    dst_port = schema.uint16be
    dst_ip = schema.Convert(schema.Bytes(4),
                            encode=socket.inet_aton,
                            decode=socket.inet_ntoa)
Example #2
0
class ClientRequest(schema.BinarySchema):
    ver = schema.MustEqual(schema.uint8, 4)
    cmd = schema.SizedIntEnum(schema.uint8, Cmd)
    dst_port = schema.uint16be
    dst_ip = schema.Convert(schema.Bytes(4),
                            encode=socket.inet_aton,
                            decode=socket.inet_ntoa)
    user_id = schema.EndWith(b"\x00")
Example #3
0
 class Content(schema.BinarySchema):
     name = schema.MustEqual(schema.Bytes(3), b"abc")
     name2 = schema.LengthPrefixedObject(schema.uint8, schema.Bytes(1))