/* ib_ud_header_pack() packs the UD header structure @header into wire format in the buffer @buf.  */
int ib_ud_header_pack(struct ib_ud_header *header, void *buf)
/* ib_ud_header_pack() packs the UD header structure @header into wire format in the buffer @buf.  */
int ib_ud_header_pack(struct ib_ud_header *header, void *buf)
{
	int len = 0;
	ib_pack(lrh_table, ARRAY_SIZE(lrh_table),
		&header->lrh, buf);
	len += IB_LRH_BYTES;
	if (header->grh_present) {
		ib_pack(grh_table, ARRAY_SIZE(grh_table),
			&header->grh, buf + len);
		len += IB_GRH_BYTES;
	}
	ib_pack(bth_table, ARRAY_SIZE(bth_table),
		&header->bth, buf + len);
	len += IB_BTH_BYTES;
	ib_pack(deth_table, ARRAY_SIZE(deth_table),
		&header->deth, buf + len);
	len += IB_DETH_BYTES;
	if (header->immediate_present) {
		memcpy(buf + len, &header->immediate_data, sizeof header->immediate_data);
		len += sizeof header->immediate_data;
	}
	return len;
}