Commit 71bcd792 authored by Ghislain MARY's avatar Ghislain MARY

Huge rework to prepare use of ICE with IPv6.

parent e84dc4d0
......@@ -153,7 +153,8 @@ typedef struct _IceStunServerRequest {
typedef struct _IceTransportAddress {
char ip[64];
int port;
// TODO: Handling of IP version (4 or 6) and transport type: TCP, UDP...
int family;
// TODO: Handling of transport type: TCP, UDP...
} IceTransportAddress;
/**
......@@ -698,6 +699,7 @@ MS2_PUBLIC const char * ice_candidate_type(const IceCandidate *candidate);
*
* @param cl A pointer to a check list
* @param type The type of the local candidate to add as a string (must be one of: "host", "srflx", "prflx" or "relay")
* @param family The address family of the local candidate (AF_INET or AF_INET6)
* @param ip The IP address of the local candidate as a string (eg. 192.168.0.10)
* @param port The port of the local candidate
* @param componentID The component ID of the local candidate (usually 1 for RTP and 2 for RTCP)
......@@ -705,13 +707,14 @@ MS2_PUBLIC const char * ice_candidate_type(const IceCandidate *candidate);
*
* This function is to be called when gathering local candidates.
*/
MS2_PUBLIC IceCandidate * ice_add_local_candidate(IceCheckList *cl, const char *type, const char *ip, int port, uint16_t componentID, IceCandidate *base);
MS2_PUBLIC IceCandidate * ice_add_local_candidate(IceCheckList *cl, const char *type, int family, const char *ip, int port, uint16_t componentID, IceCandidate *base);
/**
* Add a remote candidate to an ICE check list.
*
* @param cl A pointer to a check list
* @param type The type of the remote candidate to add as a string (must be one of: "host", "srflx", "prflx" or "relay")
* @param family The address family of the remote candidate (AF_INET or AF_INET6)
* @param ip The IP address of the remote candidate as a string (eg. 192.168.0.10)
* @param port The port of the remote candidate
* @param componentID The component ID of the remote candidate (usually 1 for RTP and 2 for RTCP)
......@@ -721,13 +724,14 @@ MS2_PUBLIC IceCandidate * ice_add_local_candidate(IceCheckList *cl, const char *
*
* This function is to be called once the remote candidate list has been received via SDP.
*/
MS2_PUBLIC IceCandidate * ice_add_remote_candidate(IceCheckList *cl, const char *type, const char *ip, int port, uint16_t componentID, uint32_t priority, const char * const foundation, bool_t is_default);
MS2_PUBLIC IceCandidate * ice_add_remote_candidate(IceCheckList *cl, const char *type, int family, const char *ip, int port, uint16_t componentID, uint32_t priority, const char * const foundation, bool_t is_default);
/**
* Add a losing pair to an ICE check list.
*
* @param cl A pointer to a check list
* @param componentID The component ID of the candidates of the pair to add
* @param family The address family of the candidates (AF_INET or AF_INET6)
* @param local_addr The address of the local candidate of the pair to add
* @param local_port The port of the local candidate of the pair to add
* @param remote_addr The address of the remote candidate of the pair to add
......@@ -735,7 +739,7 @@ MS2_PUBLIC IceCandidate * ice_add_remote_candidate(IceCheckList *cl, const char
*
* This function is to be called when a RE-INVITE with an SDP containing a remote-candidates attribute is received.
*/
MS2_PUBLIC void ice_add_losing_pair(IceCheckList *cl, uint16_t componentID, const char *local_addr, int local_port, const char *remote_addr, int remote_port);
MS2_PUBLIC void ice_add_losing_pair(IceCheckList *cl, uint16_t componentID, int family, const char *local_addr, int local_port, const char *remote_addr, int remote_port);
/**
* Get the number of losing candidate pairs for an ICE session.
......
......@@ -147,7 +147,8 @@ typedef void (*MSIterate3Func)(void *a, void *b, void *c);
extern "C"{
#endif
/*for stun*/
typedef struct { unsigned char octet[12]; } UInt96;
typedef struct { unsigned char octet[12]; } UInt96;
typedef struct { unsigned char octet[16]; } UInt128;
MS2_PUBLIC void ms_thread_exit(void* ret_val);
......
......@@ -107,7 +107,15 @@ typedef struct {
} MSStunAddress4;
typedef struct {
MSStunAddress4 ipv4;
uint16_t port;
UInt128 addr;
} MSStunAddress6;
typedef struct {
union {
MSStunAddress4 v4;
MSStunAddress6 v6;
} ip;
uint8_t family;
} MSStunAddress;
......@@ -193,7 +201,13 @@ extern "C"
typedef void (*MSStunAuthRequestedCb)(void *userdata, const char *realm, const char *nonce, const char **username, const char **password, const char **ha1);
MS2_PUBLIC MSStunAddress4 ms_stun_hostname_to_stun_addr(const char *hostname, uint16_t default_port);
MS2_PUBLIC bool_t ms_compare_stun_addresses(const MSStunAddress *a1, const MSStunAddress *a2);
MS2_PUBLIC int ms_stun_family_to_af(int stun_family);
MS2_PUBLIC void ms_stun_address_to_sockaddr(const MSStunAddress *stun_addr, struct sockaddr *addr, socklen_t *addrlen);
MS2_PUBLIC void ms_sockaddr_to_stun_address(const struct sockaddr *addr, MSStunAddress *stun_addr);
MS2_PUBLIC MSStunAddress ms_ip_address_to_stun_address(int ai_family, int socktype, const char *hostname, int port);
MS2_PUBLIC void ms_stun_address_to_ip_address(const MSStunAddress *stun_address, char *ip, size_t ip_size, int *port);
MS2_PUBLIC void ms_stun_address_to_printable_ip_address(const MSStunAddress *stun_address, char *printable_ip, size_t printable_ip_size);
MS2_PUBLIC char * ms_stun_calculate_integrity_short_term(const char *buf, size_t bufsize, const char *key);
MS2_PUBLIC char * ms_stun_calculate_integrity_long_term(const char *buf, size_t bufsize, const char *realm, const char *username, const char *password);
MS2_PUBLIC char * ms_stun_calculate_integrity_long_term_from_ha1(const char *buf, size_t bufsize, const char *ha1_text);
......
This diff is collapsed.
This diff is collapsed.
......@@ -818,8 +818,8 @@ void setup_media_streams(MediastreamDatas* args) {
int c;
for (c=0;c<args->ice_local_candidates_nb;c++){
candidate=&args->ice_local_candidates[c];
ice_add_local_candidate(args->audio->ms.ice_check_list,candidate->type,candidate->ip,candidate->port,1,NULL);
ice_add_local_candidate(args->audio->ms.ice_check_list,candidate->type,candidate->ip,candidate->port+1,2,NULL);
ice_add_local_candidate(args->audio->ms.ice_check_list,candidate->type,AF_INET,candidate->ip,candidate->port,1,NULL);
ice_add_local_candidate(args->audio->ms.ice_check_list,candidate->type,AF_INET,candidate->ip,candidate->port+1,2,NULL);
}
}
if (args->ice_remote_candidates_nb) {
......@@ -830,8 +830,8 @@ void setup_media_streams(MediastreamDatas* args) {
candidate=&args->ice_remote_candidates[c];
memset(foundation, '\0', sizeof(foundation));
snprintf(foundation, sizeof(foundation) - 1, "%u", c + 1);
ice_add_remote_candidate(args->audio->ms.ice_check_list,candidate->type,candidate->ip,candidate->port,1,0,foundation,FALSE);
ice_add_remote_candidate(args->audio->ms.ice_check_list,candidate->type,candidate->ip,candidate->port+1,2,0,foundation,FALSE);
ice_add_remote_candidate(args->audio->ms.ice_check_list,candidate->type,AF_INET,candidate->ip,candidate->port,1,0,foundation,FALSE);
ice_add_remote_candidate(args->audio->ms.ice_check_list,candidate->type,AF_INET,candidate->ip,candidate->port+1,2,0,foundation,FALSE);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment