Commit 2a4660c1 authored by Pekka Pessi's avatar Pekka Pessi

Fixed stun miniserver (and stun stub in tport).

darcs-hash:20060404175757-88462-2df2a1ed28c4d021c7339606108ce9494b7cb8ed.gz
parent 957f0037
......@@ -653,9 +653,8 @@ int stun_encode_message(stun_msg_t *msg, stun_buffer_t *pwd) {
if (msg->enc_buf.data == NULL) {
/* convert msg to binary format */
/* convert attributes to binary format for transmission */
attr = msg->stun_attr;
len = 0;
while(attr) {
for (attr = msg->stun_attr; attr ; attr = attr->next) {
switch(attr->attr_type) {
case RESPONSE_ADDRESS:
case MAPPED_ADDRESS:
......@@ -668,8 +667,6 @@ int stun_encode_message(stun_msg_t *msg, stun_buffer_t *pwd) {
case TURN_SOURCE_ADDRESS:
#endif
z = stun_encode_address(attr);
if(z < 0) return z;
len += z;
break;
case CHANGE_REQUEST:
#ifdef USE_TURN
......@@ -678,8 +675,6 @@ int stun_encode_message(stun_msg_t *msg, stun_buffer_t *pwd) {
case TURN_BANDWIDTH:
#endif
z = stun_encode_uint32(attr);
if (z < 0) return z;
len += z;
break;
case USERNAME:
......@@ -690,21 +685,21 @@ int stun_encode_message(stun_msg_t *msg, stun_buffer_t *pwd) {
case TURN_DATA:
#endif
z = stun_encode_buffer(attr);
if(z < 0) return z;
len += z;
break;
case MESSAGE_INTEGRITY:
msg_int = attr;
len += 24; /* postpone encoding to 2nd round */
z = 24;
break;
case ERROR_CODE:
z = stun_encode_error_code(attr);
if(z < 0) return z;
len += z;
default:
break;
z = 0;
}
attr = attr->next;
if(z < 0) return z;
len += z;
}
msg->stun_hdr.msg_len = len;
......
......@@ -326,11 +326,11 @@ int process_3489_request(stun_mini_t *mini,
a->attr_type = CHANGED_ADDRESS;
addr = malloc(sizeof *addr); if (!addr) return STUN_500_SERVER_ERROR;
memcpy(addr, changed->ss_addr.array, sizeof *addr);
}
a->pattr = addr;
a->next = NULL;
*next = a; next = &(a->next);
a->pattr = addr;
a->next = NULL;
*next = a; next = &(a->next);
}
stun_send_message(socket, (void *)from, response, NULL);
......
......@@ -150,7 +150,7 @@ int tport_recv_stun_dgram(tport_t const *self, int N)
status = 500, error = "Server Error";
}
if (dgram[1] == 1) {
if (dgram[0] == 1) {
/* This is a response. */
if (self->tp_pri->pri_vtable->vtp_stun_response) {
if (self->tp_pri->pri_vtable->vtp_stun_response(self, dgram, n,
......
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