Commit c3a4a480 authored by Kai Vehmanen's avatar Kai Vehmanen

Fixed operations on Transaction-ID. TID is a 128bit opaque value.

darcs-hash:20060328195051-56829-7b448e06aa48c9e0a7f86ef488ed8bca47af435e.gz
parent 0a6e486a
......@@ -99,6 +99,8 @@ SOFIA_BEGIN_DECLS
#define RAND_MAX_16 65535
#define STUN_TID_BYTES 16
/* other protocol specific parameters */
#define STUN_MAX_RETRX 5 /* should be 8? */
#define STUN_MAX_RETRX_INT 1600 /**< max retrx interval in
......
......@@ -38,6 +38,7 @@
#include "config.h"
#include <assert.h>
#include <string.h>
#define SU_ROOT_MAGIC_T struct stun_magic_t
......@@ -1695,7 +1696,7 @@ int stun_make_sharedsecret_req(stun_msg_t *msg)
msg->stun_hdr.msg_type = SHARED_SECRET_REQUEST;
msg->stun_hdr.msg_len = 0; /* actual len computed by
stun_send_message */
for (i = 0; i < 8; i++) {
for (i = 0; i < STUN_TID_BYTES; i++) {
msg->stun_hdr.tran_id[i] = (1 + rand() % RAND_MAX_16);
}
......@@ -1715,12 +1716,9 @@ int stun_make_sharedsecret_req(stun_msg_t *msg)
memcpy(msg->enc_buf.data+len, &tmp, sizeof(tmp));
len+=sizeof(tmp);
for (i = 0; i < 8; i++) {
tmp = htons(msg->stun_hdr.tran_id[i]);
memcpy(msg->enc_buf.data+len, &tmp, sizeof(tmp));
len+=sizeof(tmp);
}
memcpy(msg->enc_buf.data+len, msg->stun_hdr.tran_id, STUN_TID_BYTES);
len+=STUN_TID_BYTES;
return 0;
}
......@@ -1742,7 +1740,7 @@ stun_action_t get_action(stun_request_t *req)
/* Find request from the request queue, based on TID */
static inline
stun_request_t *find_request(stun_handle_t *self, void *id)
stun_request_t *priv_find_request(stun_handle_t *self, void *id)
{
void *match;
stun_request_t *req = NULL;
......@@ -2506,7 +2504,7 @@ int stun_make_binding_req(stun_handle_t *sh,
msg->stun_hdr.msg_type = BINDING_REQUEST;
msg->stun_hdr.msg_len = 0; /* actual len computed by
stun_send_message */
for (i = 0; i < 8; i++) {
for (i = 0; i < STUN_TID_BYTES; i++) {
msg->stun_hdr.tran_id[i] = (1 + rand() % RAND_MAX_16);
}
......@@ -3105,7 +3103,7 @@ int stun_process_request(su_socket_t s, stun_msg_t *req,
resp.stun_hdr.msg_type = BINDING_RESPONSE;
resp.stun_hdr.msg_len = 0; /* actual len computed later */
for (i = 0; i < 8; i++) {
for (i = 0; i < STUN_TID_BYTES; i++) {
resp.stun_hdr.tran_id[i] = req->stun_hdr.tran_id[i];
}
p = &(resp.stun_attr);
......
......@@ -82,7 +82,7 @@ int stun_parse_message(stun_msg_t *msg)
p = msg->enc_buf.data;
msg->stun_hdr.msg_type = get16(p, 0);
msg->stun_hdr.msg_len = get16(p, 2);
memcpy(msg->stun_hdr.tran_id, p + 4, 16);
memcpy(msg->stun_hdr.tran_id, p + 4, STUN_TID_BYTES);
SU_DEBUG_5(("%s: Parse STUN message: Length = %d\n", __func__,
msg->stun_hdr.msg_len));
......@@ -688,7 +688,7 @@ int stun_encode_message(stun_msg_t *msg, stun_buffer_t *pwd) {
/* convert to binary format for transmission */
set16(buf, 0, msg->stun_hdr.msg_type);
set16(buf, 2, msg->stun_hdr.msg_len);
memcpy(buf + 4, msg->stun_hdr.tran_id, 16);
memcpy(buf + 4, msg->stun_hdr.tran_id, STUN_TID_BYTES);
len = 20;
......
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