Commit d8d8be80 authored by Pekka Pessi's avatar Pekka Pessi
Browse files

Using su_socket() and su_socket_t. Added socket_tag_class, tag_socket_v(), tag_socket_vr().

darcs-hash:20060906191338-65a35-89465dcb1f8c7d7e4ebd11e0f9a6cf703ed847c6.gz
parent 4725a433
...@@ -90,7 +90,8 @@ int main(int argc, char *argv[]) ...@@ -90,7 +90,8 @@ int main(int argc, char *argv[])
int n, N = 0; int n, N = 0;
unsigned long portno; unsigned long portno;
unsigned short port; unsigned short port;
int af, s; int af;
su_socket_t s;
socklen_t salen; socklen_t salen;
struct sockaddr_storage ss[1]; struct sockaddr_storage ss[1];
struct sockaddr *sa = (void *)ss; struct sockaddr *sa = (void *)ss;
...@@ -177,14 +178,14 @@ int main(int argc, char *argv[]) ...@@ -177,14 +178,14 @@ int main(int argc, char *argv[])
port = portno; port = portno;
for (n = 0; n < N;) { for (n = 0; n < N;) {
s = socket(sa->sa_family = af, types[n], protos[n]); s = su_socket(sa->sa_family = af, types[n], protos[n]);
#if HAVE_SIN6 #if HAVE_SIN6
if (s == -1 && af == AF_INET6 && !o_ip6) if (s == SOCKET_ERROR && af == AF_INET6 && !o_ip6)
s = socket(sa->sa_family = af = AF_INET, types[n], protos[n]); s = su_socket(sa->sa_family = af = AF_INET, types[n], protos[n]);
#endif #endif
if (s == -1) { if (s == SOCKET_ERROR) {
fprintf(stderr, "%s: socket(AF_INET%s, 0, %s): %s\n", fprintf(stderr, "%s: socket(AF_INET%s, 0, %s): %s\n",
name, af == AF_INET ? "" : "6", names[n], strerror(errno)); name, af == AF_INET ? "" : "6", names[n], strerror(errno));
exit(1); exit(1);
......
...@@ -153,8 +153,7 @@ struct agent_t { ...@@ -153,8 +153,7 @@ struct agent_t {
/* Dummy servers */ /* Dummy servers */
char const *ag_sink_port; char const *ag_sink_port;
int ag_sink_socket; su_socket_t ag_sink_socket, ag_down_socket;
int ag_down_socket;
}; };
static int test_init(agent_t *ag, char const *resolv_conf); static int test_init(agent_t *ag, char const *resolv_conf);
...@@ -425,8 +424,9 @@ int test_init(agent_t *ag, char const *resolv_conf) ...@@ -425,8 +424,9 @@ int test_init(agent_t *ag, char const *resolv_conf)
{ {
char const *contact = "sip:*:*;comp=sigcomp"; char const *contact = "sip:*:*;comp=sigcomp";
su_sockaddr_t su; su_sockaddr_t su;
socklen_t sulen; socklen_t sulen, sulen0;
int s, af, sulen0; su_socket_t s;
int af;
BEGIN(); BEGIN();
...@@ -454,7 +454,7 @@ int test_init(agent_t *ag, char const *resolv_conf) ...@@ -454,7 +454,7 @@ int test_init(agent_t *ag, char const *resolv_conf)
contact = getenv("SIPCONTACT"); contact = getenv("SIPCONTACT");
/* Sink server */ /* Sink server */
s = socket(af, SOCK_DGRAM, 0); TEST_1(s != -1); s = socket(af, SOCK_DGRAM, 0); TEST_1(s != SOCKET_ERROR);
memset(&su, 0, sulen = sulen0); memset(&su, 0, sulen = sulen0);
su.su_family = af; su.su_family = af;
if (getenv("sink")) { if (getenv("sink")) {
...@@ -467,7 +467,7 @@ int test_init(agent_t *ag, char const *resolv_conf) ...@@ -467,7 +467,7 @@ int test_init(agent_t *ag, char const *resolv_conf)
ag->ag_sink_socket = s; ag->ag_sink_socket = s;
/* Down server */ /* Down server */
s = socket(af, SOCK_STREAM, 0); TEST_1(s != -1); s = socket(af, SOCK_STREAM, 0); TEST_1(s != SOCKET_ERROR);
memset(&su, 0, sulen = sulen0); memset(&su, 0, sulen = sulen0);
su.su_family = af; su.su_family = af;
if (getenv("down")) { if (getenv("down")) {
...@@ -701,7 +701,7 @@ static int test_bad_messages(agent_t *ag) ...@@ -701,7 +701,7 @@ static int test_bad_messages(agent_t *ag)
hints->ai_protocol = IPPROTO_UDP; hints->ai_protocol = IPPROTO_UDP;
TEST(su_getaddrinfo(host, port, hints, &ai), 0); TEST_1(ai); TEST(su_getaddrinfo(host, port, hints, &ai), 0); TEST_1(ai);
s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); TEST_1(s != -1); s = su_socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); TEST_1(s != -1);
memset(su, 0, sulen = sizeof su); memset(su, 0, sulen = sizeof su);
su->su_len = sizeof su; su->su_family = ai->ai_family; su->su_len = sizeof su; su->su_family = ai->ai_family;
TEST_1(bind(s, &su->su_sa, sulen) == 0); TEST_1(bind(s, &su->su_sa, sulen) == 0);
...@@ -2409,7 +2409,7 @@ int test_call(agent_t *ag) ...@@ -2409,7 +2409,7 @@ int test_call(agent_t *ag)
{ {
sip_content_type_t *c = ag->ag_content_type; sip_content_type_t *c = ag->ag_content_type;
sip_payload_t *sdp = ag->ag_payload; sip_payload_t *sdp = ag->ag_payload;
nta_leg_t *leg, *old_leg; nta_leg_t *old_leg;
sip_replaces_t *r1, *r2; sip_replaces_t *r1, *r2;
BEGIN(); BEGIN();
......
...@@ -151,7 +151,7 @@ static int site_create(tester_t *t, int status, char const *phrase, ...@@ -151,7 +151,7 @@ static int site_create(tester_t *t, int status, char const *phrase,
static int init_test(tester_t *t) static int init_test(tester_t *t)
{ {
int s; su_socket_t s;
char const *agent_pem; char const *agent_pem;
BEGIN(); BEGIN();
...@@ -161,7 +161,8 @@ static int init_test(tester_t *t) ...@@ -161,7 +161,8 @@ static int init_test(tester_t *t)
TEST_1(t->t_mclass); TEST_1(t->t_mclass);
t->t_addr->su_len = (sizeof t->t_addr->su_sin); t->t_addr->su_len = (sizeof t->t_addr->su_sin);
s = socket(t->t_addr->su_family = AF_INET, SOCK_STREAM, 0); TEST_1(s != -1); s = su_socket(t->t_addr->su_family = AF_INET, SOCK_STREAM, 0);
TEST_1(s != SOCKET_ERROR);
TEST_1(inet_pton(AF_INET, "127.0.0.1", &t->t_addr->su_sin.sin_addr) >= 0); TEST_1(inet_pton(AF_INET, "127.0.0.1", &t->t_addr->su_sin.sin_addr) >= 0);
TEST_1(bind(s, &t->t_addr->su_sa, TEST_1(bind(s, &t->t_addr->su_sa,
t->t_addrlen = (sizeof t->t_addr->su_sin)) != -1); t->t_addrlen = (sizeof t->t_addr->su_sin)) != -1);
...@@ -449,14 +450,14 @@ static int send_request(tester_t *t, char const *req, size_t reqlen, ...@@ -449,14 +450,14 @@ static int send_request(tester_t *t, char const *req, size_t reqlen,
char reply[], int rlen, char reply[], int rlen,
int *return_len) int *return_len)
{ {
static su_socket_t c = -1; static su_socket_t c = SOCKET_ERROR;
int m, r; int m, r;
su_wait_t w[1]; su_wait_t w[1];
BEGIN(); BEGIN();
if (c == -1) { if (c == SOCKET_ERROR) {
c = socket(t->t_addr->su_family, SOCK_STREAM, 0); TEST_1(c != -1); c = su_socket(t->t_addr->su_family, SOCK_STREAM, 0); TEST_1(c != SOCK_STREAM);
TEST_1(connect(c, &t->t_addr->su_sa, t->t_addrlen) != -1); TEST_1(connect(c, &t->t_addr->su_sa, t->t_addrlen) != -1);
while (su_root_step(t->t_root, 1) == 0); while (su_root_step(t->t_root, 1) == 0);
...@@ -613,7 +614,7 @@ static int test_requests(tester_t *t) ...@@ -613,7 +614,7 @@ static int test_requests(tester_t *t)
static int init_engine(tester_t *t) static int init_engine(tester_t *t)
{ {
BEGIN(); BEGIN();
int s; su_socket_t s;
t->t_engine = nth_engine_create(t->t_root, t->t_engine = nth_engine_create(t->t_root,
NTHTAG_STREAMING(0), NTHTAG_STREAMING(0),
......
...@@ -105,7 +105,7 @@ struct nat { ...@@ -105,7 +105,7 @@ struct nat {
/* ...but source address will be "fake" */ /* ...but source address will be "fake" */
su_localinfo_t *localinfo, *private, *fake; su_localinfo_t *localinfo, *private, *fake;
int udp_socket, tcp_socket; su_socket_t udp_socket, tcp_socket;
int udp_register, tcp_register; int udp_register, tcp_register;
char buffer[65536]; char buffer[65536];
...@@ -118,7 +118,7 @@ struct binding ...@@ -118,7 +118,7 @@ struct binding
struct binding *next, **prev; struct binding *next, **prev;
struct nat *nat; /* backpointer */ struct nat *nat; /* backpointer */
int socktype, protocol; int socktype, protocol;
int in_socket, out_socket; su_socket_t in_socket, out_socket;
int in_register, out_register; int in_register, out_register;
int in_closed, out_closed; int in_closed, out_closed;
char in_name[64], out_name[64]; char in_name[64], out_name[64];
...@@ -128,7 +128,7 @@ static struct binding *nat_binding_new(struct nat *nat, ...@@ -128,7 +128,7 @@ static struct binding *nat_binding_new(struct nat *nat,
char const *protoname, char const *protoname,
int socktype, int protocol, int socktype, int protocol,
int connected, int connected,
int in_socket, su_socket_t in_socket,
su_sockaddr_t *from, su_sockaddr_t *from,
socklen_t fromlen); socklen_t fromlen);
static void nat_binding_destroy(struct binding *); static void nat_binding_destroy(struct binding *);
...@@ -165,7 +165,7 @@ test_nat_init(su_root_t *root, struct nat *nat) ...@@ -165,7 +165,7 @@ test_nat_init(su_root_t *root, struct nat *nat)
su_wait_t wait[1]; su_wait_t wait[1];
nat->root = root; nat->root = root;
nat->udp_socket = -1, nat->tcp_socket = -1; nat->udp_socket = SOCKET_ERROR, nat->tcp_socket = SOCKET_ERROR;
tl_gets(nat->tags, tl_gets(nat->tags,
TESTNATTAG_SYMMETRIC_REF(nat->symmetric), TESTNATTAG_SYMMETRIC_REF(nat->symmetric),
...@@ -201,7 +201,7 @@ test_nat_init(su_root_t *root, struct nat *nat) ...@@ -201,7 +201,7 @@ test_nat_init(su_root_t *root, struct nat *nat)
/* Bind TCP and UDP to same port */ /* Bind TCP and UDP to same port */
for (;;) { for (;;) {
nat->udp_socket = su_socket(li->li_family, SOCK_DGRAM, IPPROTO_UDP); nat->udp_socket = su_socket(li->li_family, SOCK_DGRAM, IPPROTO_UDP);
if (nat->udp_socket == -1) if (nat->udp_socket == SOCKET_ERROR)
return -1; return -1;
if (bind(nat->udp_socket, (void *)su, sulen) < 0) { if (bind(nat->udp_socket, (void *)su, sulen) < 0) {
...@@ -212,9 +212,9 @@ test_nat_init(su_root_t *root, struct nat *nat) ...@@ -212,9 +212,9 @@ test_nat_init(su_root_t *root, struct nat *nat)
fprintf(stderr, "test_nat: port %u: %s\n", fprintf(stderr, "test_nat: port %u: %s\n",
port, su_strerror(su_errno())); port, su_strerror(su_errno()));
su_close(nat->udp_socket); su_close(nat->udp_socket);
nat->udp_socket = -1;
nat->udp_socket = SOCKET_ERROR;
if (++port > 65535) if (++port > 65535)
port = 1024; port = 1024;
...@@ -240,12 +240,12 @@ test_nat_init(su_root_t *root, struct nat *nat) ...@@ -240,12 +240,12 @@ test_nat_init(su_root_t *root, struct nat *nat)
} }
nat->tcp_socket = su_socket(li->li_family, SOCK_STREAM, IPPROTO_TCP); nat->tcp_socket = su_socket(li->li_family, SOCK_STREAM, IPPROTO_TCP);
if (nat->tcp_socket == -1) if (nat->tcp_socket == SOCKET_ERROR)
return -1; return -1;
if (bind(nat->tcp_socket, (void *)su, sulen) < 0) { if (bind(nat->tcp_socket, (void *)su, sulen) < 0) {
su_close(nat->tcp_socket); su_close(nat->tcp_socket);
nat->tcp_socket = -1; nat->tcp_socket = SOCKET_ERROR;
fprintf(stderr, "test_nat: port %u: %s\n", fprintf(stderr, "test_nat: port %u: %s\n",
port, su_strerror(su_errno())); port, su_strerror(su_errno()));
...@@ -311,9 +311,9 @@ test_nat_deinit(su_root_t *root, struct nat *nat) ...@@ -311,9 +311,9 @@ test_nat_deinit(su_root_t *root, struct nat *nat)
if (nat->udp_register) if (nat->udp_register)
su_root_deregister(root, nat->udp_register); su_root_deregister(root, nat->udp_register);
if (nat->udp_socket != -1) if (nat->udp_socket != SOCKET_ERROR)
su_close(nat->udp_socket); su_close(nat->udp_socket);
if (nat->tcp_socket != -1) if (nat->tcp_socket != SOCKET_ERROR)
su_close(nat->tcp_socket); su_close(nat->tcp_socket);
su_freelocalinfo(nat->localinfo); su_freelocalinfo(nat->localinfo);
...@@ -427,7 +427,7 @@ struct binding *nat_binding_new(struct nat *nat, ...@@ -427,7 +427,7 @@ struct binding *nat_binding_new(struct nat *nat,
int socktype, int socktype,
int protocol, int protocol,
int connected, int connected,
int in_socket, su_socket_t in_socket,
su_sockaddr_t *from, su_sockaddr_t *from,
socklen_t fromlen) socklen_t fromlen)
{ {
...@@ -466,7 +466,7 @@ static int binding_init(struct binding *b, ...@@ -466,7 +466,7 @@ static int binding_init(struct binding *b,
socklen_t fromlen) socklen_t fromlen)
{ {
struct nat *nat = b->nat; struct nat *nat = b->nat;
int out_socket; su_socket_t out_socket;
su_sockaddr_t addr[1]; su_sockaddr_t addr[1];
socklen_t addrlen = (sizeof addr); socklen_t addrlen = (sizeof addr);
char ipname[64]; char ipname[64];
...@@ -478,11 +478,11 @@ static int binding_init(struct binding *b, ...@@ -478,11 +478,11 @@ static int binding_init(struct binding *b,
else else
in_to_out = udp_in_to_out, out_to_in = udp_out_to_in; in_to_out = udp_in_to_out, out_to_in = udp_out_to_in;
if (b->in_socket == -1) { if (b->in_socket == SOCKET_ERROR) {
int in_socket; int in_socket;
in_socket = su_socket(from->su_family, b->socktype, b->protocol); in_socket = su_socket(from->su_family, b->socktype, b->protocol);
if (in_socket < 0) { if (in_socket == SOCKET_ERROR) {
su_perror("nat_binding_new: socket"); su_perror("nat_binding_new: socket");
return -1; return -1;
} }
...@@ -502,7 +502,7 @@ static int binding_init(struct binding *b, ...@@ -502,7 +502,7 @@ static int binding_init(struct binding *b,
} }
out_socket = su_socket(li->li_family, b->socktype, b->protocol); out_socket = su_socket(li->li_family, b->socktype, b->protocol);
if (out_socket < 0) { if (out_socket == SOCKET_ERROR) {
su_perror("nat_binding_new: socket"); su_perror("nat_binding_new: socket");
return -1; return -1;
} }
...@@ -717,7 +717,7 @@ static int udp_out_to_in(struct nat *nat, su_wait_t *wait, struct binding *b) ...@@ -717,7 +717,7 @@ static int udp_out_to_in(struct nat *nat, su_wait_t *wait, struct binding *b)
static int new_tcp(struct nat *nat, su_wait_t *wait, struct binding *dummy) static int new_tcp(struct nat *nat, su_wait_t *wait, struct binding *dummy)
{ {
int events; int events;
int in_socket; su_socket_t in_socket;
su_sockaddr_t from[1]; su_sockaddr_t from[1];
socklen_t fromlen = (sizeof from); socklen_t fromlen = (sizeof from);
struct binding *b; struct binding *b;
...@@ -725,7 +725,7 @@ static int new_tcp(struct nat *nat, su_wait_t *wait, struct binding *dummy) ...@@ -725,7 +725,7 @@ static int new_tcp(struct nat *nat, su_wait_t *wait, struct binding *dummy)
events = su_wait_events(wait, nat->tcp_socket); events = su_wait_events(wait, nat->tcp_socket);
in_socket = accept(nat->tcp_socket, (void *)from, &fromlen); in_socket = accept(nat->tcp_socket, (void *)from, &fromlen);
if (in_socket < 0) { if (in_socket == SOCKET_ERROR) {
su_perror("new_tcp: accept"); su_perror("new_tcp: accept");
return 0; return 0;
} }
...@@ -822,12 +822,13 @@ static int invalidate_binding(struct binding *b) ...@@ -822,12 +822,13 @@ static int invalidate_binding(struct binding *b)
struct nat *nat = b->nat; struct nat *nat = b->nat;
su_sockaddr_t addr[1]; su_sockaddr_t addr[1];
socklen_t addrlen = (sizeof addr); socklen_t addrlen = (sizeof addr);
int out, out_register; su_socket_t out;
int out_register;
su_wait_t wout[1]; su_wait_t wout[1];
char name[64]; char name[64];
out = su_socket(nat->fake->li_family, b->socktype, 0); out = su_socket(nat->fake->li_family, b->socktype, 0);
if (out < 0) { if (out == SOCKET_ERROR) {
su_perror("new_udp: socket"); su_perror("new_udp: socket");
return -1; return -1;
} }
......
...@@ -291,10 +291,12 @@ SOFIAPUBFUN int stun_dns_lookup_stp_addr(stun_dns_lookup_t *self, ...@@ -291,10 +291,12 @@ SOFIAPUBFUN int stun_dns_lookup_stp_addr(stun_dns_lookup_t *self,
SOFIAPUBFUN stun_mini_t *stun_mini_create(void); SOFIAPUBFUN stun_mini_t *stun_mini_create(void);
SOFIAPUBFUN void stun_mini_destroy(stun_mini_t *); SOFIAPUBFUN void stun_mini_destroy(stun_mini_t *);
SOFIAPUBFUN int stun_mini_add_socket(stun_mini_t *server, int socket); SOFIAPUBFUN int stun_mini_add_socket(stun_mini_t *server,
SOFIAPUBFUN int stun_mini_remove_socket(stun_mini_t *server, int socket); su_socket_t socket);
SOFIAPUBFUN int stun_mini_remove_socket(stun_mini_t *server,
su_socket_t socket);
SOFIAPUBFUN void stun_mini_request(stun_mini_t *server, int socket, SOFIAPUBFUN void stun_mini_request(stun_mini_t *server, su_socket_t socket,
void *msg, ssize_t msglen, void *msg, ssize_t msglen,
void *addr, socklen_t addrlen); void *addr, socklen_t addrlen);
......
...@@ -36,6 +36,9 @@ ...@@ -36,6 +36,9 @@
#ifndef SU_TAG_H #ifndef SU_TAG_H
#include <sofia-sip/su_tag.h> #include <sofia-sip/su_tag.h>
#endif #endif
#ifndef SU_TAG_IO_H
#include <sofia-sip/su_tag_io.h>
#endif
SOFIA_BEGIN_DECLS SOFIA_BEGIN_DECLS
...@@ -66,9 +69,9 @@ SOFIAPUBVAR tag_typedef_t stuntag_integrity; ...@@ -66,9 +69,9 @@ SOFIAPUBVAR tag_typedef_t stuntag_integrity;
#define STUNTAG_INTEGRITY_REF(x) stuntag_integrity_ref, tag_int_vr(&(x)) #define STUNTAG_INTEGRITY_REF(x) stuntag_integrity_ref, tag_int_vr(&(x))
SOFIAPUBVAR tag_typedef_t stuntag_integrity_ref; SOFIAPUBVAR tag_typedef_t stuntag_integrity_ref;
#define STUNTAG_SOCKET(x) stuntag_socket, tag_int_v(x) #define STUNTAG_SOCKET(x) stuntag_socket, tag_socket_v(x)
SOFIAPUBVAR tag_typedef_t stuntag_socket; SOFIAPUBVAR tag_typedef_t stuntag_socket;
#define STUNTAG_SOCKET_REF(x) stuntag_socket_ref, tag_int_vr(&(x)) #define STUNTAG_SOCKET_REF(x) stuntag_socket_ref, tag_socket_vr(&(x))
SOFIAPUBVAR tag_typedef_t stuntag_socket_ref; SOFIAPUBVAR tag_typedef_t stuntag_socket_ref;
#define STUNTAG_REGISTER_EVENTS(x) stuntag_register_events, tag_int_v(x) #define STUNTAG_REGISTER_EVENTS(x) stuntag_register_events, tag_int_v(x)
......
...@@ -547,7 +547,7 @@ int stun_obtain_shared_secret(stun_handle_t *sh, ...@@ -547,7 +547,7 @@ int stun_obtain_shared_secret(stun_handle_t *sh,
/* open tcp connection to server */ /* open tcp connection to server */
s = su_socket(family = AF_INET, SOCK_STREAM, 0); s = su_socket(family = AF_INET, SOCK_STREAM, 0);
if (s == -1) { if (s == SOCKET_ERROR) {
STUN_ERROR(errno, socket); STUN_ERROR(errno, socket);
return -1; return -1;
} }
...@@ -738,7 +738,8 @@ void stun_handle_destroy(stun_handle_t *sh) ...@@ -738,7 +738,8 @@ void stun_handle_destroy(stun_handle_t *sh)
/** Create wait object and register it to the handle callback */ /** Create wait object and register it to the handle callback */
int assign_socket(stun_discovery_t *sd, su_socket_t s, int reg_socket) static
int assign_socket(stun_discovery_t *sd, su_socket_t s, int register_socket)
{ {
stun_handle_t *sh = sd->sd_handle; stun_handle_t *sh = sd->sd_handle;
int events; int events;
...@@ -754,8 +755,8 @@ int assign_socket(stun_discovery_t *sd, su_socket_t s, int reg_socket) ...@@ -754,8 +755,8 @@ int assign_socket(stun_discovery_t *sd, su_socket_t s, int reg_socket)
enter; enter;
if (s == -1) { if (s == SOCKET_ERROR) {
SU_DEBUG_3(("%s: invalid socket.\n", __func__)); SU_DEBUG_3(("%s: invalid socket\n", __func__));
return errno = EINVAL, -1; return errno = EINVAL, -1;
} }
...@@ -769,7 +770,7 @@ int assign_socket(stun_discovery_t *sd, su_socket_t s, int reg_socket) ...@@ -769,7 +770,7 @@ int assign_socket(stun_discovery_t *sd, su_socket_t s, int reg_socket)
} }
sd->sd_socket = s; sd->sd_socket = s;
if (reg_socket != 1) if (!register_socket)
return 0; return 0;
/* set socket asynchronous */ /* set socket asynchronous */
...@@ -1037,7 +1038,7 @@ int stun_bind(stun_handle_t *sh, ...@@ -1037,7 +1038,7 @@ int stun_bind(stun_handle_t *sh,
tag_type_t tag, tag_value_t value, tag_type_t tag, tag_value_t value,
...) ...)
{ {
su_socket_t s = -1; su_socket_t s = SOCKET_ERROR;
stun_request_t *req = NULL; stun_request_t *req = NULL;
stun_discovery_t *sd = NULL; stun_discovery_t *sd = NULL;
ta_list ta; ta_list ta;
...@@ -1206,7 +1207,7 @@ int stun_test_nattype(stun_handle_t *sh, ...@@ -1206,7 +1207,7 @@ int stun_test_nattype(stun_handle_t *sh,
stun_request_t *req = NULL; stun_request_t *req = NULL;
stun_discovery_t *sd = NULL; stun_discovery_t *sd = NULL;
su_sockaddr_t bind_addr; su_sockaddr_t bind_addr;
su_socket_t s = -1; su_socket_t s = SOCKET_ERROR;
socklen_t bind_len; socklen_t bind_len;
su_sockaddr_t *destination = NULL; su_sockaddr_t *destination = NULL;
...@@ -1496,7 +1497,7 @@ static int stun_tls_callback(su_root_magic_t *m, su_wait_t *w, su_wakeup_arg_t * ...@@ -1496,7 +1497,7 @@ static int stun_tls_callback(su_root_magic_t *m, su_wait_t *w, su_wakeup_arg_t *
/* closed TLS connection */ /* closed TLS connection */
SSL_shutdown(ssl); SSL_shutdown(ssl);
su_close(sd->sd_socket); su_close(sd->sd_socket), sd->sd_socket = SOCKET_ERROR;
SSL_free(self->sh_ssl), ssl = NULL; SSL_free(self->sh_ssl), ssl = NULL;
SSL_CTX_free(self->sh_ctx), ctx = NULL; SSL_CTX_free(self->sh_ctx), ctx = NULL;
...@@ -2411,7 +2412,7 @@ static int stun_send_binding_request(stun_request_t *req, ...@@ -2411,7 +2412,7 @@ static int stun_send_binding_request(stun_request_t *req,
su_sockaddr_t *srvr_addr) su_sockaddr_t *srvr_addr)
{ {
su_timer_t *sendto_timer = NULL; su_timer_t *sendto_timer = NULL;
int s; su_socket_t s;
stun_handle_t *sh = req->sr_handle; stun_handle_t *sh = req->sr_handle;
stun_msg_t *msg = req->sr_msg; stun_msg_t *msg = req->sr_msg;
...@@ -2705,7 +2706,8 @@ int stun_test_lifetime(stun_handle_t *sh, ...@@ -2705,7 +2706,8 @@ int stun_test_lifetime(stun_handle_t *sh,
stun_request_t *req = NULL; stun_request_t *req = NULL;
stun_discovery_t *sd = NULL; stun_discovery_t *sd = NULL;
ta_list ta; ta_list ta;
int s = -1, err, index = 0, s_reg = 0; su_socket_t s = SOCKET_ERROR;
int err, index = 0, s_reg = 0;
char ipaddr[SU_ADDRSIZE + 2] = { 0 }; char ipaddr[SU_ADDRSIZE + 2] = { 0 };
char const *server = NULL;