Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ addons:
packages:
- cmake
- cmake-data
- libbsd-dev
before_install:
- export PATH=$HOME/.local/bin:$PATH
- pip install cpp-coveralls --user `whoami`
Expand Down
13 changes: 7 additions & 6 deletions include/stun_intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ typedef struct {
DiscussData* discussData; /*NULL allowed if none present */
bool addSoftware;
bool stuntrace;
bool addTransCnt;
} StunBindReqStruct;

struct StunClientStats
Expand Down Expand Up @@ -102,11 +103,6 @@ typedef struct
uint32_t inst;
StunBindReqStruct stunBindReq;

uint8_t stunReqMsgBuf[STUN_MAX_PACKET_SIZE]; /* encoded STUN request
* */
int stunReqMsgBufLen; /* of encoded STUN
* request */

STUN_USER_CREDENTIALS userCredentials;
bool authenticated;

Expand All @@ -117,13 +113,18 @@ typedef struct
int32_t TimerRetransmit;
uint32_t retransmits;

uint32_t reqTransCnt;
uint32_t respTransCnt;

/* RTT Info */
struct timeval start[STUNCLIENT_MAX_RETRANSMITS];
struct timeval stop[STUNCLIENT_MAX_RETRANSMITS];



/* icmp */
uint32_t ICMPtype;
uint32_t ttl;
/* uint32_t ttl; */

/* DISCUSS */
bool hasDiscuss;
Expand Down
25 changes: 3 additions & 22 deletions include/stunclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ typedef struct
struct sockaddr_storage dstBaseAddr; /* The destination seen from the
* sender of the response */
uint32_t rtt; /* Rtt in microseconds */
uint32_t reqTransCnt;
uint32_t respTransCnt;
uint32_t retransmits;
uint32_t ICMPtype;
uint32_t ttl;
Expand Down Expand Up @@ -180,7 +182,7 @@ StunClient_startBindTransaction(STUN_CLIENT_DATA* clientData,
STUN_SENDFUNC sendFunc,
STUNCB stunCbFunc,
DiscussData* discussData);
uint32_t
void
StunClient_startSTUNTrace(STUN_CLIENT_DATA* clientData,
void* userCtx,
const struct sockaddr* serverAddr,
Expand Down Expand Up @@ -230,27 +232,6 @@ StunClient_cancelBindingTransaction(STUN_CLIENT_DATA* clientData,
StunMsgId transactionId);


/********* Server handling: send STUN BIND RESP *************/
bool
StunServer_SendConnectivityBindingResp(STUN_CLIENT_DATA* clientData,
int32_t globalSocketId,
StunMsgId transactionId,
const char* password,
const struct sockaddr* mappedAddr,
const struct sockaddr* dstAddr,
void* userData,
STUN_SENDFUNC sendFunc,
int proto,
bool useRelay,
uint32_t responseCode,
DiscussData* discussData);

/********** Server handling: incoming STUN BIND REQ **********/
bool
StunServer_HandleStunIncomingBindReqMsg(STUN_CLIENT_DATA* clientData,
STUN_INCOMING_REQ_DATA* pReq,
const StunMessage* stunMsg,
bool fromRelay);

void
StunClient_clearStats(STUN_CLIENT_DATA* clientData);
Expand Down
25 changes: 21 additions & 4 deletions include/stunlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ extern "C" {
#define STUN_ATTR_ICEControlled 0x8029
#define STUN_ATTR_ICEControlling 0x802A

/* Draft loss and RTT calculation TODO:update actual calues*/
#define STUN_ATTR_TransCount 0x8072

/** IP Addr family **/
#define STUN_ADDR_IPv4Family 0x01
#define STUN_ADDR_IPv6Family 0x02
Expand Down Expand Up @@ -188,6 +191,7 @@ extern "C" {
*
*
*
*
*msec
**/
#define STUNCLIENT_DFLT_TICK_TIMER_MS 50
Expand Down Expand Up @@ -362,6 +366,14 @@ typedef struct
}
StunAtrNetworkStatus;

typedef struct
{
uint16_t reserved;
uint8_t reqCnt;
uint8_t respCnt;
}
StunAtrTransCount;

typedef struct
{
uint32_t first;
Expand Down Expand Up @@ -542,7 +554,8 @@ typedef struct
bool hasCiscoNetFeedResp;
StunAtrCiscoNetworkFeedback ciscoNetFeedResp;


bool hasTransCount;
StunAtrTransCount transCount;

/* No value, only flaged */
bool hasUseCandidate;
Expand Down Expand Up @@ -575,6 +588,11 @@ typedef void (* STUN_ERR_FUNC)(const char* fmt,
***** API Funcs ******
**********************/

/* transaction id compare */
bool
stunlib_transIdIsEqual(const StunMsgId* a,
const StunMsgId* b);

/***********************************************/
/************* Decode functions ***************/
/***********************************************/
Expand Down Expand Up @@ -846,9 +864,8 @@ stunlib_printBuffer(FILE* stream,


void
stunlib_createId(StunMsgId* pId,
long randval,
unsigned char retries);
stunlib_createId(StunMsgId* pId);

bool
stunlib_addRealm(StunMessage* stunMsg,
const char* realm,
Expand Down
51 changes: 51 additions & 0 deletions include/stunserver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@


#ifndef STUNSERVER_H
#define STUNSERVER_H


#include "stunlib.h" /* stun enc/dec and msg formats*/
#include <stdint.h>
#include "sockaddr_util.h"
#include "stunclient.h"
#include "stun_intern.h"

#ifdef __cplusplus
extern "C" {
#else
#include <stdbool.h>
#endif

bool
CreateConnectivityBindingResp(StunMessage * stunMsg,
StunMsgId transactionId,
const struct sockaddr* mappedSockAddr,
uint8_t reqTrnspCnt,
uint8_t respTrnspCnt,
uint16_t response,
uint32_t responseCode,
DiscussData * discussData);
/********* Server handling: send STUN BIND RESP *************/
bool
StunServer_SendConnectivityBindingResp(STUN_CLIENT_DATA * clientData,
int32_t globalSocketId,
StunMsgId transactionId,
const char* password,
const struct sockaddr* mappedAddr,
const struct sockaddr* dstAddr,
uint8_t reqTrnspCnt,
uint8_t respTrnspCnt,
void* userData,
STUN_SENDFUNC sendFunc,
int proto,
bool useRelay,
uint32_t responseCode,
DiscussData * discussData);

/********** Server handling: incoming STUN BIND REQ **********/
bool
StunServer_HandleStunIncomingBindReqMsg(STUN_CLIENT_DATA * clientData,
STUN_INCOMING_REQ_DATA * pReq,
const StunMessage * stunMsg,
bool fromRelay);
#endif
2 changes: 1 addition & 1 deletion include/stuntrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct hiutResult {


/* Initial Length of first STUN packet (TTL=1) */
uint32_t stunLen;
/* uint32_t stunLen; */
struct hiutPathElement pathElement[MAX_TTL + 1];
bool remoteAlive;
/* struct hiutTTLinfo ttlInfo[MAX_TTL]; */
Expand Down
28 changes: 15 additions & 13 deletions include/turn_intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extern "C" {

/* make sure both the following timers are < 5 minutes */
#define TURN_REFRESH_CHANNEL_TIMER_SEC (3 * 60) /* 3 min (spec. is 10 min)
**/
**/
#define TURN_REFRESH_PERMISSION_TIMER_SEC (4 * 60) /* 4 min (spec. is 5 min)
* */

Expand Down Expand Up @@ -103,19 +103,21 @@ struct TURN_INSTANCE_DATA
unsigned long id;
TURN_INFO_FUNC infoFunc;

TURN_STATE state;
bool inUse;
TurnAllocateReqStuct turnAllocateReq;
StunMsgId StunReqTransId; /* transaction
*id of request
TURN_STATE state;
bool inUse;
TurnAllocateReqStuct turnAllocateReq;
StunMsgId StunReqTransId; /* transaction
* id of
*request
**/
StunMsgId PrevRespTransId; /* transaction
*id of last
*received */
uint8_t stunReqMsgBuf[STUN_MAX_PACKET_SIZE]; /* encoded STUN
*request */
int stunReqMsgBufLen; /* of encoded
*STUN request
StunMsgId PrevRespTransId; /* transaction
* id of last
* received */
uint8_t stunReqMsgBuf[STUN_MAX_PACKET_SIZE]; /* encoded STUN
* request
* */
int stunReqMsgBufLen; /* of encoded
* STUN request
**/
bool pendingChannelBind;
STUN_USER_CREDENTIALS userCredentials;
Expand Down
Loading