[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Freeipmi-devel] libfreeipmi struct/pack(1) vs byte array

From: Anand Babu
Subject: [Freeipmi-devel] libfreeipmi struct/pack(1) vs byte array
Date: Fri, 05 Dec 2003 02:57:40 -0800
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux)

Started a new thread with new subject.

            |               Debate status               |
            |  ---------------------------------------  |
            |  "byte array" on the verge of winning :)  |

There are 2 different issues:
 (1) Byte Ordering (Endianess)
 (2) Byte Alignment

1) Byte Ordering (Endianess)
As long as we align RMCP data to BIG-ENDIAN and IPMI data to
LITTLE-ENDIAN, this will not pose a problem.

Byte ordering problem will happen only when the element is bigger than
a byte. We rarely use a double word element inside the structure. Most
of them are single byte or in bits. For the few elements we can have
macros to convert to the specified order.

2) Byte Alignment - Currently the biggest problem.

I understand, struct model is *insane* to use in a protocol

IPMI is different. The whole spec is carefully designed to be single
byte aligned. If you notice the reserved members, they are actually
structure pads used for alignment. They can also be used for future

typedef struct ipmi_cmd_get_channel_auth_caps_rs
  u_int8_t cmd;
  u_int8_t comp_code;
  struct {
    u_int8_t channel_num;
    struct {
      u_int8_t none:1;
      u_int8_t md2:1;
      u_int8_t md5:1;
      u_int8_t reserved1:1;
      u_int8_t straight_passwd_key:1;
      u_int8_t oem_prop:1;
      u_int8_t reserved2:2;
    } auth_type;
      u_int8_t anonymous_login:3;
      u_int8_t user_level_auth:1;
      u_int8_t per_message_auth:1;
      u_int8_t reserved3:3;
    } auth_status;
    u_int8_t reserved;
    u_int8_t oem_id[IPMI_OEM_ID_LEN];
    u_int8_t oem_aux;
  } data;
} ipmi_cmd_get_channel_auth_caps_rs_t;

But it is very clear, if we do not have a guaranteed mechanism to
align struct members to single byte, code breaks.

So Question is:
If not "#pragma pack(1)", don't we have a similar directive or a
compiler switch in other compilers that is guaranteed to do
single-byte-alignment ?

Using byte array is a definite approach which is guaranteed work for
all compilers and architectures.

I'm just waiting for your responses, to go ahead and make changes
to the code for byte array model.

Anand Babu
Office# +1-510-687-7045
Cell# +1-510-396-0717
Home# +1-510-894-0586

Free as in Freedom <>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]