Mercurial > pidgin
comparison src/stun.c @ 11300:dd1a5969b2e5
[gaim-migrate @ 13500]
Fix two C99isms. I recommend -Wdeclaration-after-statement for everyone.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Thu, 18 Aug 2005 06:36:05 +0000 |
parents | 67f874fadb57 |
children | 7d7dd22215ec |
comparison
equal
deleted
inserted
replaced
11299:421007f39e53 | 11300:dd1a5969b2e5 |
---|---|
59 char *tmp; | 59 char *tmp; |
60 int len; | 60 int len; |
61 struct in_addr in; | 61 struct in_addr in; |
62 struct stun_attrib *attrib; | 62 struct stun_attrib *attrib; |
63 struct stun_header *hdr; | 63 struct stun_header *hdr; |
64 struct ifconf ifc; | |
65 struct ifreq *ifr; | |
66 struct sockaddr_in *sinptr; | |
64 | 67 |
65 len = recv(source, buffer, 10240, 0); | 68 len = recv(source, buffer, 10240, 0); |
66 | 69 |
67 hdr = (struct stun_header*)buffer; | 70 hdr = (struct stun_header*)buffer; |
68 if(hdr->transid[0]!=transid[0] || hdr->transid[1]!=transid[1] || hdr->transid[2]!=transid[2] || hdr->transid[3]!=transid[3]) { // wrong transaction | 71 if(hdr->transid[0]!=transid[0] || hdr->transid[1]!=transid[1] || hdr->transid[2]!=transid[2] || hdr->transid[3]!=transid[3]) { // wrong transaction |
83 gaim_debug_info("simple", "got public ip %s\n",nattype.publicip); | 86 gaim_debug_info("simple", "got public ip %s\n",nattype.publicip); |
84 nattype.status = 2; | 87 nattype.status = 2; |
85 nattype.type = 1; | 88 nattype.type = 1; |
86 | 89 |
87 // is it a NAT? | 90 // is it a NAT? |
88 struct ifconf ifc; | |
89 struct ifreq *ifr; | |
90 struct sockaddr_in *sinptr; | |
91 | 91 |
92 ifc.ifc_len = sizeof(buffer); | 92 ifc.ifc_len = sizeof(buffer); |
93 ifc.ifc_req = (struct ifreq *) buffer; | 93 ifc.ifc_req = (struct ifreq *) buffer; |
94 ioctl(source, SIOCGIFCONF, &ifc); | 94 ioctl(source, SIOCGIFCONF, &ifc); |
95 | 95 |
117 | 117 |
118 struct stun_nattype *gaim_stun_discover(StunCallback cb) { | 118 struct stun_nattype *gaim_stun_discover(StunCallback cb) { |
119 struct sockaddr_in addr; | 119 struct sockaddr_in addr; |
120 struct stun_header data; | 120 struct stun_header data; |
121 int ret = 0; | 121 int ret = 0; |
122 const char *ip = gaim_prefs_get_string("/core/network/stun_ip"); | |
123 int port = gaim_prefs_get_int("/core/network/stun_port"); | |
122 | 124 |
123 if(nattype.status == 1) { // currently discovering | 125 if(nattype.status == 1) { // currently discovering |
124 callbacks = g_slist_append(callbacks, cb); | 126 callbacks = g_slist_append(callbacks, cb); |
125 return NULL; | 127 return NULL; |
126 } | 128 } |
145 nattype.status = 0; | 147 nattype.status = 0; |
146 cb(&nattype); | 148 cb(&nattype); |
147 return &nattype; | 149 return &nattype; |
148 } | 150 } |
149 incb = gaim_input_add(fd, GAIM_INPUT_READ, reply_cb, NULL); | 151 incb = gaim_input_add(fd, GAIM_INPUT_READ, reply_cb, NULL); |
150 | |
151 const char *ip = gaim_prefs_get_string("/core/network/stun_ip"); | |
152 int port = gaim_prefs_get_int("/core/network/stun_port"); | |
153 | 152 |
154 if(port == 0 || ip == NULL || ip[0] == '\0') return NULL; | 153 if(port == 0 || ip == NULL || ip[0] == '\0') return NULL; |
155 | 154 |
156 addr.sin_family = AF_INET; | 155 addr.sin_family = AF_INET; |
157 addr.sin_port = htons(port); | 156 addr.sin_port = htons(port); |