Skip to content

networking: add network_intX_t types #1586

@Kijewski

Description

@Kijewski

OK, the idea may sound odd, but how about adding explicit types for integers in network byte-order?

#include <arpa/inet.h>

// X = 32

typedef struct network_uint32 {
    uint32 val;
} __attribute__((packed)) network_uint32_t;

static inline uint32_t ntoh32(network_uint32 v) {
     return ntohl(v.val);
}

static inline network_uint32_t hton32(uint32_t v) {
     network_uint32_t result;
     result.val = htonl(v);
     return result;
}

And using this type in the various structs?

Metadata

Metadata

Assignees

Labels

Area: networkArea: NetworkingDiscussion: RFCThe issue/PR is used as a discussion starting point about the item of the issue/PRImpact: majorThe PR changes a significant part of the code base. It should be reviewed carefully

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions