/home/tomh/openhip/hip-0.5/src/protocol/hip_stun.c File Reference

#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <stdio.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <netdb.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <net/if.h>
#include <sys/types.h>
#include <fcntl.h>
#include <openssl/rand.h>
#include <time.h>
#include <hip/hip_stun_udp.h>
#include <hip/hip_stun.h>
#include <openssl/hmac.h>

Functions

static void computeHmac (char *hmac, const char *input, int length, const char *key, int keySize)
static int stunParseAtrAddress (char *body, unsigned int hdrLen, StunAtrAddress4 *result)
static int stunParseAtrChangeRequest (char *body, unsigned int hdrLen, StunAtrChangeRequest *result)
static int stunParseAtrError (char *body, unsigned int hdrLen, StunAtrError *result)
static int stunParseAtrUnknown (char *body, unsigned int hdrLen, StunAtrUnknown *result)
static int stunParseAtrString (char *body, unsigned int hdrLen, StunAtrString *result)
static int stunParseAtrIntegrity (char *body, unsigned int hdrLen, StunAtrIntegrity *result)
int stunParseMessage (char *buf, unsigned int bufLen, StunMessage *msg, int verbose)
static char * encode16 (char *buf, UInt16 data)
static char * encode32 (char *buf, UInt32 data)
static char * encode (char *buf, const char *data, unsigned int length)
static char * encodeAtrAddress4 (char *ptr, UInt16 type, const StunAtrAddress4 atr)
static char * encodeAtrChangeRequest (char *ptr, const StunAtrChangeRequest atr)
static char * encodeAtrError (char *ptr, const StunAtrError atr)
static char * encodeAtrUnknown (char *ptr, const StunAtrUnknown atr)
static char * encodeXorOnly (char *ptr)
static char * encodeAtrString (char *ptr, UInt16 type, const StunAtrString atr)
static char * encodeAtrIntegrity (char *ptr, const StunAtrIntegrity *atr)
unsigned int stunEncodeMessage (const StunMessage *msg, char *buf, unsigned int bufLen, const StunAtrString *password, int verbose)
int stunRand ()
int stunRandomPort ()
static void toHex (const char *buffer, int bufferSize, char *output)
void stunCreateUserName (const StunAddress4 *source, StunAtrString *username)
void stunCreatePassword (const StunAtrString *username, StunAtrString *password)
UInt64 stunGetSystemTimeSecs ()
void printIPv4Addr (StunAddress4 *ad)
void printUInt128 (UInt128 r)
int stunParseHostName (char *peerName, UInt32 *ip, UInt16 *portVal, UInt16 defaultPort)
int stunParseServerName (char *name, StunAddress4 *addr)
static void stunCreateErrorResponse (StunMessage *response, int cl, int number, const char *msg)
static void stunCreateSharedSecretResponse (const StunMessage *request, const StunAddress4 *source, StunMessage *response)
int stunServerProcessMsg (char *buf, unsigned int bufLen, StunAddress4 *from, StunAddress4 *secondary, StunAddress4 *myAddr, StunAddress4 *altAddr, StunMessage *resp, StunAddress4 *destination, StunAtrString *hmacPassword, int *changePort, int *changeIp, int verbose)
int stunInitServer (StunServerInfo *info, const StunAddress4 *myAddr, const StunAddress4 *altAddr, int startMediaPort, int verbose)
void stunStopServer (StunServerInfo *info)
int stunServerProcess (StunServerInfo *info, int verbose)
int stunFindLocalInterfaces (UInt32 *addresses, int maxRet)
void stunBuildReqSimple (StunMessage *msg, const StunAtrString *username, int changePort, int changeIp, unsigned int id)
static void stunSendTest (int myFd, StunAddress4 *dest, const StunAtrString *username, const StunAtrString *password, int testNum, int verbose)
void stunGetUserNameAndPassword (const StunAddress4 *dest, StunAtrString *username, StunAtrString *password)
void stunTest (StunAddress4 *dest, int testNum, int verbose, StunAddress4 *sAddr)
NatType stunNatType (StunAddress4 *dest, int verbose, int *preservePort, int *hairpin, int portnb, StunAddress4 *sAddr)
int stunOpenSocket (StunAddress4 *dest, StunAddress4 *mapAddr, int portnb, StunAddress4 *srcAddr, int verbose)
int stunOpenSocketPair (StunAddress4 *dest, StunAddress4 *mapAddr, int *fd1, int *fd2, int port, StunAddress4 *srcAddr, int verbose)

Variables

UInt8 IPv4Family = 0x01
UInt8 IPv6Family = 0x02
UInt32 ChangeIpFlag = 0x04
UInt32 ChangePortFlag = 0x02
UInt16 MappedAddress = 0x0001
UInt16 ResponseAddress = 0x0002
UInt16 ChangeRequest = 0x0003
UInt16 SourceAddress = 0x0004
UInt16 ChangedAddress = 0x0005
UInt16 Username = 0x0006
UInt16 Password = 0x0007
UInt16 MessageIntegrity = 0x0008
UInt16 ErrorCode = 0x0009
UInt16 UnknownAttribute = 0x000A
UInt16 ReflectedFrom = 0x000B
UInt16 XorMappedAddress = 0x8020
UInt16 XorOnly = 0x0021
UInt16 ServerName = 0x8022
UInt16 SecondaryAddress = 0x8050
UInt16 BindRequestMsg = 0x0001
UInt16 BindResponseMsg = 0x0101
UInt16 BindErrorResponseMsg = 0x0111
UInt16 SharedSecretRequestMsg = 0x0002
UInt16 SharedSecretResponseMsg = 0x0102
UInt16 SharedSecretErrorResponseMsg = 0x0112

Function Documentation

static void computeHmac ( char *  hmac,
const char *  input,
int  length,
const char *  key,
int  keySize 
) [static]

static char* encode ( char *  buf,
const char *  data,
unsigned int  length 
) [static]

static char* encode16 ( char *  buf,
UInt16  data 
) [static]

static char* encode32 ( char *  buf,
UInt32  data 
) [static]

static char* encodeAtrAddress4 ( char *  ptr,
UInt16  type,
const StunAtrAddress4  atr 
) [static]

static char* encodeAtrChangeRequest ( char *  ptr,
const StunAtrChangeRequest  atr 
) [static]

static char* encodeAtrError ( char *  ptr,
const StunAtrError  atr 
) [static]

static char* encodeAtrIntegrity ( char *  ptr,
const StunAtrIntegrity atr 
) [static]

static char* encodeAtrString ( char *  ptr,
UInt16  type,
const StunAtrString  atr 
) [static]

static char* encodeAtrUnknown ( char *  ptr,
const StunAtrUnknown  atr 
) [static]

static char* encodeXorOnly ( char *  ptr  )  [static]

void printIPv4Addr ( StunAddress4 ad  ) 

void printUInt128 ( UInt128  r  ) 

void stunBuildReqSimple ( StunMessage msg,
const StunAtrString username,
int  changePort,
int  changeIp,
unsigned int  id 
)

static void stunCreateErrorResponse ( StunMessage response,
int  cl,
int  number,
const char *  msg 
) [static]

void stunCreatePassword ( const StunAtrString username,
StunAtrString password 
)

static void stunCreateSharedSecretResponse ( const StunMessage request,
const StunAddress4 source,
StunMessage response 
) [static]

void stunCreateUserName ( const StunAddress4 source,
StunAtrString username 
)

unsigned int stunEncodeMessage ( const StunMessage msg,
char *  buf,
unsigned int  bufLen,
const StunAtrString password,
int  verbose 
)

int stunFindLocalInterfaces ( UInt32 addresses,
int  maxRet 
)

UInt64 stunGetSystemTimeSecs (  ) 

void stunGetUserNameAndPassword ( const StunAddress4 dest,
StunAtrString username,
StunAtrString password 
)

int stunInitServer ( StunServerInfo info,
const StunAddress4 myAddr,
const StunAddress4 altAddr,
int  startMediaPort,
int  verbose 
)

NatType stunNatType ( StunAddress4 dest,
int  verbose,
int *  preservePort,
int *  hairpin,
int  portnb,
StunAddress4 sAddr 
)

int stunOpenSocket ( StunAddress4 dest,
StunAddress4 mapAddr,
int  portnb,
StunAddress4 srcAddr,
int  verbose 
)

int stunOpenSocketPair ( StunAddress4 dest,
StunAddress4 mapAddr,
int *  fd1,
int *  fd2,
int  port,
StunAddress4 srcAddr,
int  verbose 
)

static int stunParseAtrAddress ( char *  body,
unsigned int  hdrLen,
StunAtrAddress4 result 
) [static]

static int stunParseAtrChangeRequest ( char *  body,
unsigned int  hdrLen,
StunAtrChangeRequest result 
) [static]

static int stunParseAtrError ( char *  body,
unsigned int  hdrLen,
StunAtrError result 
) [static]

static int stunParseAtrIntegrity ( char *  body,
unsigned int  hdrLen,
StunAtrIntegrity result 
) [static]

static int stunParseAtrString ( char *  body,
unsigned int  hdrLen,
StunAtrString result 
) [static]

static int stunParseAtrUnknown ( char *  body,
unsigned int  hdrLen,
StunAtrUnknown result 
) [static]

int stunParseHostName ( char *  peerName,
UInt32 ip,
UInt16 portVal,
UInt16  defaultPort 
)

int stunParseMessage ( char *  buf,
unsigned int  bufLen,
StunMessage msg,
int  verbose 
)

int stunParseServerName ( char *  name,
StunAddress4 addr 
)

int stunRand (  ) 

int stunRandomPort (  ) 

static void stunSendTest ( int  myFd,
StunAddress4 dest,
const StunAtrString username,
const StunAtrString password,
int  testNum,
int  verbose 
) [static]

int stunServerProcess ( StunServerInfo info,
int  verbose 
)

int stunServerProcessMsg ( char *  buf,
unsigned int  bufLen,
StunAddress4 from,
StunAddress4 secondary,
StunAddress4 myAddr,
StunAddress4 altAddr,
StunMessage resp,
StunAddress4 destination,
StunAtrString hmacPassword,
int *  changePort,
int *  changeIp,
int  verbose 
)

void stunStopServer ( StunServerInfo info  ) 

void stunTest ( StunAddress4 dest,
int  testNum,
int  verbose,
StunAddress4 sAddr 
)

static void toHex ( const char *  buffer,
int  bufferSize,
char *  output 
) [static]


Variable Documentation

UInt16 BindErrorResponseMsg = 0x0111

UInt16 BindRequestMsg = 0x0001

UInt16 BindResponseMsg = 0x0101

UInt16 ChangedAddress = 0x0005

UInt32 ChangeIpFlag = 0x04

UInt32 ChangePortFlag = 0x02

UInt16 ChangeRequest = 0x0003

UInt16 ErrorCode = 0x0009

UInt8 IPv4Family = 0x01

UInt8 IPv6Family = 0x02

UInt16 MappedAddress = 0x0001

UInt16 MessageIntegrity = 0x0008

UInt16 Password = 0x0007

UInt16 ReflectedFrom = 0x000B

UInt16 ResponseAddress = 0x0002

UInt16 SecondaryAddress = 0x8050

UInt16 ServerName = 0x8022

UInt16 SharedSecretErrorResponseMsg = 0x0112

UInt16 SharedSecretRequestMsg = 0x0002

UInt16 SharedSecretResponseMsg = 0x0102

UInt16 SourceAddress = 0x0004

UInt16 UnknownAttribute = 0x000A

UInt16 Username = 0x0006

UInt16 XorMappedAddress = 0x8020

UInt16 XorOnly = 0x0021


Generated on Mon Oct 22 11:43:44 2007 for OpenHIP by  doxygen 1.5.1