parent
2874c641f5
commit
edfef1c6a2
|
@ -18,4 +18,23 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
*/
|
||||
/**@file tnet_dns.h
|
||||
* @brief DNS utilities functions (RFCS [1034 1035] [3401 3402 3403 3404]).
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
|
||||
#ifndef TNET_DNS_H
|
||||
#define TNET_DNS_H
|
||||
|
||||
#include "tinyNET_config.h"
|
||||
|
||||
TNET_BEGIN_DECLS
|
||||
|
||||
|
||||
TNET_END_DECLS
|
||||
|
||||
#endif /* TNET_DNS_H */
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* This file is part of Open Source Doubango Framework.
|
||||
*
|
||||
* DOUBANGO is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* DOUBANGO is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
/**@file tnet_dns_message.h
|
||||
* @brief DNS Message holding RRs (RFC 1035).
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#include "tnet_dns_message.h"
|
||||
|
||||
#include "tsk_memory.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//========================================================
|
||||
// [[DNS MESSAGE]] object definition
|
||||
//
|
||||
static void* tnet_dns_message_create(void * self, va_list * app)
|
||||
{
|
||||
tnet_dns_message_t *message = self;
|
||||
if(message)
|
||||
{
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
static void* tnet_dns_message_destroy(void * self)
|
||||
{
|
||||
tnet_dns_message_t *message = self;
|
||||
if(message)
|
||||
{
|
||||
TSK_FREE(message->Question.QNAME);
|
||||
|
||||
TSK_OBJECT_SAFE_FREE(message->Answers);
|
||||
TSK_OBJECT_SAFE_FREE(message->Authoritys);
|
||||
TSK_OBJECT_SAFE_FREE(message->Additionals);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
static const tsk_object_def_t tnet_dns_message_def_s =
|
||||
{
|
||||
sizeof(tnet_dns_message_t),
|
||||
tnet_dns_message_create,
|
||||
tnet_dns_message_destroy,
|
||||
0,
|
||||
};
|
||||
const void *tnet_dns_message_def_t = &tnet_dns_message_def_s;
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* This file is part of Open Source Doubango Framework.
|
||||
*
|
||||
* DOUBANGO is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* DOUBANGO is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
/**@file tnet_dns_message.h
|
||||
* @brief DNS Message holding RRs (RFC 1035).
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
|
||||
#ifndef TNET_DNS_MESSAGE_H
|
||||
#define TNET_DNS_MESSAGE_H
|
||||
|
||||
#include "tinyNET_config.h"
|
||||
|
||||
#include "tnet_dns_rr.h"
|
||||
|
||||
TNET_BEGIN_DECLS
|
||||
|
||||
/** Response code as per RFC 1035 subclause 4.1.1.
|
||||
*/
|
||||
typedef enum tnet_dns_rcode_e
|
||||
{
|
||||
rcode_noerror = 0,
|
||||
rcode_error_format = 1,
|
||||
rcode_server_failure = 2,
|
||||
rcode_error_name = 3,
|
||||
rcode_notimplemented = 4,
|
||||
rcode_refused = 5
|
||||
}
|
||||
tnet_dns_rcode_t;
|
||||
|
||||
/** DNS message as per RFC 1035 subclause 4.
|
||||
*/
|
||||
typedef struct tnet_dns_message_s
|
||||
{
|
||||
TSK_DECLARE_OBJECT;
|
||||
|
||||
/* RFC 1035 - 4.1. Format
|
||||
+---------------------+
|
||||
| Header |
|
||||
+---------------------+
|
||||
| Question | the question for the name server
|
||||
+---------------------+
|
||||
| Answer | RRs answering the question
|
||||
+---------------------+
|
||||
| Authority | RRs pointing toward an authority
|
||||
+---------------------+
|
||||
| Additional | RRs holding additional information
|
||||
+---------------------+
|
||||
*/
|
||||
|
||||
/* RFC 1035 - 4.1.1. Header section format
|
||||
1 1 1 1 1 1
|
||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| ID |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
|QR| Opcode |AA|TC|RD|RA| Z | RCODE |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| QDCOUNT |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| ANCOUNT |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| NSCOUNT |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| ARCOUNT |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*/
|
||||
struct
|
||||
{
|
||||
uint16_t ID;
|
||||
unsigned QR:1;
|
||||
unsigned OPCODE:4;
|
||||
unsigned AA:1;
|
||||
unsigned TC:1;
|
||||
unsigned RD:1;
|
||||
unsigned RA:1;
|
||||
unsigned Z:3;
|
||||
unsigned RCODE:4; /* see @ref tnet_dns_rcode_t */
|
||||
uint16_t QDCOUNT;
|
||||
uint16_t ANCOUNT;
|
||||
uint16_t NSCOUNT;
|
||||
uint16_t ARCOUNT;
|
||||
}
|
||||
Header;
|
||||
|
||||
/* RFc 1035 - 4.1.2. Question section format
|
||||
1 1 1 1 1 1
|
||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| |
|
||||
/ QNAME /
|
||||
/ /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| QTYPE |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| QCLASS |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*/
|
||||
struct
|
||||
{
|
||||
void* QNAME;
|
||||
tnet_dns_qtype_t QTYPE;
|
||||
tnet_dns_qclass_t QCLASS;
|
||||
}
|
||||
Question;
|
||||
|
||||
tnet_dns_rrs_L_t *Answers;
|
||||
tnet_dns_rrs_L_t *Authoritys;
|
||||
tnet_dns_rrs_L_t *Additionals;
|
||||
}
|
||||
tnet_dns_message_t;
|
||||
|
||||
TNET_END_DECLS
|
||||
|
||||
#endif /* TNET_DNS_MESSAGE_H */
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* This file is part of Open Source Doubango Framework.
|
||||
*
|
||||
* DOUBANGO is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* DOUBANGO is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
/**@file tnet_dns_rr.c
|
||||
* @brief DNS Resource Record (RFC 1034 and 1035).
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#include "tnet_dns_rr.h"
|
||||
|
||||
#include "tsk_memory.h"
|
||||
|
||||
int tnet_dns_rr_init(tnet_dns_rr_t *rr, tnet_dns_qtype_t qtype, tnet_dns_qclass_t qclass)
|
||||
{
|
||||
if(rr)
|
||||
{
|
||||
if(!rr->initialized)
|
||||
{
|
||||
rr->qtype = qtype;
|
||||
rr->qclass = qclass;
|
||||
|
||||
rr->initialized = 1;
|
||||
return 0;
|
||||
}
|
||||
return -2;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int tnet_dns_rr_deinit(tnet_dns_rr_t *rr)
|
||||
{
|
||||
if(rr)
|
||||
{
|
||||
if(rr->initialized)
|
||||
{
|
||||
TSK_FREE(rr->name);
|
||||
TSK_FREE(rr->rpdata);
|
||||
|
||||
rr->initialized = 0;
|
||||
return 0;
|
||||
}
|
||||
return -2;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//========================================================
|
||||
// [[DNS RR]] object definition
|
||||
//
|
||||
static void* tnet_dns_rr_create(void * self, va_list * app)
|
||||
{
|
||||
tnet_dns_rr_t *rr = self;
|
||||
if(rr)
|
||||
{
|
||||
tnet_dns_rr_init(rr, qtype_any, qclass_any);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
static void* tnet_dns_rr_destroy(void * self)
|
||||
{
|
||||
tnet_dns_rr_t *rr = self;
|
||||
if(rr)
|
||||
{
|
||||
tnet_dns_rr_deinit(rr);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
static const tsk_object_def_t tnet_dns_rr_def_s =
|
||||
{
|
||||
sizeof(tnet_dns_rr_t),
|
||||
tnet_dns_rr_create,
|
||||
tnet_dns_rr_destroy,
|
||||
0,
|
||||
};
|
||||
const void *tnet_dns_rr_def_t = &tnet_dns_rr_def_s;
|
|
@ -0,0 +1,147 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* This file is part of Open Source Doubango Framework.
|
||||
*
|
||||
* DOUBANGO is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* DOUBANGO is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
/**@file tnet_dns_rr.h
|
||||
* @brief DNS Resource Record (RFCS 1034 and 1035).
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
|
||||
#ifndef TNET_DNS_RR_H
|
||||
#define TNET_DNS_RR_H
|
||||
|
||||
#include "tinyNET_config.h"
|
||||
|
||||
#include "tsk_list.h"
|
||||
|
||||
TNET_BEGIN_DECLS
|
||||
|
||||
#define TNET_DNS_RR_CREATE() tsk_object_new(tnet_dns_rr_def_t)
|
||||
|
||||
/**
|
||||
* RFC 1035 - 3.2.2. TYPE values
|
||||
*/
|
||||
typedef enum tnet_dns_qtype_e
|
||||
{
|
||||
qtype_a = 0x0001, /**< A 1 a host address */
|
||||
qtype_ns = 0x0002, /**< NS 2 an authoritative name server */
|
||||
qtype_md = 0x0003, /**< MD 3 a mail destination (Obsolete - use MX) */
|
||||
qtype_mf = 0x0004, /**< MF 4 a mail forwarder (Obsolete - use MX) */
|
||||
qtype_cname = 0x0005, /**< CNAME 5 the canonical name for an alias */
|
||||
qtype_soa = 0x0006, /**< SOA 6 marks the start of a zone of authority */
|
||||
qtype_mb = 0x0007, /**< MB 7 a mailbox domain name (EXPERIMENTAL) */
|
||||
qtype_mg = 0x0008, /**< MG 8 a mail group member (EXPERIMENTAL) */
|
||||
qtype_mr = 0x0009, /**< MR 9 a mail rename domain name (EXPERIMENTAL) */
|
||||
qtype_null = 0x000a, /**< NULL 10 a null RR (EXPERIMENTAL) */
|
||||
qtype_wks = 0x000b, /**< WKS 11 a well known service description */
|
||||
qtype_ptr = 0x000c, /**< PTR 12 a domain name pointer */
|
||||
qtype_hinfo = 0x000d, /**< HINFO 13 host information */
|
||||
qtype_minfo = 0x000e, /**< MINFO 14 mailbox or mail list information */
|
||||
qtype_mx = 0x000f, /**< MX 15 mail exchange */
|
||||
qtype_txt = 0x0010, /**< TXT 16 text strings */
|
||||
|
||||
qtype_aaa = 0x001c, /**< AAAA 28 IPv6 host address */
|
||||
|
||||
qtype_any = 0x00ff /**< * 255 A request for all records (3.2.3. QTYPE values)*/
|
||||
}
|
||||
tnet_dns_qtype_t;
|
||||
|
||||
/**
|
||||
* RFC 1035 - 3.2.4. CLASS values
|
||||
*/
|
||||
typedef enum tnet_dns_qclass_e
|
||||
{
|
||||
qclass_in = 0x0001, /**< IN 1 the Internet */
|
||||
qclass_ics = 0x0002, /**< CS 2 the CSNET class (Obsolete - used only for examples in some obsolete RFCs) */
|
||||
qclass_ch = 0x0003, /**< CH 3 the CHAOS class */
|
||||
qclass_hs = 0x0004, /**< HS 4 Hesiod [Dyer 87] */
|
||||
|
||||
qclass_any = 0x00ff /**< * 255 any class (3.2.5. QCLASS values) */
|
||||
}
|
||||
tnet_dns_qclass_t;
|
||||
|
||||
/**
|
||||
* RFC 1034 (3.6. Resource Records) and 1035 (3.2.1. Format)
|
||||
*/
|
||||
typedef struct tnet_dns_rr_s
|
||||
{
|
||||
TSK_DECLARE_OBJECT;
|
||||
|
||||
/* RFC 1035 - 3.2.1. Format
|
||||
1 1 1 1 1 1
|
||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| |
|
||||
/ /
|
||||
/ NAME /
|
||||
| |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| TYPE |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| CLASS |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| TTL |
|
||||
| |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| RDLENGTH |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
|
||||
/ RDATA /
|
||||
/ /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*/
|
||||
|
||||
unsigned initialized:1;
|
||||
|
||||
/** An owner name, i.e., the name of the node to which this resource record pertains. */
|
||||
char* name;
|
||||
|
||||
/** Two octets containing one of the RR TYPE codes. */
|
||||
tnet_dns_qtype_t qtype;
|
||||
|
||||
/** Two octets containing one of the RR CLASS codes. */
|
||||
tnet_dns_qclass_t qclass;
|
||||
|
||||
/** A 32 bit signed integer that specifies the time interval that the resource record may be cached before the source
|
||||
of the information should again be consulted.
|
||||
Zero values are interpreted to mean that the RR can only be used for the transaction in progress, and should not be cached.
|
||||
For example, SOA records are always distributed with a zero TTL to prohibit caching. Zero values can also be used for extremely volatile data. */
|
||||
int32_t ttl;
|
||||
|
||||
/** An unsigned 16 bit integer that specifies the length in octets of the RDATA field. */
|
||||
uint16_t rdlength;
|
||||
|
||||
/** A variable length string of octets that describes the resource.
|
||||
The format of this information varies according to the TYPE and CLASS of the resource record.*/
|
||||
void *rpdata;
|
||||
}
|
||||
tnet_dns_rr_t;
|
||||
typedef tsk_list_t tnet_dns_rrs_L_t;
|
||||
|
||||
int tnet_dns_rr_init(tnet_dns_rr_t *rr, tnet_dns_qtype_t qtype, tnet_dns_qclass_t qclass);
|
||||
int tnet_dns_rr_deinit(tnet_dns_rr_t *rr);
|
||||
|
||||
TINYNET_GEXTERN const void *tnet_dns_rr_def_t;
|
||||
|
||||
TNET_END_DECLS
|
||||
|
||||
#endif /* TNET_DNS_RR_H */
|
|
@ -49,8 +49,13 @@ tnet_stun_attribute_t* tnet_stun_attribute_deserialize(const void* data, size_t
|
|||
tnet_stun_attribute_type_t type = (tnet_stun_attribute_type_t)ntohs(*((uint16_t*)dataPtr));
|
||||
uint16_t length = ntohs(*(((uint16_t*)dataPtr)+1));
|
||||
|
||||
dataPtr += (2 /* Type */+ 2/* Length */);
|
||||
/* Check validity */
|
||||
if(!data || size<=4/* Type(2-bytes) plus Length (2-bytes) */)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
dataPtr += (2 /* Type */+ 2/* Length */);
|
||||
|
||||
/* Attribute Value
|
||||
*/
|
||||
|
@ -206,14 +211,14 @@ int tnet_stun_attribute_serialize(const tnet_stun_attribute_t* attribute, tsk_bu
|
|||
case stun_mapped_address:
|
||||
{
|
||||
TSK_DEBUG_ERROR("NOT IMPLEMENTED");
|
||||
break;
|
||||
return -3;
|
||||
}
|
||||
|
||||
/* RFC 5389 - 15.2. XOR-MAPPED-ADDRESS*/
|
||||
case stun_xor_mapped_address:
|
||||
{
|
||||
TSK_DEBUG_ERROR("NOT IMPLEMENTED");
|
||||
break;
|
||||
return -3;
|
||||
}
|
||||
|
||||
/* RFC 5389 - 15.3. USERNAME*/
|
||||
|
@ -221,7 +226,7 @@ int tnet_stun_attribute_serialize(const tnet_stun_attribute_t* attribute, tsk_bu
|
|||
{
|
||||
tnet_stun_attribute_username_t *username = (tnet_stun_attribute_username_t*)attribute;
|
||||
tsk_buffer_append(output, username->value, strlen(username->value));
|
||||
break;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -230,22 +235,22 @@ int tnet_stun_attribute_serialize(const tnet_stun_attribute_t* attribute, tsk_bu
|
|||
{
|
||||
tnet_stun_attribute_integrity_t *integrity = (tnet_stun_attribute_integrity_t*)attribute;
|
||||
tsk_buffer_append(output, integrity->sha1digest, TSK_SHA1_DIGEST_SIZE);
|
||||
break;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* RFC 5389 - 15.5. FINGERPRINT*/
|
||||
case stun_fingerprint:
|
||||
{
|
||||
tnet_stun_attribute_fingerprint_t *fingerprint = (tnet_stun_attribute_fingerprint_t*)attribute;
|
||||
tsk_buffer_append(output, &(fingerprint->value), 4);
|
||||
break;
|
||||
uint32_t fingerprint = /*htonl*/(((tnet_stun_attribute_fingerprint_t*)attribute)->value);
|
||||
tsk_buffer_append(output, &fingerprint, 4);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* RFC 5389 - 15.6. ERROR-CODE*/
|
||||
case stun_error_code:
|
||||
{
|
||||
TSK_DEBUG_ERROR("NOT IMPLEMENTED");
|
||||
break;
|
||||
return -3;
|
||||
}
|
||||
|
||||
/* RFC 5389 - 15.7. REALM*/
|
||||
|
@ -253,7 +258,7 @@ int tnet_stun_attribute_serialize(const tnet_stun_attribute_t* attribute, tsk_bu
|
|||
{
|
||||
tnet_stun_attribute_realm_t *realm = (tnet_stun_attribute_realm_t*)attribute;
|
||||
tsk_buffer_append(output, realm->value, strlen(realm->value));
|
||||
break;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* RFC 5389 - 15.8. NONCE*/
|
||||
|
@ -261,14 +266,14 @@ int tnet_stun_attribute_serialize(const tnet_stun_attribute_t* attribute, tsk_bu
|
|||
{
|
||||
tnet_stun_attribute_nonce_t *nonce = (tnet_stun_attribute_nonce_t*)attribute;
|
||||
tsk_buffer_append(output, nonce->value, strlen(nonce->value));
|
||||
break;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* RFC 5389 - 15.9. UNKNOWN-ATTRIBUTES*/
|
||||
case stun_unknown_attributes:
|
||||
{
|
||||
TSK_DEBUG_ERROR("NOT IMPLEMENTED");
|
||||
break;
|
||||
return -3;
|
||||
}
|
||||
|
||||
/* RFC 5389 - 15.10. SOFTWARE */
|
||||
|
@ -276,14 +281,14 @@ int tnet_stun_attribute_serialize(const tnet_stun_attribute_t* attribute, tsk_bu
|
|||
{
|
||||
tnet_stun_attribute_software_t *software = (tnet_stun_attribute_software_t*)attribute;
|
||||
tsk_buffer_append(output, software->value, strlen(software->value));
|
||||
break;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* RFC 5389 - 15.11. ALTERNATE-SERVER */
|
||||
case stun_alternate_server:
|
||||
{
|
||||
TSK_DEBUG_ERROR("NOT IMPLEMENTED");
|
||||
break;
|
||||
return -3;
|
||||
}
|
||||
/* draft-ietf-behave-turn-16 - */
|
||||
case stun_channel_number:
|
||||
|
@ -298,15 +303,12 @@ int tnet_stun_attribute_serialize(const tnet_stun_attribute_t* attribute, tsk_bu
|
|||
case stun_reserved3:
|
||||
case stun_reservation_token:
|
||||
{
|
||||
tnet_turn_attribute_serialize(attribute, output);
|
||||
break;
|
||||
return tnet_turn_attribute_serialize(attribute, output);
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
return -2;
|
||||
}
|
||||
|
||||
return -2;
|
||||
}
|
||||
|
||||
void tnet_stun_attribute_pad(const tnet_stun_attribute_t* attribute, tsk_buffer_t *output)
|
||||
|
|
|
@ -143,7 +143,7 @@ int tnet_turn_attribute_serialize(const tnet_stun_attribute_t* attribute, tsk_bu
|
|||
{
|
||||
tnet_turn_attribute_channelnum_t *number = (tnet_turn_attribute_channelnum_t*)attribute;
|
||||
tsk_buffer_append(output, &(number->number), 2);
|
||||
break;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* draft-ietf-behave-turn-16 - 14.2. LIFETIME */
|
||||
|
@ -151,7 +151,7 @@ int tnet_turn_attribute_serialize(const tnet_stun_attribute_t* attribute, tsk_bu
|
|||
{
|
||||
tnet_turn_attribute_lifetime_t *lifetime = (tnet_turn_attribute_lifetime_t*)attribute;
|
||||
tsk_buffer_append(output, &(lifetime->value), 4);
|
||||
break;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* draft-ietf-behave-turn-16 - 14.3. XOR-PEER-ADDRESS */
|
||||
|
@ -171,9 +171,10 @@ int tnet_turn_attribute_serialize(const tnet_stun_attribute_t* attribute, tsk_bu
|
|||
else
|
||||
{
|
||||
TSK_DEBUG_ERROR("SERIALIZE:XOR-PEER-ADDRESS ==> IPV6 - NOT IMPLEMENTED");
|
||||
return -3;
|
||||
}
|
||||
}
|
||||
break;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* draft-ietf-behave-turn-16 - 14.4. DATA */
|
||||
|
@ -184,14 +185,14 @@ int tnet_turn_attribute_serialize(const tnet_stun_attribute_t* attribute, tsk_bu
|
|||
{
|
||||
tsk_buffer_append(output, data->value->data, data->value->size);
|
||||
}
|
||||
break;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* draft-ietf-behave-turn-16 - 14.5. XOR-RELAYED-ADDRESS */
|
||||
case stun_xor_relayed_address:
|
||||
{
|
||||
TSK_DEBUG_ERROR("SERIALIZE:XOR-RELAYED-ADDRESS ==> NOT IMPLEMENTED");
|
||||
break;
|
||||
return -3;
|
||||
}
|
||||
|
||||
/* draft-ietf-behave-turn-16 - 14.6. EVEN-PORT */
|
||||
|
@ -200,7 +201,7 @@ int tnet_turn_attribute_serialize(const tnet_stun_attribute_t* attribute, tsk_bu
|
|||
tnet_turn_attribute_even_port_t *even_port = (tnet_turn_attribute_even_port_t*)attribute;
|
||||
uint8_t value = (even_port->R << 7);
|
||||
tsk_buffer_append(output, &(value), 1);
|
||||
break;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* draft-ietf-behave-turn-16 - 14.7. REQUESTED-TRANSPORT */
|
||||
|
@ -209,21 +210,21 @@ int tnet_turn_attribute_serialize(const tnet_stun_attribute_t* attribute, tsk_bu
|
|||
tnet_turn_attribute_reqtrans_t *reqtrans = (tnet_turn_attribute_reqtrans_t*)attribute;
|
||||
tsk_buffer_append(output, &(reqtrans->protocol), 1);
|
||||
tsk_buffer_append(output, &(reqtrans->rffu), 3);
|
||||
break;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* draft-ietf-behave-turn-16 - 14.8. DONT-FRAGMENT */
|
||||
case stun_dont_fragment:
|
||||
{
|
||||
TSK_DEBUG_ERROR("SERIALIZE:DONT-FRAGMENT ==> NOT IMPLEMENTED");
|
||||
break;
|
||||
return -3;
|
||||
}
|
||||
|
||||
/* draft-ietf-behave-turn-16 - 14.9. RESERVATION-TOKEN */
|
||||
case stun_reservation_token:
|
||||
{
|
||||
TSK_DEBUG_ERROR("SERIALIZE:TOKEN ==> NOT IMPLEMENTED");
|
||||
break;
|
||||
return -3;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""$(DOUBANGO_HOME)\thirdparties\win32\include";"$(DOUBANGO_HOME)\tinySAK\src""
|
||||
AdditionalIncludeDirectories=""$(DOUBANGO_HOME)\tinyNET\src";"$(DOUBANGO_HOME)\thirdparties\win32\include";"$(DOUBANGO_HOME)\tinySAK\src""
|
||||
PreprocessorDefinitions="DEBUG_LEVEL=DEBUG_LEVEL_INFO;WIN32;_WIN32_WINNT=0x0501;_DEBUG;_WINDOWS;_USRDLL;TINYNET_EXPORTS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
|
@ -64,7 +64,7 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="ws2_32.lib $(OutDir)\tinySAK.lib"
|
||||
AdditionalDependencies="ws2_32.lib Iphlpapi.lib $(OutDir)\tinySAK.lib"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
|
@ -432,6 +432,10 @@
|
|||
RelativePath="..\..\tinyNET\src\dns\tnet_dns_cname.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\tinyNET\src\dns\tnet_dns_message.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\tinyNET\src\dns\tnet_dns_mx.c"
|
||||
>
|
||||
|
@ -448,6 +452,10 @@
|
|||
RelativePath="..\..\tinyNET\src\dns\tnet_dns_ptr.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\tinyNET\src\dns\tnet_dns_rr.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\tinyNET\src\dns\tnet_dns_soa.c"
|
||||
>
|
||||
|
@ -556,6 +564,10 @@
|
|||
RelativePath="..\..\tinyNET\src\dns\tnet_dns_cname.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\tinyNET\src\dns\tnet_dns_message.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\tinyNET\src\dns\tnet_dns_mx.h"
|
||||
>
|
||||
|
@ -572,6 +584,10 @@
|
|||
RelativePath="..\..\tinyNET\src\dns\tnet_dns_ptr.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\tinyNET\src\dns\tnet_dns_rr.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\tinyNET\src\dns\tnet_dns_soa.h"
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue