[hipl-dev] Re: [Branch ~toxedvirus/hipl/options] Rev 5262: Added functions to convert between compressed (on the wire) format and uncompressed (internal) fo...

On Fri, Dec 17, 2010 at 03:20:52PM +0000, noreply@xxxxxxxxxxxxx wrote:
> ------------------------------------------------------------
> revno: 5262
> committer: Henrik Ziegeldorf <henrik.ziegeldorf@xxxxxxxxxxxxxx>
> branch nick: hipl
> timestamp: Wed 2010-12-08 19:30:17 +0100
> message:
>   Added functions to convert between compressed (on the wire) format and 
> uncompressed (internal) format of host identities.
>   
>   These two functions are needed to fix bug 612029. 
>   Internally host identities are handled within a struct that reserves place 
> for 4096 bit rsa keys and 64 byte hostnames.
>   For transmission on the wire unused space should not be sent thus we need 
> to compress the host identity before sending it as a message parameter on the 
> wire.
>   This is done by funciton hip_build_param_host_id.
>   
>   When receiving a message that contains a host_id parameter we need to 
> decompress it to the internal format. This is done my function 
> hip_build_host_id_from_param.

Nice and informative, thanks.

> --- lib/core/builder.c        2010-12-02 07:16:57 +0000
> +++ lib/core/builder.c        2010-12-08 18:30:17 +0000
> @@ -3138,6 +3138,72 @@
>  
>  /**
> + * Convert a host id parameter from its compressed on the wire format to
> + * the uncompressed internal format.
> + *
> + * @param param the host id parameter
> + * @param peer_host_id pointer to memory, where the uncompressed host id is 
> written to

ID

Vertical alignment of the parameter descriptions would make this more readable.

> +int hip_build_host_id_from_param(const struct hip_host_id *param, struct 
> hip_host_id *peer_host_id) {

> +int hip_build_param_host_id(struct hip_common *msg,
> +                            const struct hip_host_id *host_id) {

What can we do to make you remember K&R brace placement for
function declarations?

> +    // with the header we also copied the compressed length value, so 
> correct this
> +    hip_set_param_contents_len((struct hip_tlv_common *) peer_host_id,
> +                               sizeof(struct hip_host_id) - sizeof(struct 
> hip_tlv_common));

Time and again, the amount of casting being done in this project
makes me shiver.  Why can't you declare peer_host_id as struct
hip_tlv_common directly?

Diego

Other related posts: