I’m trying to write an interface for communicating with a network protocol, but the IEEE document describes the protocol at the bit level with information split accross a single byte.
What would be the best way to go about handling a C typedef such as
typedef struct {
Nibble transportSpecific;
Enumeration4 messageType;
UInteger4 versionPTP;
UInteger16 messageLength;
UInteger8 domainNumber;
Octet flagField[2];
Integer64 correctionfield;
PortIdentity sourcePortIdentity;
UInteger16 sequenceId;
UInteger8 controlField;
Integer8 logMessageInterval;
} MsgHeader;
when porting a compatibility layer to .Net?
FieldOffsetAttribute may be of help to you, although there is no way to represent values smaller than a byte.
I would use a byte to represent the two values for interop purposes, and then access the value via property getters.