teknoraver icon

scalar_storage_order

teknoraver | PRO | 07/10/24 12:45:56 AM UTC (Edited) | 0 ⭐ | 13937 👁️ | Never ⏰ | []
C |

460 B

|

None

|

0 👍

/

0 👎

#include <stdint.h>
#include <stdio.h>
#include <string.h>
 
#define __sso_be __attribute__((scalar_storage_order("big-endian")))
 
struct __sso_be ipv6hdr {
uint32_t
    version:4,
    tos:8,
    flow_lbl:20;
};
 
int main()
{
    struct ipv6hdr hdr;
 
    memcpy(&hdr, "\x60\x01\x23\x45", 4);
 
    printf("size:   %ld\n\n", sizeof(hdr));
 
    printf("version:    %x\n", hdr.version);
    printf("tos:        %x\n", hdr.tos);
    printf("flow_lbl:   %x\n\n", hdr.flow_lbl);
 
    return 0;
}
 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎