belle_sip_hop_t* belle_sip_hop_new_from_uri(const belle_sip_uri_t *uri){ const char *host; const char *cname=NULL; const char * transport=belle_sip_uri_get_transport_param(uri); if (!transport) { transport=belle_sip_uri_is_secure(uri)?"tls":"udp"; } host=belle_sip_uri_get_maddr_param(uri); if (!host) host=belle_sip_uri_get_host(uri); else cname=belle_sip_uri_get_host(uri); return belle_sip_hop_new( transport, cname, host, belle_sip_uri_get_listening_port(uri)); }
belle_sip_hop_t* belle_sip_hop_new_from_generic_uri(const belle_generic_uri_t *uri){ const char *host; const char * transport="TCP"; const char *scheme=belle_generic_uri_get_scheme(uri); int port=belle_generic_uri_get_port(uri); int well_known_port=0; host=belle_generic_uri_get_host(uri); if (strcasecmp(scheme,"http")==0) { transport="TCP"; well_known_port=80; }else if (strcasecmp(scheme,"https")==0) { transport="TLS"; well_known_port=443; } return belle_sip_hop_new(transport, host, host, port > 0 ? port : well_known_port); }