Revision 6575ae37 util/stun.c

View differences:

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>
46 44
#include <sys/time.h>
47 45
#include <sys/types.h> 
48
#include <arpa/inet.h>
49 46

  
50 47
#include <fcntl.h>
48

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

  
59
#else
60

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

  
64
#endif
56 65

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

  
70
#define STUN_VERBOSE false
71

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

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

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

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

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

  
192 203
  //reflexiveAddr.sin_addr.s_addr = inet_addr(changed_addr);
193 204
  //reflexiveAddr->sin_addr.s_addr = inet_addr("1.1.1.1");
......
213 224
      UInt16 nport;
214 225
      memcpy(&nport, body, 2); body+=2;
215 226
      
216
      if (verbose) info("port %i \n",ntohs(nport));
227
      if (verbose) info("port %u \n",ntohs(nport));
217 228

  
218 229
      result->ipv4.port = ntohs(nport);
219 230

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

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

  

Also available in: Unified diff