reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
Stun.cxx File Reference
#include "rutil/ResipAssert.h"
#include <cstring>
#include <iostream>
#include <cstdlib>
#include <errno.h>
#include <ctype.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <net/if.h>
#include "Udp.hxx"
#include "Stun.hxx"
#include "rutil/Socket.hxx"
#include "rutil/Random.hxx"
#include "rutil/WinLeakCheck.hxx"
#include <openssl/hmac.h>

Go to the source code of this file.

Namespaces

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

Functions

static bool resip::stunParseAtrAddress (char *body, unsigned int hdrLen, StunAtrAddress4 &result)
 
static bool resip::stunParseUInt32 (char *body, unsigned int hdrLen, uint32_t &result)
 
static bool resip::stunParseAtrChangeRequest (char *body, unsigned int hdrLen, StunAtrChangeRequest &result)
 
static bool resip::stunParseAtrError (char *body, unsigned int hdrLen, StunAtrError &result)
 
static bool resip::stunParseAtrUnknown (char *body, unsigned int hdrLen, StunAtrUnknown &result)
 
static bool resip::stunParseAtrString (char *body, unsigned int hdrLen, StunAtrString &result)
 
static bool resip::stunParseAtrUInt32 (char *body, unsigned int hdrLen, uint32_t &result)
 
static bool resip::stunParseAtrIntegrity (char *body, unsigned int hdrLen, StunAtrIntegrity &result)
 
bool resip::stunParseMessage (char *buf, unsigned int bufLen, StunMessage &msg, bool verbose)
 
static char * resip::encode16 (char *buf, uint16_t data)
 
static char * resip::encode32 (char *buf, uint32_t data)
 
static char * resip::encode (char *buf, const char *data, unsigned int length)
 
static char * resip::encodeTurnData (char *ptr, const resip::Data *td)
 
static char * resip::encodeAtrUInt32 (char *ptr, uint16_t type, uint32_t value)
 
static char * resip::encodeAtrAddress4 (char *ptr, uint16_t type, const StunAtrAddress4 &atr)
 
static char * resip::encodeAtrChangeRequest (char *ptr, const StunAtrChangeRequest &atr)
 
static char * resip::encodeMagicCookie (char *ptr, const uint32_t &cookie)
 
static char * resip::encodeAtrError (char *ptr, const StunAtrError &atr)
 
static char * resip::encodeAtrUnknown (char *ptr, const StunAtrUnknown &atr)
 
static char * resip::encodeXorOnly (char *ptr)
 
static char * resip::encodeAtrString (char *ptr, uint16_t type, const StunAtrString &atr)
 
static char * resip::encodeAtrIntegrity (char *ptr, const StunAtrIntegrity &atr)
 
unsigned int resip::stunEncodeMessage (const StunMessage &msg, char *buf, unsigned int bufLen, const StunAtrString &password, bool verbose)
 
int resip::stunRand ()
 
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)
 
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.
 
static void resip::toHex (const char *buffer, int bufferSize, char *output)
 
void resip::stunCreateUserName (const StunAddress4 &source, StunAtrString *username)
 
void resip::stunCreatePassword (const StunAtrString &username, StunAtrString *password)
 
uint64_t resip::stunGetSystemTimeSecs ()
 
ostream & resip::operator<< (ostream &strm, const UInt128 &r)
 
ostream & resip::operator<< (std::ostream &strm, const StunAddress4 &addr)
 prints a StunAddress
 
ostream & resip::operator<< (ostream &os, const StunMsgHdr &h)
 
bool resip::stunParseHostName (char *peerName, uint32_t &ip, uint16_t &portVal, uint16_t defaultPort)
 
bool resip::stunParseServerName (char *software, StunAddress4 &stunServerAddr)
 find the IP address of a the specified stun server - return false is fails parse
 
static void resip::stunCreateErrorResponse (StunMessage &response, int cl, int number, const char *msg)
 
static void resip::stunCreateSharedSecretResponse (const StunMessage &request, const StunAddress4 &source, StunMessage &response)
 
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)
 
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
 
void resip::stunBuildReqSimple (StunMessage *msg, const StunAtrString &username, bool changePort, bool changeIp, unsigned int id)
 
static void resip::stunSendTest (resip::Socket myFd, StunAddress4 &dest, const StunAtrString &username, const StunAtrString &password, int testNum, bool verbose)
 
void resip::stunGetUserNameAndPassword (const StunAddress4 &dest, StunAtrString *username, StunAtrString *password)
 
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)
 
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)
 
bool resip::operator< (const UInt128 &lhs, const UInt128 &rhs)
 
bool resip::operator== (const UInt128 &lhs, const UInt128 &rhs)
 
bool resip::operator< (const StunMsgHdr &lhs, const StunMsgHdr &rhs)