Revision 5f3adef4 ml/util/stun.c

View differences:

ml/util/stun.c
41 41
#include <stdio.h> 
42 42
#include <unistd.h>
43 43

  
44
#include <sys/ioctl.h>
45
#include <sys/socket.h>
44 46
#include <sys/time.h>
45 47
#include <sys/types.h> 
48
#include <arpa/inet.h>
46 49

  
47 50
#include <fcntl.h>
48

  
49
#ifndef WIN32
50
#include <sys/ioctl.h>
51
#include <sys/socket.h>
52 51
#include <netdb.h>
53 52
#include <netinet/in.h>
54 53
//#include <arpa/nameser.h>
55 54
//#include <resolv.h>
56 55
#include <net/if.h>
57
#include <arpa/inet.h>
58

  
59
#else
60

  
61
#include <winsock2.h>
62
#include <ws2tcpip.h>
63

  
64
#endif
65 56

  
66 57
#include "ml_log.h"
67 58
#include "stun.h"
68 59
#include "udpSocket.h"
69 60

  
70
#define STUN_VERBOSE false
71

  
72 61
/// define a structure to hold a stun address             
73 62
const UInt8  IPv4Family = 0x01;
74 63
const UInt8  IPv6Family = 0x02;
......
113 102
  assert( sizeof(UInt16) == 2 );
114 103
  assert( sizeof(UInt32) == 4 );
115 104

  
116
  bool verbose = STUN_VERBOSE;
105
  bool verbose = false;
117 106
  
118 107
  //set the verbose mode 
119 108
  verbose = true;
......
142 131
  struct iovec iov;
143 132
  iov.iov_len = len;
144 133
  iov.iov_base = buf;
145
debug("Sending STUN %d!!!!!\n",len); 
146 134
  sendPacket(udpSocket,&iov,1,stunServ);
147 135

  
148 136
  return 0;
......
165 153
  //memset(&resp, 0, sizeof(StunMessage));
166 154
  int returnValue = 0;
167 155
  //bool verbose = true;
168
  bool verbose = STUN_VERBOSE;
156
  bool verbose = false;
169 157

  
170 158
  //debug("still alive 4 \n ");
171 159
  //if ( verbose ) info("Got a response \n");
......
199 187
              response->changedAddress.ipv4.port);
200 188

  
201 189
      }
190
  debug("still here");
202 191

  
203 192
  //reflexiveAddr.sin_addr.s_addr = inet_addr(changed_addr);
204 193
  //reflexiveAddr->sin_addr.s_addr = inet_addr("1.1.1.1");
......
289 278
   char* body = buf + sizeof(StunMsgHdr);
290 279
   unsigned int size = msg->msgHdr.msgLength;
291 280
	
292
//   debug("bytes after header = %d\n",size);
281
   debug("bytes after header = %d",size);
293 282
	
294 283
   while ( size > 0 )
295 284
   {
......
349 338
            }
350 339
            else
351 340
            {
352
	      if (verbose) info("ChangeRequest = %ud \n", msg->changeRequest.value);
341
	      if (verbose) info("ChangeRequest = %i \n",(int)&msg->changeRequest.value);
353 342
            }
354 343
            
355 344
	} else if (atrType == SourceAddress)
......
802 791
{
803 792
   if ( hdrLen != 4 )
804 793
   {
805
      error("hdr length = %d excepcting %ld \n ",hdrLen,sizeof(result));
794
      error("hdr length = %d excepcting %d \n ",hdrLen,sizeof(result));
806 795

  
807 796
      error("Incorrect size for ChangeRequest \n ");
808 797

  

Also available in: Unified diff