[erlang-questions] {packet, PacketType} for little-signed packets

Pablo Platt pablo.platt@REDACTED
Wed Jun 9 14:44:58 CEST 2010


I think I somehow need to add BSON to the {packet, PacketType} options
and then add a case similar to asn1 http://github.com/erlang/otp/blob/dev/erts/emulator/beam/packet_parser.c#L326
Any ideas how to add BSON to the list of options and what code should be in the case TCP_PB_BSON ?

case TCP_PB_ASN1: {
    /* TCP_PB_ASN1: handles long (4 bytes) or short length format */
    const char* tptr = ptr;
    int length;
    int nn = n;
    
    if (n < 2) goto more;
    nn--;
    if ((*tptr++ & 0x1f) == 0x1f) { /* Long tag format */
        while (nn && ((*tptr & 0x80) == 0x80)) {
            tptr++;
            nn--;
        }
        if (nn < 2) goto more;
        tptr++;
        nn--;
    }
    
    /* tptr now point to length field and nn characters remain */
    length = *tptr & 0x7f;
    if ((*tptr & 0x80) == 0x80) { /* Long length format */
        tptr++;
        nn--;
        if (nn < length) goto more;
        switch (length) {
        case 0: plen = 0; break;
        case 1: plen = get_int8(tptr); tptr += 1; break;
        case 2: plen = get_int16(tptr); tptr += 2; break;
        case 3: plen = get_int24(tptr); tptr += 3; break;
        case 4: plen = get_int32(tptr); tptr += 4; break;
        default: goto error; /* error */
        }
    }
    else {
        tptr++;
        plen = length;
    }
    hlen = (tptr-ptr);
    goto remain;
} 





________________________________
From: Jachym Holecek <freza@REDACTED>
To: Pablo Platt <pablo.platt@REDACTED>
Sent: Wed, June 9, 2010 12:48:12 AM
Subject: Re: [erlang-questions] {packet, PacketType} for little-signed packets

Hello,

# Pablo Platt 2010-06-08:
> {packet, ...} will be much faster, reduce the code and possible errors.
> If someone can point me to what file need to be patched I can try to do it myself.

These seem like good places to start:

  erts/emulator/beam/packet_parser.c
  erts/emulator/drivers/common/inet_drv.c

> Subject: Re: [erlang-questions] {packet, PacketType} for little-signed packets
                                                                  ^^^^^^
Huh? Are they seriously using signed integers for message length?

Have fun,
    -- Jachym



      


More information about the erlang-questions mailing list