reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
Stun.hxx File Reference
#include <iostream>
#include <time.h>
#include "rutil/Data.hxx"
#include "rutil/Socket.hxx"

Go to the source code of this file.

Classes

struct  resip::UInt128
 
struct  resip::StunMsgHdr
 
struct  resip::StunAtrHdr
 
struct  resip::StunAddress4
 
struct  resip::StunAtrAddress4
 
struct  resip::StunAtrChangeRequest
 
struct  resip::StunAtrError
 
struct  resip::StunAtrUnknown
 
struct  resip::StunAtrString
 
struct  resip::StunAtrIntegrity
 
struct  resip::StunMessage
 
struct  resip::StunMediaRelay
 
struct  resip::StunServerInfo
 

Namespaces

namespace  resip
 dcm! – add UnusedChecking(_enum) below;
 

Macros

#define STUN_VERSION   "0.97"
 
#define STUN_MAX_STRING   256
 
#define STUN_MAX_UNKNOWN_ATTRIBUTES   8
 
#define STUN_MAX_MESSAGE_SIZE   2048
 
#define STUN_PORT   3478
 
#define MAX_REALM_BYTES   763
 
#define MAX_NONCE_BYTES   763
 
#define MAX_MEDIA_RELAYS   500
 
#define MAX_RTP_MSG_SIZE   1500
 
#define MEDIA_RELAY_TIMEOUT   3*60
 

Typedefs

typedef unsigned char resip::uint8_t
 
typedef unsigned short resip::uint16_t
 
typedef unsigned int resip::uint32_t
 
typedef unsigned long long resip::uint64_t
 

Enumerations

enum  resip::StunHmacStatus {
  resip::HmacUnknown = 0 , resip::HmacOK , resip::HmacBadUserName , resip::HmacUnknownUserName ,
  resip::HmacFailed
}
 
enum  resip::NatType {
  resip::StunTypeUnknown = 0 , resip::StunTypeFailure , resip::StunTypeOpen , resip::StunTypeBlocked ,
  resip::StunTypeIndependentFilter , resip::StunTypeDependentFilter , resip::StunTypePortDependedFilter , resip::StunTypeDependentMapping ,
  resip::StunTypeFirewall
}
 

Functions

bool resip::stunParseMessage (char *buf, unsigned int bufLen, StunMessage &msg, bool verbose)
 
void resip::stunBuildReqSimple (StunMessage *msg, const StunAtrString &username, bool changePort, bool changeIp, unsigned int id)
 
bool resip::stunVerifyMessageIntegrity (const char *buf, unsigned int bufLen, const StunMessage &message, const StunAtrString &password)
 Verify the MESSAGE-INTEGRITY attribute of a parsed message against the supplied short-term credential password, using a constant-time comparison.
 
unsigned int resip::stunEncodeMessage (const StunMessage &msg, char *buf, unsigned int bufLen, const StunAtrString &password, bool verbose)
 
void resip::stunCreateUserName (const StunAddress4 &source, StunAtrString *username)
 
void resip::stunGetUserNameAndPassword (const StunAddress4 &dest, StunAtrString *username, StunAtrString *password)
 
void resip::stunCreatePassword (const StunAtrString &username, StunAtrString *password)
 
int resip::stunRand ()
 
uint64_t resip::stunGetSystemTimeSecs ()
 
bool resip::stunParseServerName (char *software, StunAddress4 &stunServerAddr)
 find the IP address of a the specified stun server - return false is fails parse
 
bool resip::stunParseHostName (char *peerName, uint32_t &ip, uint16_t &portVal, uint16_t defaultPort)
 
bool resip::stunInitServer (StunServerInfo &info, const StunAddress4 &myAddr, const StunAddress4 &altAddr, int startMediaPort, bool verbose)
 return true if all is OK Create a media relay and do the STERN thing if startMediaPort is non-zero
 
void resip::stunStopServer (StunServerInfo &info)
 
bool resip::stunServerProcess (StunServerInfo &info, bool verbose)
 return true if all is OK
 
int resip::stunFindLocalInterfaces (uint32_t *addresses, int maxSize)
 returns number of address found - take array or addres
 
bool resip::stunTest (StunAddress4 &dest, int testNum, bool verbose, StunAddress4 *sAddr, unsigned long timeoutMs)
 
NatType resip::stunNatType (StunAddress4 &dest, bool verbose, bool *preservePort, bool *hairpin, int port, StunAddress4 *sAddr)
 
ostream & resip::operator<< (std::ostream &strm, const StunAddress4 &addr)
 prints a StunAddress
 
ostream & resip::operator<< (ostream &strm, const UInt128 &r)
 
ostream & resip::operator<< (ostream &os, const StunMsgHdr &h)
 
bool resip::stunServerProcessMsg (char *buf, unsigned int bufLen, StunAddress4 &from, StunAddress4 &secondary, StunAddress4 &myAddr, StunAddress4 &altAddr, StunMessage *resp, StunAddress4 *destination, StunAtrString *hmacPassword, bool *changePort, bool *changeIp, bool verbose)
 
int resip::stunOpenSocket (StunAddress4 &dest, StunAddress4 *mapAddr, int port, StunAddress4 *srcAddr, bool verbose)
 
bool resip::stunOpenSocketPair (StunAddress4 &dest, StunAddress4 *mapAddr, int *fd1, int *fd2, int port, StunAddress4 *srcAddr, bool verbose)
 
int resip::stunRandomPort ()
 return a random number to use as a port
 
void resip::computeHmac (char *hmac, const char *input, int length, const char *key, int sizeKey)
 

Variables

const uint8_t resip::IPv4Family = 0x01
 define a structure to hold a stun address
 
const uint8_t resip::IPv6Family = 0x02
 
const uint32_t resip::ChangeIpFlag = 0x04
 
const uint32_t resip::ChangePortFlag = 0x02
 
static const uint16_t resip::MappedAddress = 0x0001
 
static const uint16_t resip::ResponseAddress = 0x0002
 
static const uint16_t resip::ChangeRequest = 0x0003
 
static const uint16_t resip::SourceAddress = 0x0004
 
static const uint16_t resip::ChangedAddress = 0x0005
 
static const uint16_t resip::Username = 0x0006
 
static const uint16_t resip::Password = 0x0007
 
static const uint16_t resip::MessageIntegrity = 0x0008
 
static const uint16_t resip::ErrorCode = 0x0009
 
static const uint16_t resip::UnknownAttribute = 0x000A
 
static const uint16_t resip::ReflectedFrom = 0x000B
 
static const uint16_t resip::Realm = 0x0014
 
static const uint16_t resip::Nonce = 0x0015
 
static const uint16_t resip::XorMappedAddress = 0x0020
 
static const uint16_t resip::XorOnly = 0x0021
 
static const uint16_t resip::XorMappedAddress_old = 0x8020
 
static const uint16_t resip::Software = 0x8022
 
static const uint16_t resip::AlternateServer = 0x8023
 
static const uint16_t resip::Fingerprint = 0x8028
 
static const uint16_t resip::SecondaryAddress = 0x8050
 
const uint16_t resip::TurnLifetime = 0x000d
 
const uint16_t resip::TurnAlternateServer = 0x000e
 
const uint16_t resip::TurnMagicCookie = 0x000f
 
const uint16_t resip::TurnBandwidth = 0x0010
 
const uint16_t resip::TurnDestinationAddress = 0x0011
 
const uint16_t resip::TurnRemoteAddress = 0x0012
 
const uint16_t resip::TurnData = 0x0013
 
const uint16_t resip::TurnNonce = 0x0014
 
const uint16_t resip::TurnRealm = 0x0015
 
const uint16_t resip::BindRequestMsg = 0x0001
 
const uint16_t resip::BindResponseMsg = 0x0101
 
const uint16_t resip::BindErrorResponseMsg = 0x0111
 
const uint16_t resip::SharedSecretRequestMsg = 0x0002
 
const uint16_t resip::SharedSecretResponseMsg = 0x0102
 
const uint16_t resip::SharedSecretErrorResponseMsg = 0x0112
 
const uint16_t resip::TurnAllocateRequest = 0x0003
 
const uint16_t resip::TurnAllocateResponse = 0x0103
 
const uint16_t resip::TurnAllocateErrorResponse = 0x0113
 
const uint16_t resip::TurnSendRequest = 0x0004
 
const uint16_t resip::TurnSendResponse = 0x0104
 
const uint16_t resip::TurnSendErrorResponse = 0x0114
 
const uint16_t resip::TurnDataIndication = 0x0115
 
const uint16_t resip::TurnSetActiveDestinationRequest = 0x0006
 
const uint16_t resip::TurnSetActiveDestinationResponse = 0x0106
 
const uint16_t resip::TurnSetActiveDestinationErrorResponse = 0x0116
 
static const uint32_t resip::StunMagicCookie = 0x2112A442
 

Macro Definition Documentation

◆ MAX_MEDIA_RELAYS

#define MAX_MEDIA_RELAYS   500

Definition at line 322 of file Stun.hxx.

◆ MAX_NONCE_BYTES

#define MAX_NONCE_BYTES   763

Definition at line 59 of file Stun.hxx.

◆ MAX_REALM_BYTES

#define MAX_REALM_BYTES   763

Definition at line 58 of file Stun.hxx.

◆ MAX_RTP_MSG_SIZE

#define MAX_RTP_MSG_SIZE   1500

Definition at line 323 of file Stun.hxx.

◆ MEDIA_RELAY_TIMEOUT

#define MEDIA_RELAY_TIMEOUT   3*60

Definition at line 324 of file Stun.hxx.

◆ STUN_MAX_MESSAGE_SIZE

#define STUN_MAX_MESSAGE_SIZE   2048

Definition at line 23 of file Stun.hxx.

◆ STUN_MAX_STRING

#define STUN_MAX_STRING   256

Definition at line 21 of file Stun.hxx.

◆ STUN_MAX_UNKNOWN_ATTRIBUTES

#define STUN_MAX_UNKNOWN_ATTRIBUTES   8

Definition at line 22 of file Stun.hxx.

◆ STUN_PORT

#define STUN_PORT   3478

Definition at line 25 of file Stun.hxx.

◆ STUN_VERSION

#define STUN_VERSION   "0.97"

Definition at line 19 of file Stun.hxx.