krb5_ser_pack_int32(krb5_int32 iarg, krb5_octet **bufp, size_t *remainp)
{
if (*remainp >= sizeof(krb5_int32)) {
- (*bufp)[0] = (krb5_octet) ((iarg >> 24) & 0xff);
- (*bufp)[1] = (krb5_octet) ((iarg >> 16) & 0xff);
- (*bufp)[2] = (krb5_octet) ((iarg >> 8) & 0xff);
- (*bufp)[3] = (krb5_octet) (iarg & 0xff);
+ store_32_be(iarg, *bufp);
*bufp += sizeof(krb5_int32);
*remainp -= sizeof(krb5_int32);
return(0);
krb5_ser_unpack_int32(krb5_int32 *intp, krb5_octet **bufp, size_t *remainp)
{
if (*remainp >= sizeof(krb5_int32)) {
- *intp = (((krb5_int32) ((unsigned char) (*bufp)[0]) << 24) |
- ((krb5_int32) ((unsigned char) (*bufp)[1]) << 16) |
- ((krb5_int32) ((unsigned char) (*bufp)[2]) << 8) |
- ((krb5_int32) ((unsigned char) (*bufp)[3])));
+ *intp = load_32_be(*bufp);
*bufp += sizeof(krb5_int32);
*remainp -= sizeof(krb5_int32);
return(0);
*marshal++ = (krb5_octet) ((tmp16 >> 8) & 0xff);
tmp32 = kaddr->length;
- *marshal++ = (krb5_octet) (tmp32 & 0xff);
- *marshal++ = (krb5_octet) ((tmp32 >> 8) & 0xff);
- *marshal++ = (krb5_octet) ((tmp32 >> 16) & 0xff);
- *marshal++ = (krb5_octet) ((tmp32 >> 24) & 0xff);
+ store_32_le(tmp32, marshal);
+ marshal += 4;
(void) memcpy((char *)marshal, (char *)(kaddr->contents), kaddr->length);
marshal += kaddr->length;
tmp16 = kport->addrtype;
*marshal++ = 0x00;
*marshal++ = 0x00;
- *marshal++ = (krb5_octet) (tmp16 & 0xff);
- *marshal++ = (krb5_octet) ((tmp16 >> 8) & 0xff);
+ store_16_le(tmp16, marshal);
+ marshal += 2;
tmp32 = kport->length;
- *marshal++ = (krb5_octet) (tmp32 & 0xff);
- *marshal++ = (krb5_octet) ((tmp32 >> 8) & 0xff);
- *marshal++ = (krb5_octet) ((tmp32 >> 16) & 0xff);
- *marshal++ = (krb5_octet) ((tmp32 >> 24) & 0xff);
+ store_32_le(tmp32, marshal);
+ marshal += 4;
(void) memcpy((char *)marshal, (char *)(kport->contents), kport->length);
marshal += kport->length;
if (!state->is_udp) {
- state->x.out.msg_len_buf[0] = (message->length >> 24) & 0xff;
- state->x.out.msg_len_buf[1] = (message->length >> 16) & 0xff;
- state->x.out.msg_len_buf[2] = (message->length >> 8) & 0xff;
- state->x.out.msg_len_buf[3] = message->length & 0xff;
-
+ store_32_be(message->length, state->x.out.msg_len_buf);
SG_SET(&state->x.out.sgbuf[0], state->x.out.msg_len_buf, 4);
SG_SET(&state->x.out.sgbuf[1], message->data, message->length);
state->x.out.sg_count = 2;