PRIVATE void rpc__tower_to_tower_ref ( twr_p_t tower, rpc_tower_ref_p_t *tower_ref, unsigned32 *status ) { unsigned16 floor_count; CODING_ERROR (status); /* * Get the tower floor count and correct for proper endian. */ memcpy ((char *) &floor_count, (char *) tower->tower_octet_string, RPC_C_TOWER_FLR_COUNT_SIZE); RPC_RESOLVE_ENDIAN_INT16 (floor_count); /* * Allocate and initialize the tower reference structure to be returned. */ rpc__tower_ref_alloc (tower->tower_octet_string, floor_count, 1, tower_ref, status); /* * Return status from the tower ref allocate operation. */ return; }
INTERNAL void addr_set_netaddr ( unsigned_char_p_t netaddr, rpc_addr_p_t *rpc_addr, unsigned32 *status ) { rpc_http_addr_p_t http_addr = (rpc_http_addr_p_t) *rpc_addr; CODING_ERROR (status); /* * check to see if this is a request to remove the netaddr */ if (netaddr == NULL || strlen ((char *) netaddr) == 0) { http_addr->server[0] = '\0'; *status = rpc_s_ok; return; } strncpy((char*) &http_addr->server, (char*) netaddr, sizeof(http_addr->server)); *status = rpc_s_ok; }
PRIVATE void rpc__cn_binding_inq_client ( rpc_binding_rep_p_t binding_r, rpc_client_handle_t *client_h, unsigned32 *st ) { rpc_cn_local_id_t grp_id; CODING_ERROR (st); /* * Get the association group id from the binding rep. */ grp_id = ((rpc_cn_binding_rep_t *)binding_r)->grp_id; /* * Make sure the group id is valid. */ *client_h = (rpc_client_handle_t) grp_id.all; if (RPC_CN_LOCAL_ID_VALID (grp_id)) { *st = rpc_s_ok; } else { *st = rpc_s_invalid_binding; } }
PRIVATE void rpc__tower_ref_free ( rpc_tower_ref_p_t *tower_ref, unsigned32 *status ) { unsigned32 i; CODING_ERROR (status); /* * Free the tower floors in the tower, freeing the octet string * associated with the each floor only if the free floor flag is set. */ for (i=0; i < (*tower_ref)->count; i++) { rpc__tower_flr_free (&((*tower_ref)->floor[i]), status); if (*status != rpc_s_ok) { return; } } /* * Free the tower reference and set the pointer to NULL. */ RPC_MEM_FREE (*tower_ref, RPC_C_MEM_TOWER_REF); *tower_ref = NULL; *status = rpc_s_ok; return; }
PRIVATE void rpc__tower_ref_add_floor ( unsigned32 floor_number, rpc_tower_floor_p_t floor, rpc_tower_ref_t *tower_ref, unsigned32 *status ) { CODING_ERROR (status); /* * If we're replacing the floor, free it first. */ if (tower_ref->floor[floor_number-1] != NULL) { rpc__tower_flr_free (&(tower_ref->floor[floor_number-1]), status); if (*status != rpc_s_ok) { return; } } /* * Add the new floor. */ tower_ref->floor[floor_number-1] = floor; *status = rpc_s_ok; return; }
INTERNAL void addr_inq_netaddr ( rpc_addr_p_t rpc_addr, unsigned_char_t **p_netaddr, unsigned32 *status ) { rpc_http_addr_p_t http_addr = (rpc_http_addr_p_t) rpc_addr; unsigned_char_p_t netaddr; size_t addr_length = 0; CODING_ERROR (status); addr_length = strlen(http_addr->server); RPC_MEM_ALLOC( *p_netaddr, unsigned_char_p_t, addr_length + 1, RPC_C_MEM_STRING, RPC_C_MEM_WAITOK); if (*p_netaddr == NULL) { *status = rpc_s_no_memory; return; } netaddr = *p_netaddr; memcpy(netaddr, http_addr->server, addr_length); netaddr[addr_length] = 0; *status = rpc_s_ok; }
void rpc_binding_inq_prot_seq( rpc_binding_handle_t binding_handle, unsigned32 *prot_seq, unsigned32 *st ) { rpc_binding_rep_p_t binding_r = (rpc_binding_rep_p_t) binding_handle; CODING_ERROR (st); RPC_VERIFY_INIT (); if (binding_r && binding_r->transport_info) { *prot_seq = (unsigned32)binding_r->transport_info->protseq; } else if (binding_r) { *prot_seq = (unsigned32)binding_r->rpc_addr->rpc_protseq_id; } else { *prot_seq = (unsigned32)RPC_C_INVALID_PROTSEQ_ID; } *st = rpc_s_ok; }
INTERNAL void addr_set_endpoint ( unsigned_char_p_t endpoint, rpc_addr_p_t *rpc_addr, unsigned32 *status ) { rpc_http_addr_p_t http_addr = (rpc_http_addr_p_t) *rpc_addr; CODING_ERROR (status); /* * check to see if this is a request to remove the endpoint */ if (endpoint == NULL || strlen ((char *) endpoint) == 0) { http_addr->endpoint = 0; *status = rpc_s_ok; return; } http_addr->endpoint = atoi((char*) endpoint); *status = rpc_s_ok; }
PRIVATE void rpc_tower_vector_free ( rpc_tower_vector_p_t *twr_vector, unsigned32 *status ) { unsigned32 i; CODING_ERROR (status); /* * Free each tower reference in the vector. */ for (i=0; i < (*twr_vector)->count; i++) { rpc__tower_free (&((*twr_vector)->tower[i]), status); if (*status != rpc_s_ok) { return; } } /* * Free the tower vector structure and set pointer to NULL. */ RPC_MEM_FREE (*twr_vector, RPC_C_MEM_TOWER_VECTOR); *twr_vector = NULL; *status = rpc_s_ok; return; }
PUBLIC void dce_cs_loc_to_rgy ( idl_char *local_code_set_name, unsigned32 *rgy_code_set_value, unsigned16 *rgy_char_sets_number, unsigned16 **rgy_char_sets_value, error_status_t *status ) { entry_t **epp; entry_t *found = NULL; int i; unsigned16 *char_array; CODING_ERROR (status); rpc__codesets_read_registry_file(status); if (*status != rpc_s_ok) { return; } epp = rpc_g_codesets_sort_by_name; /* binary search */ n_binary_search(epp, 0, rpc_g_codesets_entry_count-1, (char *)local_code_set_name, &found); if (found == NULL) { *status = dce_cs_c_unknown; return; } if (rgy_char_sets_number != NULL) { *rgy_char_sets_number = found->char_sets_num; } if (rgy_char_sets_value != NULL) { if ((char_array = (unsigned16 *)malloc(sizeof(unsigned16) * found->char_sets_num)) == NULL) { *status = dce_cs_c_cannot_allocate_memory; return; } *rgy_char_sets_value = char_array; for (i = 0; i < found->char_sets_num; i++) { *char_array++ = found->char_sets[i]; } } *rgy_code_set_value = (unsigned32)found->code_set; *status = dce_cs_c_ok; return; }
PRIVATE void rpc__tower_ref_copy ( rpc_tower_ref_p_t source_tower, rpc_tower_ref_p_t *dest_tower, unsigned32 *status ) { unsigned32 i, tower_ref_size; CODING_ERROR (status); tower_ref_size = sizeof (rpc_tower_ref_t) + (sizeof (rpc_tower_floor_p_t) * ((source_tower->count)-1)); /* * Allocate the destination tower structure and * copy the source tower into it. */ RPC_MEM_ALLOC ( *dest_tower, rpc_tower_ref_p_t, tower_ref_size, RPC_C_MEM_TOWER_REF, RPC_C_MEM_WAITOK); /* * Copy the floor count to the destination tower ref. */ (*dest_tower)->count = source_tower->count; /* * For each floor in the source tower ref, allocate a new floor * for the destination tower ref and copy the floor contents. * Set the destination free flag to false since the * floors' tower octet string will be freed when freeing * the source_tower. */ for (i=0; i < source_tower->count; i++) { RPC_MEM_ALLOC ( (*dest_tower)->floor[i], rpc_tower_floor_p_t, sizeof (rpc_tower_floor_t), RPC_C_MEM_TOWER_FLOOR, RPC_C_MEM_WAITOK); memcpy ((*dest_tower)->floor[i], source_tower->floor[i], sizeof (rpc_tower_floor_t)); (*dest_tower)->floor[i]->free_twr_octet_flag = false; } *status = rpc_s_ok; return; }
void rpc_binding_inq_access_token_caller( rpc_binding_handle_t binding_handle, rpc_access_token_p_t* token, unsigned32* st ) { rpc_binding_rep_p_t binding_r = (rpc_binding_rep_p_t) binding_handle; int err = 0; CODING_ERROR (st); RPC_VERIFY_INIT (); *token = NULL; if (binding_r) { if (binding_r->auth_info) { rpc_g_authn_protocol_id[binding_r->auth_info->authn_protocol].epv-> inq_access_token(binding_r->auth_info, token, st); if (*st != rpc_s_ok) { goto error; } } if (!*token && binding_r->transport_info) { err = rpc_g_protseq_id[binding_r->transport_info->protseq].socket_vtbl-> transport_inq_access_token( binding_r->transport_info->handle, token); if (err) { *st = rpc_s_binding_has_no_auth; goto error; } } } if (!*token) { *st = rpc_s_binding_has_no_auth; goto error; } else { *st = rpc_s_ok; } error: return; }
INTERNAL void addr_alloc ( rpc_protseq_id_t rpc_protseq_id, rpc_naf_id_t naf_id, unsigned_char_p_t endpoint, unsigned_char_p_t netaddr, unsigned_char_p_t network_options ATTRIBUTE_UNUSED, rpc_addr_p_t *rpc_addr, unsigned32 *status ) { CODING_ERROR (status); /* * allocate memory for the new RPC address */ RPC_MEM_ALLOC ( *rpc_addr, rpc_addr_p_t, sizeof (rpc_http_addr_t), RPC_C_MEM_RPC_ADDR, RPC_C_MEM_WAITOK); if (*rpc_addr == NULL) { *status = rpc_s_no_memory; return; } /* * zero allocated memory */ memset( *rpc_addr, 0, sizeof (rpc_http_addr_t)); /* * insert id, length, family into rpc address */ (*rpc_addr)->rpc_protseq_id = rpc_protseq_id; (*rpc_addr)->len = sizeof (struct sockaddr); (*rpc_addr)->sa.family = naf_id; /* * set the endpoint in the RPC addr */ addr_set_endpoint (endpoint, rpc_addr, status); if (*status != rpc_s_ok) return; /* * set the network address in the RPC addr */ addr_set_netaddr (netaddr, rpc_addr, status); if (*status != rpc_s_ok) return; *status = rpc_s_ok; }
PRIVATE void rpc__http_init_local_addr_vec ( unsigned32 *status ) { CODING_ERROR (status); *status = rpc_s_ok; return; }
PRIVATE void rpc__cn_binding_changed ( rpc_binding_rep_p_t binding_r, unsigned32 *st ) { CODING_ERROR (st); /* * The exact field which changed is not known. Init the binding. */ rpc__cn_binding_init (binding_r, st); }
PRIVATE void rpc__tower_free ( twr_p_t *tower, unsigned32 *status ) { CODING_ERROR (status); RPC_MEM_FREE (*tower, RPC_C_MEM_TOWER); *tower = NULL; *status = rpc_s_ok; return; }
PRIVATE void rpc__cn_binding_cross_fork ( rpc_binding_rep_p_t binding_r ATTRIBUTE_UNUSED, unsigned32 *st ) { CODING_ERROR (st); /* * This is a dummy function to avoid the null reference * causing a core dump. */ *st = rpc_s_ok; }
PRIVATE rpc_binding_rep_t *rpc__cn_binding_alloc ( boolean32 is_server, unsigned32 *st ) { rpc_cn_binding_rep_p_t brp; CODING_ERROR (st); /* * A server binding is allocated from the receiver thread which * has already acquired the CN global mutex. */ if (!is_server) { RPC_CN_LOCK (); } else { RPC_CN_LOCK_ASSERT (); } /* * Allocate a binding rep off the lookaside list. */ brp = (rpc_cn_binding_rep_p_t) rpc__list_element_alloc (&rpc_g_cn_binding_lookaside_list, true); if (brp == NULL) { *st = rpc_s_no_memory; RPC_CN_UNLOCK (); return NULL; } if (!is_server) { ((rpc_cn_binding_rep_t *)brp)->being_resolved = false; RPC_CN_UNLOCK (); } brp->common.rpc_addr = NULL; brp->common.auth_info = NULL; brp->common.transport_info = NULL; *st = rpc_s_ok; return ((rpc_binding_rep_p_t) brp); }
PUBLIC void rpc_tower_to_binding ( byte_p_t prot_tower, rpc_binding_handle_t *binding, unsigned32 *status ) { rpc_binding_rep_p_t binding_rep; rpc_protocol_id_t prot_id; rpc_addr_p_t rpc_addr; CODING_ERROR (status); RPC_VERIFY_INIT (); /* * Null binding in case of error before finishing. */ *binding = NULL; /* * Obtain an RPC address for the tower. */ rpc__naf_tower_flrs_to_addr (prot_tower, &rpc_addr, status); if (*status != rpc_s_ok) { return; } prot_id = RPC_PROTSEQ_INQ_PROT_ID(rpc_addr->rpc_protseq_id); /* * Allocate and initialize a binding rep. */ binding_rep = rpc__binding_alloc (false, &uuid_g_nil_uuid, prot_id, rpc_addr, status); /* * Return binding handle to user. */ *binding = (rpc_binding_handle_t) binding_rep; /* * Return status from rpc__binding_alloc */ return; }
PUBLIC void rpc_string_free ( unsigned_char_p_t *string, unsigned32 *status ) { CODING_ERROR (status); if (*string != NULL) { RPC_MEM_FREE (*string, RPC_C_MEM_STRING); *string = NULL; } *status = rpc_s_ok; return; }
PRIVATE void rpc__http_get_broadcast ( rpc_naf_id_t naf_id ATTRIBUTE_UNUSED, rpc_protseq_id_t protseq_id, rpc_addr_vector_p_t *rpc_addr_vec, unsigned32 *status ) { naf_id = 0; protseq_id = 0; rpc_addr_vec = NULL; CODING_ERROR (status); *status = rpc_s_cant_inq_socket; return; }
INTERNAL void addr_copy ( rpc_addr_p_t src_rpc_addr, rpc_addr_p_t *dst_rpc_addr, unsigned32 *status ) { CODING_ERROR (status); /* * if the source RPC address looks valid - IP family ok */ if (src_rpc_addr->sa.family == RPC_C_NAF_ID_HTTP) { /* * allocate memory for the new RPC address */ RPC_MEM_ALLOC ( *dst_rpc_addr, rpc_addr_p_t, sizeof (rpc_http_addr_t), RPC_C_MEM_RPC_ADDR, RPC_C_MEM_WAITOK); if (*dst_rpc_addr == NULL) { *status = rpc_s_no_memory; return; } /* * Copy source rpc address to destination rpc address */ /* b_c_o_p_y ((unsigned8 *) src_rpc_addr, (unsigned8 *) *dst_rpc_addr, sizeof (rpc_http_addr_t));*/ memmove( *dst_rpc_addr, src_rpc_addr, sizeof (rpc_http_addr_t)); *status = rpc_s_ok; return; } *status = rpc_s_invalid_naf_id; }
PRIVATE void rpc__cn_binding_init ( rpc_binding_rep_p_t binding_r, unsigned32 *st ) { unsigned32 type; rpc_cn_local_id_t grp_id; CODING_ERROR (st); /* * Determine the type of association group we are looking for. */ if (RPC_BINDING_IS_SERVER (binding_r)) { type = RPC_C_CN_ASSOC_GRP_SERVER; } else { type = RPC_C_CN_ASSOC_GRP_CLIENT; /* * Use the RPC address contained in the binding rep to find an * association group. */ RPC_CN_LOCK (); grp_id = rpc__cn_assoc_grp_lkup_by_addr (binding_r->rpc_addr, binding_r->transport_info, type, st); /* * Record its the association group id returned into the * binding rep. Note that the group id returned may be invalid. */ ((rpc_cn_binding_rep_t *)binding_r)->grp_id = grp_id; RPC_CN_UNLOCK (); } /* * Return a good status code no matter what happened. */ *st = rpc_s_ok; }
PRIVATE boolean32 rpc__http_is_local_addr ( rpc_addr_p_t rpc_addr, unsigned32 *status ) { CODING_ERROR (status); if (rpc_addr == NULL) { *status = rpc_s_invalid_arg; return false; } *status = rpc_s_ok; return true; }
PRIVATE void rpc__cn_binding_copy ( rpc_binding_rep_p_t src_binding_r, rpc_binding_rep_p_t dst_binding_r, unsigned32 *st ) { CODING_ERROR (st); /* * Get the association group id from the src binding rep and put * it in the dst binding rep. */ ((rpc_cn_binding_rep_t *)dst_binding_r)->grp_id = ((rpc_cn_binding_rep_t *)src_binding_r)->grp_id; *st = rpc_s_ok; }
PUBLIC void rpc_rgy_get_max_bytes ( unsigned32 tag, unsigned16 *max_bytes, error_status_t *status ) { entry_t **epp; entry_t *found = NULL; int i; unsigned16 *char_array; CODING_ERROR (status); rpc__codesets_read_registry_file(status); if (*status != rpc_s_ok) { return; } epp = rpc_g_codesets_sort_by_id; i = rpc_g_codesets_entry_count; /* binary search */ c_binary_search(epp, 0, rpc_g_codesets_entry_count-1, tag, &found); if (found == NULL) { *status = dce_cs_c_unknown; return; } if ((i = strcoll(found->code_set_name, "NONE")) == 0) { *status = dce_cs_c_notfound; return; } *max_bytes = found->max_bytes; *status = rpc_s_ok; return; }
PRIVATE void rpc__cn_binding_reset ( rpc_binding_rep_p_t binding_r, unsigned32 *st ) { CODING_ERROR (st); /* * The endpoint in the binding is being reset. Since we assume * endpoints are tied to address spaces and an association group * id identifies an address space we should reset the group ID. * When the endpoint is added to the binding * rpc__cn_binding_init should be called again to set the group id. */ RPC_CN_LOCAL_ID_CLEAR (((rpc_cn_binding_rep_t *)binding_r)->grp_id); *st = rpc_s_ok; }
INTERNAL void addr_free ( rpc_addr_p_t *rpc_addr, unsigned32 *status ) { CODING_ERROR (status); /* * free memory of RPC addr */ RPC_MEM_FREE (*rpc_addr, RPC_C_MEM_RPC_ADDR); /* * indicate that the rpc_addr is now empty */ *rpc_addr = NULL; *status = rpc_s_ok; }
PRIVATE void rpc__cn_binding_free ( rpc_binding_rep_p_t *binding_r, unsigned32 *st ) { CODING_ERROR (st); RPC_CN_LOCK_ASSERT (); /* * Put the binding rep back on the lookaside list. */ rpc__list_element_free (&rpc_g_cn_binding_lookaside_list, (pointer_t) *binding_r); /* * Null the caller's pointer to this memory. */ *binding_r = NULL; *st = rpc_s_ok; }
void rpc_binding_inq_transport_info( rpc_binding_handle_t binding_handle, rpc_transport_info_handle_t *info, unsigned32 *st ) { rpc_binding_rep_p_t binding_r = (rpc_binding_rep_p_t) binding_handle; CODING_ERROR (st); RPC_VERIFY_INIT (); if (binding_r && binding_r->transport_info) { *info = binding_r->transport_info->handle; } else { *info = NULL; } *st = rpc_s_ok; }