Changeset 748:daf48a9534be in mediastreamer2


Ignore:
Timestamp:
Oct 27, 2009 12:56:52 PM (4 years ago)
Author:
aymeric <aymeric@…>
Branch:
default
Message:

use correct type

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@736 3f6dc0c8-ddfe-455d-9043-3cd528dc4637

Location:
linphone/oRTP
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • linphone/oRTP/include/ortp/stun.h

    r747 r748  
    7777#include <ortp/stun_udp.h> 
    7878 
     79#ifdef __APPLE__ 
     80   #include "TargetConditionals.h" 
     81#endif 
    7982 
    8083#ifdef __cplusplus 
     
    9396 
    9497/* define some basic types */ 
    95 typedef unsigned char  UInt8; 
    96 typedef unsigned short UInt16; 
    97 #if __LP64__ 
    98         typedef unsigned int   UInt32; 
     98#if 0 
     99typedef unsigned char  uint8_t; 
     100typedef unsigned short uint16_t; 
     101typedef unsigned int   uint32_t; 
     102 
     103#if     defined(WIN32) || defined(_WIN32_WCE) 
     104typedef unsigned __int64 uint64_t; 
    99105#else 
    100         typedef unsigned long   UInt32; 
     106typedef unsigned long long uint64_t; 
    101107#endif 
    102 #if     defined(WIN32) || defined(_WIN32_WCE) 
    103 typedef unsigned __int64 UInt64; 
    104 #else 
    105 typedef unsigned long long UInt64; 
    106108#endif 
    107109typedef struct { unsigned char octet[12]; }  UInt96; 
     
    185187typedef struct  
    186188{ 
    187       UInt16 msgType; 
    188       UInt16 msgLength; 
    189       UInt32 magic_cookie; 
     189      uint16_t msgType; 
     190      uint16_t msgLength; 
     191      uint32_t magic_cookie; 
    190192      UInt96 tr_id; 
    191193} StunMsgHdr; 
     
    194196typedef struct 
    195197{ 
    196       UInt16 type; 
    197       UInt16 length; 
     198      uint16_t type; 
     199      uint16_t length; 
    198200} StunAtrHdr; 
    199201 
    200202typedef struct 
    201203{ 
    202       UInt16 port; 
    203       UInt32 addr; 
     204      uint16_t port; 
     205      uint32_t addr; 
    204206} StunAddress4; 
    205207 
    206208typedef struct 
    207209{ 
    208       UInt8 pad; 
    209       UInt8 family; 
     210      uint8_t pad; 
     211      uint8_t family; 
    210212      StunAddress4 ipv4; 
    211213} StunAtrAddress4; 
     
    213215typedef struct 
    214216{ 
    215       UInt32 value; 
     217      uint32_t value; 
    216218} StunAtrChangeRequest; 
    217219 
    218220typedef struct 
    219221{ 
    220       UInt16 pad; /* all 0 */ 
    221       UInt8 errorClass; 
    222       UInt8 number; 
     222      uint16_t pad; /* all 0 */ 
     223      uint8_t errorClass; 
     224      uint8_t number; 
    223225      char reason[STUN_MAX_STRING]; 
    224       UInt16 sizeReason; 
     226      uint16_t sizeReason; 
    225227} StunAtrError; 
    226228 
    227229typedef struct 
    228230{ 
    229       UInt16 attrType[STUN_MAX_UNKNOWN_ATTRIBUTES]; 
    230       UInt16 numAttributes; 
     231      uint16_t attrType[STUN_MAX_UNKNOWN_ATTRIBUTES]; 
     232      uint16_t numAttributes; 
    231233} StunAtrUnknown; 
    232234 
    233235typedef struct 
    234236{ 
    235       UInt16 channelNumber; 
    236       UInt16 rffu; /* Reserved For Future Use */ 
     237      uint16_t channelNumber; 
     238      uint16_t rffu; /* Reserved For Future Use */ 
    237239} TurnAtrChannelNumber; 
    238240 
    239241typedef struct 
    240242{ 
    241       UInt32 lifetime; 
     243      uint32_t lifetime; 
    242244} TurnAtrLifetime; 
    243245 
     
    245247{ 
    246248      char value[1500];       
    247       UInt16 sizeValue; 
     249      uint16_t sizeValue; 
    248250} TurnAtrData; 
    249251 
    250252typedef struct 
    251253{ 
    252       UInt8 proto; 
    253       UInt8 pad1; 
    254       UInt8 pad2; 
    255       UInt8 pad3; 
     254      uint8_t proto; 
     255      uint8_t pad1; 
     256      uint8_t pad2; 
     257      uint8_t pad3; 
    256258} TurnAtrRequestedTransport; 
    257259 
    258260typedef struct 
    259261{ 
    260       UInt64 value; 
     262      uint64_t value; 
    261263} TurnAtrReservationToken; 
    262264 
    263265typedef struct 
    264266{ 
    265       UInt32 fingerprint; 
     267      uint32_t fingerprint; 
    266268} StunAtrFingerprint; 
    267269 
     
    270272{ 
    271273      char value[STUN_MAX_STRING];       
    272       UInt16 sizeValue; 
     274      uint16_t sizeValue; 
    273275} StunAtrString; 
    274276 
    275277typedef struct 
    276278{ 
    277       UInt32 priority; 
     279      uint32_t priority; 
    278280} IceAtrPriority; 
    279281 
    280282typedef struct 
    281283{ 
    282       UInt64 value; 
     284      uint64_t value; 
    283285} IceAtrIceControll; 
    284286 
     
    300302typedef struct 
    301303{ 
    302       UInt16 attrType[STUN_MAX_UNKNOWN_ATTRIBUTES]; 
    303       UInt16 numAttributes; 
     304      uint16_t attrType[STUN_MAX_UNKNOWN_ATTRIBUTES]; 
     305      uint16_t numAttributes; 
    304306} TurnAtrUnknown; 
    305307 
     
    437439void 
    438440stunCalculateIntegrity_shortterm(char* hmac, const char* input, int length, const char* key); 
    439 UInt32 
     441uint32_t 
    440442stunCalculateFingerprint(const char* input, int length); 
    441443 
     
    470472stunRand(void); 
    471473 
    472 UInt64 
     474uint64_t 
    473475stunGetSystemTimeSecs(void); 
    474476 
     
    479481bool_t  
    480482stunParseHostName( const char* peerName, 
    481                    UInt32 *ip, 
    482                    UInt16 *portVal, 
    483                    UInt16 defaultPort ); 
     483                   uint32_t *ip, 
     484                   uint16_t *portVal, 
     485                   uint16_t defaultPort ); 
    484486 
    485487/* return true if all is OK  
     
    496498/* returns number of address found - take array or addres */ 
    497499int  
    498 stunFindLocalInterfaces(UInt32* addresses, int maxSize ); 
     500stunFindLocalInterfaces(uint32_t* addresses, int maxSize ); 
    499501 
    500502int  
  • linphone/oRTP/src/stun.c

    r723 r748  
    136136   if (result->family == IPv4Family) 
    137137   { 
    138       UInt16 nport; 
    139       UInt32 naddr; 
     138      uint16_t nport; 
     139      uint32_t naddr; 
    140140      memcpy(&nport, body, 2); body+=2; 
    141141      result->ipv4.port = ntohs(nport); 
     
    325325#define ntohq(n) n 
    326326#else /* little endian */ 
    327 static inline UInt64 
    328 htonq (UInt64 v) 
    329 { 
    330   return htonl ((UInt32) (v >> 32)) 
    331     | (UInt64) htonl ((UInt32) v) << 32; 
    332 } 
    333 static inline UInt64 
    334 ntohq (UInt64 v) 
    335 { 
    336   return ntohl ((UInt32) (v >> 32)) 
    337     | (UInt64) ntohl ((UInt32) v) << 32; 
     327static inline uint64_t 
     328htonq (uint64_t v) 
     329{ 
     330  return htonl ((uint32_t) (v >> 32)) 
     331    | (uint64_t) htonl ((uint32_t) v) << 32; 
     332} 
     333static inline uint64_t 
     334ntohq (uint64_t v) 
     335{ 
     336  return ntohl ((uint32_t) (v >> 32)) 
     337    | (uint64_t) ntohl ((uint32_t) v) << 32; 
    338338} 
    339339#endif /* little endian */ 
     
    789789 
    790790static char*  
    791 encode16(char* buf, UInt16 data) 
    792 { 
    793    UInt16 ndata = htons(data); 
    794    memcpy(buf, &ndata, sizeof(UInt16)); 
    795    return buf + sizeof(UInt16); 
     791encode16(char* buf, uint16_t data) 
     792{ 
     793   uint16_t ndata = htons(data); 
     794   memcpy(buf, &ndata, sizeof(uint16_t)); 
     795   return buf + sizeof(uint16_t); 
    796796} 
    797797 
    798798static char*  
    799 encode32(char* buf, UInt32 data) 
    800 { 
    801    UInt32 ndata = htonl(data); 
    802    memcpy(buf, &ndata, sizeof(UInt32)); 
    803    return buf + sizeof(UInt32); 
     799encode32(char* buf, uint32_t data) 
     800{ 
     801   uint32_t ndata = htonl(data); 
     802   memcpy(buf, &ndata, sizeof(uint32_t)); 
     803   return buf + sizeof(uint32_t); 
    804804} 
    805805 
    806806static char*  
    807 encode64(char* buf, UInt64 data) 
    808 { 
    809    UInt64 ndata = htonq(data); 
    810    memcpy(buf, &ndata, sizeof(UInt64)); 
    811    return buf + sizeof(UInt64); 
     807encode64(char* buf, uint64_t data) 
     808{ 
     809   uint64_t ndata = htonq(data); 
     810   memcpy(buf, &ndata, sizeof(uint64_t)); 
     811   return buf + sizeof(uint64_t); 
    812812} 
    813813 
     
    821821 
    822822static char*  
    823 encodeAtrAddress4(char* ptr, UInt16 type, const StunAtrAddress4 *atr) 
     823encodeAtrAddress4(char* ptr, uint16_t type, const StunAtrAddress4 *atr) 
    824824{ 
    825825   ptr = encode16(ptr, type); 
     
    881881 
    882882static char*  
    883 encodeAtrString(char* ptr, UInt16 type, const StunAtrString *atr) 
     883encodeAtrString(char* ptr, uint16_t type, const StunAtrString *atr) 
    884884{ 
    885885   int padding; 
     
    914914encodeAtrFingerprint(char* ptr, const StunAtrFingerprint *atr) 
    915915{ 
    916         UInt32 val; 
     916        uint32_t val; 
    917917        ptr = encode16(ptr, SA_FINGERPRINT); 
    918918        ptr = encode16(ptr, 4); 
     
    971971 
    972972static char*  
    973 encodeAtrIceControll(char* ptr, UInt16 type, const IceAtrIceControll *atr) 
     973encodeAtrIceControll(char* ptr, uint16_t type, const IceAtrIceControll *atr) 
    974974{ 
    975975   ptr = encode16(ptr, type); 
     
    11161116      //ortp_debug("stun: HMAC with password: %s\n", password->value ); 
    11171117 
    1118       encode16(lengthp, (UInt16)(ptr - buf - sizeof(StunMsgHdr)+24)); 
     1118      encode16(lengthp, (uint16_t)(ptr - buf - sizeof(StunMsgHdr)+24)); 
    11191119      stunCalculateIntegrity_longterm(integrity.hash, buf, (int)(ptr-buf) , 
    11201120        msg->username.value, msg->realmName.value, password->value); 
     
    11281128      //ortp_debug("stun: HMAC with password: %s\n", password->value ); 
    11291129 
    1130       encode16(lengthp, (UInt16)(ptr - buf - sizeof(StunMsgHdr)+24)); 
     1130      encode16(lengthp, (uint16_t)(ptr - buf - sizeof(StunMsgHdr)+24)); 
    11311131      stunCalculateIntegrity_shortterm(integrity.hash, buf, (int)(ptr-buf) , 
    11321132        password->value); 
     
    11391139      //ortp_debug("stun: HMAC with password: %s\n", password->value ); 
    11401140 
    1141       encode16(lengthp, (UInt16)(ptr - buf - sizeof(StunMsgHdr)+8)); 
     1141      encode16(lengthp, (uint16_t)(ptr - buf - sizeof(StunMsgHdr)+8)); 
    11421142      fingerprint.fingerprint = stunCalculateFingerprint(buf, (int)(ptr-buf)); 
    11431143      ptr = encodeAtrFingerprint(ptr, &fingerprint); 
    11441144   } 
    1145    encode16(lengthp, (UInt16)(ptr - buf - sizeof(StunMsgHdr))); 
     1145   encode16(lengthp, (uint16_t)(ptr - buf - sizeof(StunMsgHdr))); 
    11461146   return (int)(ptr - buf); 
    11471147} 
     
    11551155   if ( !init ) 
    11561156   {  
    1157       UInt64 tick; 
     1157      uint64_t tick; 
    11581158      int seed; 
    11591159      init = TRUE; 
     
    13041304#endif 
    13051305 
    1306 UInt32 
     1306uint32_t 
    13071307stunCalculateFingerprint(const char* input, int length) 
    13081308{ 
     
    13111311        3  *  code or tables extracted from it, as desired without restriction. 
    13121312        4  */ 
    1313         static UInt32 crc32_tab[] = { 
     1313        static uint32_t crc32_tab[] = { 
    13141314                0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 
    13151315                0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 
     
    13651365} 
    13661366 
    1367 UInt64 
     1367uint64_t 
    13681368stunGetSystemTimeSecs(void) 
    13691369{ 
    1370    UInt64 time=0; 
     1370   uint64_t time=0; 
    13711371#if     defined(_WIN32) || defined(_WIN32_WCE) 
    13721372   SYSTEMTIME t; 
     
    13871387bool_t  
    13881388stunParseHostName( const char* peerName, 
    1389                    UInt32* ip, 
    1390                    UInt16* portVal, 
    1391                    UInt16 defaultPort ) 
     1389                   uint32_t* ip, 
     1390                   uint16_t* portVal, 
     1391                   uint16_t defaultPort ) 
    13921392{ 
    13931393   struct in_addr sin_addr; 
     
    15631563   StunAddress4 mapped; 
    15641564   StunAddress4 respondTo; 
    1565    UInt32 flags; 
     1565   uint32_t flags; 
    15661566   bool_t ok; 
    15671567   /* set up information for default response */ 
     
    16921692         if (1) /* do xorMapped address or not */ 
    16931693         { 
    1694             UInt32 cookie = 0x2112A442; 
     1694            uint32_t cookie = 0x2112A442; 
    16951695            resp->hasXorMappedAddress = TRUE; 
    16961696            resp->xorMappedAddress.ipv4.port = mapped.port^(cookie>>16); 
     
    17391739         if (req.hasUsername && (req.username.sizeValue > 64 ) ) 
    17401740         { 
    1741             UInt32 source; 
    1742             /* assert( sizeof(int) == sizeof(UInt32) ); */ 
     1741            uint32_t source; 
     1742            /* assert( sizeof(int) == sizeof(uint32_t) ); */ 
    17431743                                         
    17441744            sscanf(req.username.value, "%x", &source); 
     
    18671867 
    18681868int  
    1869 stunFindLocalInterfaces(UInt32* addresses,int maxRet) 
     1869stunFindLocalInterfaces(uint32_t* addresses,int maxRet) 
    18701870{ 
    18711871#if defined(WIN32) || defined(_WIN32_WCE) || defined(__sparc__) 
     
    18971897      struct sockaddr_in* addr; 
    18981898    
    1899       UInt32 ai; 
     1899      uint32_t ai; 
    19001900      int si = sizeof(ifr->ifr_name) + sizeof(struct sockaddr); 
    19011901      tl -= si; 
     
    20632063         
    20642064   int port = randomPort(); 
    2065    UInt32 interfaceIp=0; 
     2065   uint32_t interfaceIp=0; 
    20662066   Socket myFd; 
    20672067   StunAtrString username; 
     
    21482148   /* assert( dest.addr != 0 ); */ 
    21492149   /* assert( dest.port != 0 ); */ 
    2150    UInt32 interfaceIp=0; 
     2150   uint32_t interfaceIp=0; 
    21512151   Socket myFd1; 
    21522152   Socket myFd2; 
     
    21672167   StunAtrString password; 
    21682168   int count=0; 
    2169    UInt64 second_started; 
    2170    UInt64 second_elapsed; 
     2169   uint64_t second_started; 
     2170   uint64_t second_elapsed; 
    21712171   Socket s; 
    21722172 
     
    25382538   if (resp.hasXorMappedAddress==TRUE) 
    25392539   { 
    2540       UInt32 cookie = 0x2112A442; 
    2541       UInt16 cookie16 = 0x2112A442 >> 16; 
     2540      uint32_t cookie = 0x2112A442; 
     2541      uint16_t cookie16 = 0x2112A442 >> 16; 
    25422542      mappedAddr.port = resp.xorMappedAddress.ipv4.port^cookie16; 
    25432543      mappedAddr.addr = resp.xorMappedAddress.ipv4.addr^cookie; 
     
    26482648      if (resp.hasXorMappedAddress==TRUE) 
    26492649      { 
    2650         UInt32 cookie = 0x2112A442; 
    2651         UInt16 cookie16 = 0x2112A442 >> 16; 
     2650        uint32_t cookie = 0x2112A442; 
     2651        uint16_t cookie16 = 0x2112A442 >> 16; 
    26522652        mappedAddr[i].port = resp.xorMappedAddress.ipv4.port^cookie16; 
    26532653        mappedAddr[i].addr = resp.xorMappedAddress.ipv4.addr^cookie; 
     
    28402840        if (resp.hasXorRelayedAddress==TRUE) 
    28412841        { 
    2842           UInt32 cookie = 0x2112A442; 
    2843           UInt16 cookie16 = 0x2112A442 >> 16; 
     2842          uint32_t cookie = 0x2112A442; 
     2843          uint16_t cookie16 = 0x2112A442 >> 16; 
    28442844          mappedAddr[i].port = resp.xorRelayedAddress.ipv4.port^cookie16; 
    28452845          mappedAddr[i].addr = resp.xorRelayedAddress.ipv4.addr^cookie; 
Note: See TracChangeset for help on using the changeset viewer.