-
Notifications
You must be signed in to change notification settings - Fork 2.1k
networking: add network_intX_t types #1586
Copy link
Copy link
Closed
Labels
Area: networkArea: NetworkingArea: NetworkingDiscussion: RFCThe issue/PR is used as a discussion starting point about the item of the issue/PRThe 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 carefullyThe PR changes a significant part of the code base. It should be reviewed carefully
Milestone
Description
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?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Area: networkArea: NetworkingArea: NetworkingDiscussion: RFCThe issue/PR is used as a discussion starting point about the item of the issue/PRThe 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 carefullyThe PR changes a significant part of the code base. It should be reviewed carefully