CDP builder

David Barroso <[email protected]> Wed, 16 Jun 2004 22:32:19 +0200
Newsgroups gmane.comp.security.libnet
Message-ID <20040616203219.GA24302@moskovskaya>
Hi all,
I've been reviewing the CDP builder code, and I have noticed some issues 
that perhaps should be changed (mostly in order to have the checksum bug solved):

- The CDP header struct is the following:

struct libnet_cdp_hdr
{
    u_int8_t cdp_version;     /* version (should always be 0x01) */
    u_int8_t cdp_ttl;         /* time reciever should hold info in this packet */
    u_int16_t cdp_sum;        /* checksum */
    u_int16_t cdp_type;       /* type */
    u_int16_t cdp_len;        /* type + length + value */
}

Wouldn't be better, since there can be any tlv (type, length, value) tuples, leave only the 
version, ttl and sum fields in the cdp header, and a (u_char *) pointer
pointing to the beginning of the tuples, or having another builder (like
the libnet_build_cdp_value) for adding them as data?

The problem I've encountered when trying to fix the checksum issue, is
that I don't have a clear picture if there should be one pblock for
each tuple, one pblock for all the tuples (ala ip/tcp options) or
perhaps the tuples should be included in the same pblock as the header
(very unlikely since we do not know how many tuples exist and therefore
we probably won't have enough memory in our buffer).

Looking at the IP and TCP options builder, I'm not pretty sure if they
are included when computing the global checksum (as far as I know the ip
options are included in the ip header and they should be including when
doing the checksum), but, could we follow the same approach with the CDP
tuples and then compute the checksum of the two pblock's buffers?