2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#include <assert.h>
2N/A#include <strings.h>
2N/A#include <sys/param.h>
2N/A
2N/A#include <smbsrv/libsmb.h>
2N/A#include <smbsrv/libndr.h>
2N/A
2N/A#ifdef _BIG_ENDIAN
2N/Astatic const int ndr_native_byte_order = NDR_REPLAB_INTG_BIG_ENDIAN;
2N/A#else
2N/Astatic const int ndr_native_byte_order = NDR_REPLAB_INTG_LITTLE_ENDIAN;
2N/A#endif
2N/A
2N/Astatic int ndr_decode_hdr_common(ndr_stream_t *, ndr_common_header_t *);
2N/Astatic int ndr_decode_pac_hdr(ndr_stream_t *, ndr_pac_hdr_t *);
2N/A
2N/Astatic int
2N/Andr_encode_decode_common(ndr_stream_t *nds, unsigned opnum,
2N/A ndr_typeinfo_t *ti, void *datum)
2N/A{
2N/A int rc;
2N/A
2N/A /*
2N/A * Perform the (un)marshalling
2N/A */
2N/A if (ndo_operation(nds, ti, opnum, datum))
2N/A return (NDR_DRC_OK);
2N/A
2N/A switch (nds->error) {
2N/A case NDR_ERR_MALLOC_FAILED:
2N/A rc = NDR_DRC_FAULT_OUT_OF_MEMORY;
2N/A break;
2N/A
2N/A case NDR_ERR_SWITCH_VALUE_INVALID:
2N/A rc = NDR_DRC_FAULT_PARAM_0_INVALID;
2N/A break;
2N/A
2N/A case NDR_ERR_UNDERFLOW:
2N/A rc = NDR_DRC_FAULT_RECEIVED_RUNT;
2N/A break;
2N/A
2N/A case NDR_ERR_GROW_FAILED:
2N/A rc = NDR_DRC_FAULT_ENCODE_TOO_BIG;
2N/A break;
2N/A
2N/A default:
2N/A if (nds->m_op == NDR_M_OP_MARSHALL)
2N/A rc = NDR_DRC_FAULT_ENCODE_FAILED;
2N/A else
2N/A rc = NDR_DRC_FAULT_DECODE_FAILED;
2N/A break;
2N/A }
2N/A
2N/A return (rc);
2N/A}
2N/A
2N/Andr_buf_t *
2N/Andr_buf_init(ndr_typeinfo_t *ti)
2N/A{
2N/A ndr_buf_t *nbuf;
2N/A
2N/A if ((nbuf = calloc(1, sizeof (ndr_buf_t))) == NULL)
2N/A return (NULL);
2N/A
2N/A if ((nbuf->nb_heap = ndr_heap_create()) == NULL) {
2N/A free(nbuf);
2N/A return (NULL);
2N/A }
2N/A
2N/A nbuf->nb_ti = ti;
2N/A nbuf->nb_magic = NDR_BUF_MAGIC;
2N/A return (nbuf);
2N/A}
2N/A
2N/Avoid
2N/Andr_buf_fini(ndr_buf_t *nbuf)
2N/A{
2N/A assert(nbuf->nb_magic == NDR_BUF_MAGIC);
2N/A
2N/A nds_destruct(&nbuf->nb_nds);
2N/A ndr_heap_destroy(nbuf->nb_heap);
2N/A nbuf->nb_magic = 0;
2N/A free(nbuf);
2N/A}
2N/A
2N/A/*
2N/A * Decode an NDR encoded buffer. The buffer is expected to contain
2N/A * a single fragment packet with a valid PDU header followed by NDR
2N/A * encoded data. The structure to which result points should be
2N/A * of the appropriate type to hold the decoded output. For example:
2N/A *
2N/A * pac_info_t info;
2N/A *
2N/A * if ((nbuf = ndr_buf_init(&TYPEINFO(ndr_pac)) != NULL) {
2N/A * rc = ndr_decode_buf(nbuf, opnum, data, datalen, &info);
2N/A * ...
2N/A * ndr_buf_fini(nbuf);
2N/A * }
2N/A */
2N/Aint
2N/Andr_buf_decode(ndr_buf_t *nbuf, unsigned hdr_type, unsigned opnum,
2N/A const char *data, size_t datalen, void *result)
2N/A{
2N/A ndr_common_header_t hdr;
2N/A ndr_pac_hdr_t pac_hdr;
2N/A unsigned pdu_size_hint;
2N/A int rc;
2N/A
2N/A assert(nbuf->nb_magic == NDR_BUF_MAGIC);
2N/A assert(nbuf->nb_heap != NULL);
2N/A assert(nbuf->nb_ti != NULL);
2N/A
2N/A if (datalen < NDR_PDU_SIZE_HINT_DEFAULT)
2N/A pdu_size_hint = NDR_PDU_SIZE_HINT_DEFAULT;
2N/A else
2N/A pdu_size_hint = datalen;
2N/A
2N/A rc = nds_initialize(&nbuf->nb_nds, pdu_size_hint, NDR_MODE_BUF_DECODE,
2N/A nbuf->nb_heap);
2N/A if (NDR_DRC_IS_FAULT(rc))
2N/A return (rc);
2N/A
2N/A bcopy(data, nbuf->nb_nds.pdu_base_addr, datalen);
2N/A
2N/A switch (hdr_type) {
2N/A case NDR_PTYPE_COMMON:
2N/A rc = ndr_decode_hdr_common(&nbuf->nb_nds, &hdr);
2N/A if (NDR_DRC_IS_FAULT(rc))
2N/A return (rc);
2N/A
2N/A if (!NDR_IS_SINGLE_FRAG(hdr.pfc_flags))
2N/A return (NDR_DRC_FAULT_DECODE_FAILED);
2N/A break;
2N/A
2N/A case NDR_PTYPE_PAC:
2N/A rc = ndr_decode_pac_hdr(&nbuf->nb_nds, &pac_hdr);
2N/A if (NDR_DRC_IS_FAULT(rc))
2N/A return (rc);
2N/A
2N/A if (pac_hdr.common_hdr.hdrlen != sizeof (ndr_serialtype1_hdr_t))
2N/A return (NDR_DRC_FAULT_DECODE_FAILED);
2N/A break;
2N/A
2N/A default:
2N/A return (NDR_ERR_UNIMPLEMENTED);
2N/A }
2N/A
2N/A rc = ndr_encode_decode_common(&nbuf->nb_nds, opnum, nbuf->nb_ti,
2N/A result);
2N/A return (rc);
2N/A}
2N/A
2N/A/*
2N/A * Use the receive stream to unmarshall data (NDR_MODE_CALL_RECV).
2N/A */
2N/Aint
2N/Andr_decode_call(ndr_xa_t *mxa, void *params)
2N/A{
2N/A ndr_stream_t *nds = &mxa->recv_nds;
2N/A int rc;
2N/A
2N/A if (!NDR_MODE_MATCH(nds, NDR_MODE_CALL_RECV))
2N/A return (NDR_DRC_FAULT_MODE_MISMATCH);
2N/A
2N/A rc = ndr_encode_decode_common(nds, mxa->opnum,
2N/A mxa->binding->service->interface_ti, params);
2N/A
2N/A return (rc + NDR_PTYPE_REQUEST);
2N/A}
2N/A
2N/A/*
2N/A * Use the send stream to marshall data (NDR_MODE_RETURN_SEND).
2N/A */
2N/Aint
2N/Andr_encode_return(ndr_xa_t *mxa, void *params)
2N/A{
2N/A ndr_stream_t *nds = &mxa->send_nds;
2N/A int rc;
2N/A
2N/A if (!NDR_MODE_MATCH(nds, NDR_MODE_RETURN_SEND))
2N/A return (NDR_DRC_FAULT_MODE_MISMATCH);
2N/A
2N/A rc = ndr_encode_decode_common(nds, mxa->opnum,
2N/A mxa->binding->service->interface_ti, params);
2N/A
2N/A return (rc + NDR_PTYPE_RESPONSE);
2N/A}
2N/A
2N/A/*
2N/A * Use the send stream to marshall data (NDR_MODE_CALL_SEND).
2N/A */
2N/Aint
2N/Andr_encode_call(ndr_xa_t *mxa, void *params)
2N/A{
2N/A ndr_stream_t *nds = &mxa->send_nds;
2N/A int rc;
2N/A
2N/A if (!NDR_MODE_MATCH(nds, NDR_MODE_CALL_SEND))
2N/A return (NDR_DRC_FAULT_MODE_MISMATCH);
2N/A
2N/A rc = ndr_encode_decode_common(nds, mxa->opnum,
2N/A mxa->binding->service->interface_ti, params);
2N/A
2N/A return (rc + NDR_PTYPE_REQUEST);
2N/A}
2N/A
2N/A/*
2N/A * Use the receive stream to unmarshall data (NDR_MODE_RETURN_RECV).
2N/A */
2N/Aint
2N/Andr_decode_return(ndr_xa_t *mxa, void *params)
2N/A{
2N/A ndr_stream_t *nds = &mxa->recv_nds;
2N/A int rc;
2N/A
2N/A if (!NDR_MODE_MATCH(nds, NDR_MODE_RETURN_RECV))
2N/A return (NDR_DRC_FAULT_MODE_MISMATCH);
2N/A
2N/A rc = ndr_encode_decode_common(nds, mxa->opnum,
2N/A mxa->binding->service->interface_ti, params);
2N/A
2N/A return (rc + NDR_PTYPE_RESPONSE);
2N/A}
2N/A
2N/Aint
2N/Andr_decode_pdu_hdr(ndr_xa_t *mxa)
2N/A{
2N/A ndr_common_header_t *hdr = &mxa->recv_hdr.common_hdr;
2N/A ndr_stream_t *nds = &mxa->recv_nds;
2N/A int rc;
2N/A
2N/A rc = ndr_decode_hdr_common(nds, hdr);
2N/A if (NDR_DRC_IS_FAULT(rc))
2N/A return (rc);
2N/A
2N/A /*
2N/A * Verify the protocol version.
2N/A */
2N/A if ((hdr->rpc_vers != 5) || (hdr->rpc_vers_minor != 0))
2N/A return (NDR_DRC_FAULT_RPCHDR_DECODE_FAILED);
2N/A
2N/A mxa->ptype = hdr->ptype;
2N/A return (NDR_DRC_OK);
2N/A}
2N/A
2N/Astatic int
2N/Andr_decode_hdr_common(ndr_stream_t *nds, ndr_common_header_t *hdr)
2N/A{
2N/A int ptype;
2N/A int rc;
2N/A int charset;
2N/A int byte_order;
2N/A
2N/A if (nds->m_op != NDR_M_OP_UNMARSHALL)
2N/A return (NDR_DRC_FAULT_RPCHDR_MODE_MISMATCH);
2N/A
2N/A /*
2N/A * All PDU headers are at least this big
2N/A */
2N/A rc = NDS_GROW_PDU(nds, sizeof (ndr_common_header_t), 0);
2N/A if (!rc)
2N/A return (NDR_DRC_FAULT_RPCHDR_RECEIVED_RUNT);
2N/A
2N/A /*
2N/A * Peek at the first eight bytes to figure out what we're doing.
2N/A */
2N/A rc = NDS_GET_PDU(nds, 0, 8, (char *)hdr, 0, 0);
2N/A if (!rc)
2N/A return (NDR_DRC_FAULT_RPCHDR_DECODE_FAILED);
2N/A
2N/A /*
2N/A * Check for ASCII as the character set. This is an ASCII
2N/A * versus EBCDIC option and has nothing to do with Unicode.
2N/A */
2N/A charset = hdr->packed_drep.intg_char_rep & NDR_REPLAB_CHAR_MASK;
2N/A if (charset != NDR_REPLAB_CHAR_ASCII)
2N/A return (NDR_DRC_FAULT_RPCHDR_DECODE_FAILED);
2N/A
2N/A /*
2N/A * Set the byte swap flag if the PDU byte-order
2N/A * is different from the local byte-order.
2N/A */
2N/A byte_order = hdr->packed_drep.intg_char_rep & NDR_REPLAB_INTG_MASK;
2N/A nds->swap = (byte_order != ndr_native_byte_order) ? 1 : 0;
2N/A
2N/A ptype = hdr->ptype;
2N/A if (ptype == NDR_PTYPE_REQUEST &&
2N/A (hdr->pfc_flags & NDR_PFC_OBJECT_UUID) != 0) {
2N/A ptype = NDR_PTYPE_REQUEST_WITH; /* fake for sizing */
2N/A }
2N/A
2N/A rc = ndr_encode_decode_common(nds, ptype, &TYPEINFO(ndr_hdr), hdr);
2N/A
2N/A return (NDR_DRC_PTYPE_RPCHDR(rc));
2N/A}
2N/A
2N/Astatic int
2N/Andr_decode_pac_hdr(ndr_stream_t *nds, ndr_pac_hdr_t *hdr)
2N/A{
2N/A int rc;
2N/A
2N/A if (nds->m_op != NDR_M_OP_UNMARSHALL)
2N/A return (NDR_DRC_FAULT_RPCHDR_MODE_MISMATCH);
2N/A
2N/A /*
2N/A * All PDU headers are at least this big
2N/A */
2N/A rc = NDS_GROW_PDU(nds, sizeof (ndr_pac_hdr_t), 0);
2N/A if (!rc)
2N/A return (NDR_DRC_FAULT_RPCHDR_RECEIVED_RUNT);
2N/A
2N/A /*
2N/A * Peek at the first eight bytes to figure out what we're doing.
2N/A */
2N/A rc = NDS_GET_PDU(nds, 0, 8, (char *)hdr, 0, 0);
2N/A if (!rc)
2N/A return (NDR_DRC_FAULT_RPCHDR_DECODE_FAILED);
2N/A
2N/A /* Must be set to 1 to indicate type serialization version 1. */
2N/A if (hdr->common_hdr.version != 1)
2N/A return (NDR_DRC_FAULT_RPCHDR_DECODE_FAILED);
2N/A
2N/A /*
2N/A * Set the byte swap flag if the PDU byte-order
2N/A * is different from the local byte-order.
2N/A */
2N/A nds->swap =
2N/A (hdr->common_hdr.endianness != ndr_native_byte_order) ? 1 : 0;
2N/A
2N/A rc = ndr_encode_decode_common(nds, NDR_PTYPE_PAC,
2N/A &TYPEINFO(ndr_hdr), hdr);
2N/A
2N/A return (NDR_DRC_PTYPE_RPCHDR(rc));
2N/A}
2N/A
2N/A/*
2N/A * Decode an RPC fragment header. Use ndr_decode_pdu_hdr() to process
2N/A * the first fragment header then this function to process additional
2N/A * fragment headers.
2N/A */
2N/Avoid
2N/Andr_decode_frag_hdr(ndr_stream_t *nds, ndr_common_header_t *hdr)
2N/A{
2N/A ndr_common_header_t *tmp;
2N/A uint8_t *pdu;
2N/A int byte_order;
2N/A
2N/A pdu = (uint8_t *)nds->pdu_base_offset + nds->pdu_scan_offset;
2N/A bcopy(pdu, hdr, NDR_RSP_HDR_SIZE);
2N/A
2N/A /*
2N/A * Swap non-byte fields if the PDU byte-order
2N/A * is different from the local byte-order.
2N/A */
2N/A byte_order = hdr->packed_drep.intg_char_rep & NDR_REPLAB_INTG_MASK;
2N/A
2N/A if (byte_order != ndr_native_byte_order) {
2N/A /*LINTED E_BAD_PTR_CAST_ALIGN*/
2N/A tmp = (ndr_common_header_t *)pdu;
2N/A
2N/A nds_bswap(&tmp->frag_length, &hdr->frag_length,
2N/A sizeof (WORD));
2N/A nds_bswap(&tmp->auth_length, &hdr->auth_length,
2N/A sizeof (WORD));
2N/A nds_bswap(&tmp->call_id, &hdr->call_id, sizeof (DWORD));
2N/A }
2N/A}
2N/A
2N/A/*
2N/A * Remove an RPC fragment header from the received data stream.
2N/A *
2N/A * NDR stream on entry:
2N/A *
2N/A * |<--- frag --->|
2N/A * +-----+--------+-----+--------+-----+---------+-----+
2N/A * | hdr | data | hdr | data | hdr | data | ... |
2N/A * +-----+--------+-----+--------+-----+---------+-----+
2N/A * <----
2N/A *
2N/A * NDR stream on return:
2N/A *
2N/A * +-----+----------------+-----+---------+-----+
2N/A * | hdr | data | hdr | data | ... |
2N/A * +-----+----------------+-----+---------+-----+
2N/A */
2N/Avoid
2N/Andr_remove_frag_hdr(ndr_stream_t *nds)
2N/A{
2N/A char *hdr;
2N/A char *data;
2N/A int nbytes;
2N/A
2N/A hdr = (char *)nds->pdu_base_offset + nds->pdu_scan_offset;
2N/A data = hdr + NDR_RSP_HDR_SIZE;
2N/A nbytes = nds->pdu_size - nds->pdu_scan_offset - NDR_RSP_HDR_SIZE;
2N/A
2N/A bcopy(data, hdr, nbytes);
2N/A nds->pdu_size -= NDR_RSP_HDR_SIZE;
2N/A}
2N/A
2N/Avoid
2N/Andr_show_hdr(ndr_common_header_t *hdr)
2N/A{
2N/A char *fragtype;
2N/A
2N/A if (hdr == NULL) {
2N/A ndo_printf(NULL, NULL, "ndr hdr: <null>");
2N/A return;
2N/A }
2N/A
2N/A if (NDR_IS_SINGLE_FRAG(hdr->pfc_flags))
2N/A fragtype = "single";
2N/A else if (NDR_IS_FIRST_FRAG(hdr->pfc_flags))
2N/A fragtype = "first";
2N/A else if (NDR_IS_LAST_FRAG(hdr->pfc_flags))
2N/A fragtype = "last";
2N/A else
2N/A fragtype = "intermediate";
2N/A
2N/A ndo_printf(NULL, NULL,
2N/A "ndr hdr: %d.%d ptype=%d, %s frag (flags=0x%08x) len=%d",
2N/A hdr->rpc_vers, hdr->rpc_vers_minor, hdr->ptype,
2N/A fragtype, hdr->pfc_flags, hdr->frag_length);
2N/A}
2N/A
2N/Aint
2N/Andr_encode_pdu_hdr(ndr_xa_t *mxa)
2N/A{
2N/A ndr_common_header_t *hdr = &mxa->send_hdr.common_hdr;
2N/A ndr_stream_t *nds = &mxa->send_nds;
2N/A int ptype;
2N/A int rc;
2N/A
2N/A if (nds->m_op != NDR_M_OP_MARSHALL)
2N/A return (NDR_DRC_FAULT_RPCHDR_MODE_MISMATCH);
2N/A
2N/A ptype = hdr->ptype;
2N/A if (ptype == NDR_PTYPE_REQUEST &&
2N/A (hdr->pfc_flags & NDR_PFC_OBJECT_UUID) != 0) {
2N/A ptype = NDR_PTYPE_REQUEST_WITH; /* fake for sizing */
2N/A }
2N/A
2N/A rc = ndr_encode_decode_common(nds, ptype, &TYPEINFO(ndr_hdr), hdr);
2N/A
2N/A return (NDR_DRC_PTYPE_RPCHDR(rc));
2N/A}
2N/A
2N/A/*
2N/A * This is a hand-coded derivative of the automatically generated
2N/A * (un)marshalling routine for bind_ack headers. bind_ack headers
2N/A * have an interior conformant array, which is inconsistent with
2N/A * IDL/NDR rules.
2N/A */
2N/Aextern struct ndr_typeinfo ndt__uchar;
2N/Aextern struct ndr_typeinfo ndt__ushort;
2N/Aextern struct ndr_typeinfo ndt__ulong;
2N/A
2N/Aint ndr__ndr_bind_ack_hdr(ndr_ref_t *encl_ref);
2N/Andr_typeinfo_t ndt__ndr_bind_ack_hdr = {
2N/A 1, /* NDR version */
2N/A 3, /* alignment */
2N/A NDR_F_STRUCT, /* flags */
2N/A ndr__ndr_bind_ack_hdr, /* ndr_func */
2N/A 68, /* pdu_size_fixed_part */
2N/A 0, /* pdu_size_variable_part */
2N/A 68, /* c_size_fixed_part */
2N/A 0, /* c_size_variable_part */
2N/A};
2N/A
2N/A/*
2N/A * [_no_reorder]
2N/A */
2N/Aint
2N/Andr__ndr_bind_ack_hdr(ndr_ref_t *encl_ref)
2N/A{
2N/A ndr_stream_t *nds = encl_ref->stream;
2N/A struct ndr_bind_ack_hdr *val = /*LINTED E_BAD_PTR_CAST_ALIGN*/
2N/A (struct ndr_bind_ack_hdr *)encl_ref->datum;
2N/A ndr_ref_t myref;
2N/A unsigned long offset;
2N/A
2N/A bzero(&myref, sizeof (myref));
2N/A myref.enclosing = encl_ref;
2N/A myref.stream = encl_ref->stream;
2N/A myref.packed_alignment = 0;
2N/A
2N/A /* do all members in order */
2N/A NDR_MEMBER(_ndr_common_header, common_hdr, 0UL);
2N/A NDR_MEMBER(_ushort, max_xmit_frag, 16UL);
2N/A NDR_MEMBER(_ushort, max_recv_frag, 18UL);
2N/A NDR_MEMBER(_ulong, assoc_group_id, 20UL);
2N/A
2N/A /* port any is the conformant culprit */
2N/A offset = 24UL;
2N/A
2N/A switch (nds->m_op) {
2N/A case NDR_M_OP_MARSHALL:
2N/A val->sec_addr.length =
2N/A strlen((char *)val->sec_addr.port_spec) + 1;
2N/A break;
2N/A
2N/A case NDR_M_OP_UNMARSHALL:
2N/A break;
2N/A
2N/A default:
2N/A NDR_SET_ERROR(encl_ref, NDR_ERR_M_OP_INVALID);
2N/A return (0);
2N/A }
2N/A
2N/A NDR_MEMBER(_ushort, sec_addr.length, offset);
2N/A NDR_MEMBER_ARR_WITH_DIMENSION(_uchar, sec_addr.port_spec,
2N/A offset+2UL, val->sec_addr.length);
2N/A
2N/A offset += 2;
2N/A offset += val->sec_addr.length;
2N/A offset += NDR_ALIGN4(offset);
2N/A
2N/A NDR_MEMBER(_ndr_p_result_list, p_result_list, offset);
2N/A return (1);
2N/A}
2N/A
2N/A/*
2N/A * Assume a single presentation context element in the result list.
2N/A */
2N/Aunsigned
2N/Andr_bind_ack_hdr_size(ndr_xa_t *mxa)
2N/A{
2N/A ndr_bind_ack_hdr_t *bahdr = &mxa->send_hdr.bind_ack_hdr;
2N/A unsigned offset;
2N/A unsigned length;
2N/A
2N/A /* port any is the conformant culprit */
2N/A offset = 24UL;
2N/A
2N/A length = strlen((char *)bahdr->sec_addr.port_spec) + 1;
2N/A
2N/A offset += 2;
2N/A offset += length;
2N/A offset += NDR_ALIGN4(offset);
2N/A offset += sizeof (ndr_p_result_list_t);
2N/A return (offset);
2N/A}
2N/A
2N/A/*
2N/A * This is a hand-coded derivative of the automatically generated
2N/A * (un)marshalling routine for alter_context_rsp headers.
2N/A * Alter context response headers have an interior conformant array,
2N/A * which is inconsistent with IDL/NDR rules.
2N/A */
2N/Aint ndr__ndr_alter_context_rsp_hdr(ndr_ref_t *encl_ref);
2N/Andr_typeinfo_t ndt__ndr_alter_context_rsp_hdr = {
2N/A 1, /* NDR version */
2N/A 3, /* alignment */
2N/A NDR_F_STRUCT, /* flags */
2N/A ndr__ndr_alter_context_rsp_hdr, /* ndr_func */
2N/A 56, /* pdu_size_fixed_part */
2N/A 0, /* pdu_size_variable_part */
2N/A 56, /* c_size_fixed_part */
2N/A 0, /* c_size_variable_part */
2N/A};
2N/A
2N/A/*
2N/A * [_no_reorder]
2N/A */
2N/Aint
2N/Andr__ndr_alter_context_rsp_hdr(ndr_ref_t *encl_ref)
2N/A{
2N/A ndr_stream_t *nds = encl_ref->stream;
2N/A ndr_alter_context_rsp_hdr_t *val = /*LINTED E_BAD_PTR_CAST_ALIGN*/
2N/A (ndr_alter_context_rsp_hdr_t *)encl_ref->datum;
2N/A ndr_ref_t myref;
2N/A unsigned long offset;
2N/A
2N/A bzero(&myref, sizeof (myref));
2N/A myref.enclosing = encl_ref;
2N/A myref.stream = encl_ref->stream;
2N/A myref.packed_alignment = 0;
2N/A
2N/A /* do all members in order */
2N/A NDR_MEMBER(_ndr_common_header, common_hdr, 0UL);
2N/A NDR_MEMBER(_ushort, max_xmit_frag, 16UL);
2N/A NDR_MEMBER(_ushort, max_recv_frag, 18UL);
2N/A NDR_MEMBER(_ulong, assoc_group_id, 20UL);
2N/A
2N/A offset = 24UL; /* offset of sec_addr */
2N/A
2N/A switch (nds->m_op) {
2N/A case NDR_M_OP_MARSHALL:
2N/A val->sec_addr.length = 0;
2N/A break;
2N/A
2N/A case NDR_M_OP_UNMARSHALL:
2N/A break;
2N/A
2N/A default:
2N/A NDR_SET_ERROR(encl_ref, NDR_ERR_M_OP_INVALID);
2N/A return (0);
2N/A }
2N/A
2N/A NDR_MEMBER(_ushort, sec_addr.length, offset);
2N/A NDR_MEMBER_ARR_WITH_DIMENSION(_uchar, sec_addr.port_spec,
2N/A offset+2UL, val->sec_addr.length);
2N/A
2N/A offset += 2; /* sizeof (sec_addr.length) */
2N/A offset += NDR_ALIGN4(offset);
2N/A
2N/A NDR_MEMBER(_ndr_p_result_list, p_result_list, offset);
2N/A return (1);
2N/A}
2N/A
2N/A/*
2N/A * Assume a single presentation context element in the result list.
2N/A */
2N/Aunsigned
2N/Andr_alter_context_rsp_hdr_size(void)
2N/A{
2N/A unsigned offset;
2N/A
2N/A offset = 24UL; /* offset of sec_addr */
2N/A offset += 2; /* sizeof (sec_addr.length) */
2N/A offset += NDR_ALIGN4(offset);
2N/A offset += sizeof (ndr_p_result_list_t);
2N/A return (offset);
2N/A}