/**@ingroup tnet_nat_group * Gets the server reflexive address associated to this STUN2 binding. * * * @param [in,out] p_self The NAT context. * @param id The id of the STUN2 binding conetxt (obtained using @ref tnet_nat_stun_bind) holding the server-reflexive address. * @param [in,out] pp_ip The reflexive IP address. It is up the the caller to free the returned string * @param [in,out] pu_port The reflexive port. * * @return Zero if succeed and non zero error code otherwise. **/ int tnet_nat_stun_get_reflexive_address(const struct tnet_nat_ctx_s* p_self, tnet_stun_binding_id_t id, char** pp_ip, tnet_port_t *pu_port) { const tsk_list_item_t* item; if (!p_self) { TSK_DEBUG_ERROR("Invalid parameter"); return -1; } if (!pp_ip && !pu_port) { return 0; } if ((item = tsk_list_find_item_by_pred(p_self->stun_bindings, __pred_find_stun_binding, &id)) && item->data) { const tnet_stun_binding_t *pc_bind = (const tnet_stun_binding_t *)item->data; const struct tnet_stun_attr_address_s *pc_addr = pc_bind->p_xmaddr ? pc_bind->p_xmaddr : pc_bind->p_maddr; if (pc_addr) { tnet_ip_t ip; int ret; if ((ret = tnet_stun_utils_inet_ntop((pc_addr->e_family == tnet_stun_address_family_ipv6), &pc_addr->address, &ip))) { return ret; } if (pp_ip) { tsk_strupdate(pp_ip, ip); } if (pu_port) { *pu_port = pc_addr->u_port; } return 0; } } return -2; }
/** * Registers a new AUID. If the AUID already exist (case-insensitive comparison on the id), * then it will be updated with the new supplied values. * @param auids The destination list. * @param id The id of the new AUID to add (e.g. xcap-caps). * @param mime_type The MIME-Type of the new AUID to add (e.g. application/xcap-caps+xml). * @param ns The Namespace of the new AUID to add (e.g. urn:ietf:params:xml:ns:xcap-caps). * @param document_name The name of the new AUID to add (e.g. index). * @param is_global Indicates whether the AUID scope is global or not (user). * @retval Zero if succeed and non-zero error code otherwise. */ int txcap_auid_register(txcap_auids_L_t* auids, const char* id, const char* mime_type, const char* ns, const char* document_name, tsk_bool_t is_global) { const tsk_list_item_t* item; int ret = -1; if(!auids || !id){ return -1; } if((item = tsk_list_find_item_by_pred(auids, pred_find_auid_by_id, id))){ tsk_strupdate(&((txcap_auid_t*)item->data)->mime_type, mime_type); tsk_strupdate(&((txcap_auid_t*)item->data)->ns, ns); tsk_strupdate(&((txcap_auid_t*)item->data)->document_name, document_name); ((txcap_auid_t*)item->data)->global = is_global; ret = 0; } else{ txcap_auid_t* auid; if((auid = txcap_auid_create(tauid_dummy, id, mime_type, ns, document_name, is_global))){ tsk_list_push_back_data(auids, (void**)&auid); ret = 0; }else{ ret = -2; } } return ret; }
/**@ingroup tsk_params_group * Checks if the supplied list of parameters contains a parameter named @a name (case-insensitive). * @param self The list of parameters into which to search. * @param name The name of the parameter to search. * @retval @ref tsk_true if the parameter exist and @ref tsk_false otherwise. */ tsk_bool_t tsk_params_have_param(const tsk_params_L_t *self, const char* name) { if(self){ if(tsk_list_find_item_by_pred(self, pred_find_param_by_name, name)){ return tsk_true; } } else{ TSK_DEBUG_ERROR("Invalid parameter"); } return tsk_false; }
/**@ingroup tsk_params_group * Gets the value of a parameter. * @param self The source list. * @param name The name(case-insensitive) of the parameter to retrieve. * @retval The value of the parameter if succeed and NULL otherwise. */ const char *tsk_params_get_param_value(const tsk_params_L_t *self, const char* name) { if(self && name){ const tsk_list_item_t *item_const = tsk_list_find_item_by_pred(self, pred_find_param_by_name, name); if(item_const && item_const->data){ return ((const tsk_param_t *)item_const->data)->value; } } else{ TSK_DEBUG_ERROR("Invalid parameter"); } return tsk_null; }
/**@ingroup tmedia_codec_group * Remove all codecs except the specified ones. * @param codecs the list of codecs from which to remove codecs. * @param codecs2keep the codecs which shall not be removed. * @retval zero if succeed (or nothing to do) and non-zero error code otherwise. */ int tmedia_codec_removeAll_exceptThese(tmedia_codecs_L_t* codecs, const tmedia_codecs_L_t * codecs2keep) { tsk_list_item_t* item; if(!codecs || !codecs2keep) { TSK_DEBUG_ERROR("Invalid parameter"); return -1; } again: tsk_list_foreach(item, codecs) { if(!tsk_list_find_item_by_pred(codecs2keep, __pred_find_codec_by_format, ((tmedia_codec_t*)item->data)->format)) { tsk_list_remove_item(codecs, item); goto again; } } return 0; }
/** * Finds an AUID by id (case-insensitive). * @param auids List of AUIDs from which to find the AUID. * @param id The @a id of the AUID to find. * @retval An AUID with the matching id or null if does not exist. * It's up to you to free the returned object. */ txcap_auid_t* txcap_auid_get_by_id(txcap_auids_L_t* auids, const char* id) { //const txcap_auid_t* ret = tsk_null; const tsk_list_item_t* item; if(!auids){ return tsk_null; } if((item = tsk_list_find_item_by_pred(auids, pred_find_auid_by_id, id))){ return tsk_object_ref((void*)item->data); } else{ return tsk_null; } }