Commit ae992428 authored by Martti Mela's avatar Martti Mela

API cleanup contd.

darcs-hash:20051222090014-1b897-2c7a4e7c04a2840fdae95c1d17e0151d1d2ddeac.gz
parent 1a460a9d
This diff is collapsed.
......@@ -90,18 +90,17 @@ typedef enum stun_states_e {
} stun_states_t;
typedef void (*stun_event_f)(stun_magic_t *magic,
stun_handle_t *se,
stun_states_t event);
/* Return the socket associated with the stun_socket_t structure */
int stun_handle_get_bind_socket(stun_handle_t *se);
char const *stun_str_state(stun_states_t state);
int stun_is_requested(tag_type_t tag, tag_value_t value, ...);
typedef void (*stun_event_f)(stun_magic_t *magic,
stun_handle_t *se,
stun_states_t event);
su_root_t *stun_handle_root(stun_handle_t *self);
stun_handle_t *stun_handle_tcreate(stun_magic_t *context,
......@@ -130,7 +129,7 @@ int stun_handle_bind(stun_handle_t *se,
su_localinfo_t *stun_handle_get_local_addr(stun_handle_t *en);
int stun_handle_get_nattype(stun_handle_t *se,
su_localinfo_t *my_addr,
/* su_localinfo_t *my_addr, */
int *addrlen);
int stun_handle_get_lifetime(stun_handle_t *se,
......
......@@ -554,19 +554,27 @@ int stun_free_message(stun_msg_t *msg) {
}
int stun_send_message(int sockfd, struct sockaddr_in *to_addr, stun_msg_t *msg, stun_buffer_t *pwd)
int stun_send_message(int sockfd, su_sockaddr_t *to_addr, stun_msg_t *msg, stun_buffer_t *pwd)
{
int z;
int err;
char ipaddr[SU_ADDRSIZE + 2];
stun_encode_message(msg, pwd);
z = sendto(sockfd, msg->enc_buf.data, msg->enc_buf.size,
0, (struct sockaddr *)to_addr, sizeof(*to_addr));
SU_DEBUG_3(("%s: message sent to %s:%u\n", __func__,
inet_ntoa(to_addr->sin_addr), ntohs(to_addr->sin_port)));
err = sendto(sockfd, msg->enc_buf.data, msg->enc_buf.size,
0, (struct sockaddr *)to_addr, sizeof(struct sockaddr_in));
if (err > 0) {
inet_ntop(to_addr->su_family, SU_ADDR(to_addr), ipaddr, sizeof(ipaddr));
SU_DEBUG_3(("%s: message sent to %s:%u\n", __func__,
ipaddr, ntohs(to_addr->su_port)));
debug_print(&msg->enc_buf);
}
else
STUN_ERROR(errno, sendto);
return z;
return err;
}
......
......@@ -76,13 +76,12 @@ int stun_set_uname_pwd(stun_handle_t *se, const char *uname, int len_uname,
/* internal functions declaration */
int stun_make_sharedsecret_req(stun_msg_t *msg);
int stun_bind_test(stun_handle_t *se,
su_addrinfo_t *srvr_info,
su_sockaddr_t *srvr_addr,
su_localinfo_t *clnt_addr,
int chg_ip,
int chg_port);
int stun_send_message(su_socket_t ss, struct sockaddr_in *srvr, stun_msg_t *msg, stun_buffer_t *pwd); /* client version */
int stun_send_binding_request(stun_handle_t *se,
su_sockaddr_t *srvr_addr,
su_localinfo_t *clnt_addr,
int chg_ip,
int chg_port);
int stun_send_message(su_socket_t ss, su_sockaddr_t *srvr, stun_msg_t *msg, stun_buffer_t *pwd); /* client version */
int stun_make_binding_req(stun_handle_t *se, stun_msg_t *msg, int chg_ip, int chg_port);
int stun_process_response(stun_msg_t *msg);
......
......@@ -154,7 +154,7 @@ int main(int argc, char *argv[])
lifetime = 0;
if (stun_handle_bind(se, &lifetime) < 0) {
SU_DEBUG_3(("%s: %s failed\n", __func__, "stun_bind()"));
SU_DEBUG_3(("%s: %s failed\n", __func__, "stun_handle_bind()"));
return -1;
}
......
......@@ -343,7 +343,7 @@ int torture_test_get_nattype(char *localaddr)
atonetaddr(my_addr, localaddr);
addrlen = sizeof(*my_addr);
result = stun_handle_get_nattype(se, &addr.su_sa, &addrlen); TEST(result, 0);
result = stun_handle_get_nattype(se, /* &addr.su_sa, */ &addrlen); TEST(result, 0);
printf("NAT type is: %s\n", stun_nattype(se));
su_close(s);
......
......@@ -87,10 +87,6 @@ char const help[] =
;
int getopt(int argc, char * const argv[], char const *opstring);
#if __CYGWIN__
int c_optind;
#define optind c_optind
#endif
extern int optind;
void usage(void)
......
......@@ -114,11 +114,6 @@ char const help[] =
"\t-h Host-internal addresses\n";
int getopt(int argc, char * const argv[], char const *opstring);
#if __CYGWIN__
int c_optind;
#define optind c_optind
#endif
extern int optind;
void usage(int returncode)
......
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