Changeset 245:d053353411bb
- Timestamp:
- 10/12/07 19:37:55
(1 year ago)
- Author:
- vadim@mbdsys.com
- Message:
cosmetics
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r244 |
r245 |
|
| 3239 | 3239 | if (!strncasecmp(phcfg.nattype, "auto", 4)) |
|---|
| 3240 | 3240 | { |
|---|
| 3241 | | NatType ntype; |
|---|
| 3242 | | int resPort = 0, hairpin = 0; |
|---|
| 3243 | | int needMappedAddress = 0; |
|---|
| 3244 | | StunAddress4 stunServerAddr; |
|---|
| 3245 | | |
|---|
| 3246 | | ntstr = "sym"; |
|---|
| 3247 | | |
|---|
| 3248 | | stunParseServerName(phcfg.stunserver, &stunServerAddr); |
|---|
| 3249 | | ph_nat_type = ntype = stunNatType( &stunServerAddr, phDebugLevel > 1, &resPort, &hairpin, |
|---|
| | 3241 | NatType ntype; |
|---|
| | 3242 | int resPort = 0, hairpin = 0; |
|---|
| | 3243 | int needMappedAddress = 0; |
|---|
| | 3244 | StunAddress4 stunServerAddr; |
|---|
| | 3245 | |
|---|
| | 3246 | ntstr = "sym"; |
|---|
| | 3247 | |
|---|
| | 3248 | stunParseServerName(phcfg.stunserver, &stunServerAddr); |
|---|
| | 3249 | ph_nat_type = ntype = stunNatType( &stunServerAddr, phDebugLevel > 1, &resPort, &hairpin, |
|---|
| 3250 | 3250 | 0, 0); |
|---|
| 3251 | 3251 | |
|---|
| 3252 | 3252 | |
|---|
| 3253 | | switch (ntype) |
|---|
| 3254 | | { |
|---|
| | 3253 | switch (ntype) |
|---|
| | 3254 | { |
|---|
| | 3255 | |
|---|
| | 3256 | |
|---|
| | 3257 | case StunTypeOpen: |
|---|
| | 3258 | ntstr = 0; |
|---|
| | 3259 | break; |
|---|
| 3255 | 3260 | |
|---|
| 3256 | | |
|---|
| 3257 | | case StunTypeOpen: |
|---|
| 3258 | | ntstr = 0; |
|---|
| 3259 | | break; |
|---|
| 3260 | | |
|---|
| 3261 | | case StunTypeConeNat: |
|---|
| 3262 | | ntstr = "fcone"; |
|---|
| 3263 | | needMappedAddress = 1; |
|---|
| 3264 | | break; |
|---|
| 3265 | | |
|---|
| 3266 | | case StunTypeRestrictedNat: |
|---|
| 3267 | | ntstr = "rcone"; |
|---|
| 3268 | | needMappedAddress = 1; |
|---|
| 3269 | | break; |
|---|
| 3270 | | |
|---|
| 3271 | | case StunTypePortRestrictedNat: |
|---|
| 3272 | | ntstr = "prcone"; |
|---|
| 3273 | | needMappedAddress = 1; |
|---|
| 3274 | | break; |
|---|
| 3275 | | |
|---|
| 3276 | | case StunTypeSymFirewall: |
|---|
| 3277 | | case StunTypeSymNat: |
|---|
| 3278 | | needMappedAddress = 1; |
|---|
| 3279 | | break; |
|---|
| 3280 | | |
|---|
| 3281 | | |
|---|
| 3282 | | case StunTypeFailure: |
|---|
| 3283 | | case StunTypeUnknown: |
|---|
| 3284 | | case StunTypeBlocked: |
|---|
| 3285 | | default: |
|---|
| 3286 | | break; |
|---|
| | 3261 | case StunTypeConeNat: |
|---|
| | 3262 | ntstr = "fcone"; |
|---|
| | 3263 | needMappedAddress = 1; |
|---|
| | 3264 | break; |
|---|
| | 3265 | |
|---|
| | 3266 | case StunTypeRestrictedNat: |
|---|
| | 3267 | ntstr = "rcone"; |
|---|
| | 3268 | needMappedAddress = 1; |
|---|
| | 3269 | break; |
|---|
| | 3270 | |
|---|
| | 3271 | case StunTypePortRestrictedNat: |
|---|
| | 3272 | ntstr = "prcone"; |
|---|
| | 3273 | needMappedAddress = 1; |
|---|
| | 3274 | break; |
|---|
| | 3275 | |
|---|
| | 3276 | case StunTypeSymFirewall: |
|---|
| | 3277 | case StunTypeSymNat: |
|---|
| | 3278 | needMappedAddress = 1; |
|---|
| | 3279 | break; |
|---|
| | 3280 | |
|---|
| | 3281 | |
|---|
| | 3282 | case StunTypeFailure: |
|---|
| | 3283 | case StunTypeUnknown: |
|---|
| | 3284 | case StunTypeBlocked: |
|---|
| | 3285 | default: |
|---|
| | 3286 | break; |
|---|
| 3287 | 3287 | |
|---|
| 3288 | 3288 | } |
|---|
| 3289 | 3289 | |
|---|
| 3290 | | if (needMappedAddress) |
|---|
| 3291 | | { |
|---|
| 3292 | | StunAddress4 mappedAddr; |
|---|
| 3293 | | Socket sock; |
|---|
| 3294 | | |
|---|
| 3295 | | sock = stunOpenSocket(&stunServerAddr, &mappedAddr, atoi(_get_local_sip_port()), NULL, 0); |
|---|
| 3296 | | |
|---|
| 3297 | | if (-1 != (int) sock) |
|---|
| 3298 | | { |
|---|
| 3299 | | ipv4tostr(ph_nat_router_addr, mappedAddr); |
|---|
| 3300 | | snprintf(ph_nat_sip_port_str, sizeof(ph_nat_sip_port_str), "%d", mappedAddr.port); |
|---|
| 3301 | | stunCloseSocket(sock); |
|---|
| 3302 | | } |
|---|
| 3303 | | |
|---|
| 3304 | | |
|---|
| 3305 | | } |
|---|
| 3306 | | |
|---|
| 3307 | | |
|---|
| | 3290 | if (needMappedAddress) |
|---|
| | 3291 | { |
|---|
| | 3292 | StunAddress4 mappedAddr; |
|---|
| | 3293 | Socket sock; |
|---|
| | 3294 | |
|---|
| | 3295 | sock = stunOpenSocket(&stunServerAddr, &mappedAddr, atoi(_get_local_sip_port()), NULL, 0); |
|---|
| | 3296 | |
|---|
| | 3297 | if (-1 != (int) sock) |
|---|
| | 3298 | { |
|---|
| | 3299 | ipv4tostr(ph_nat_router_addr, mappedAddr); |
|---|
| | 3300 | snprintf(ph_nat_sip_port_str, sizeof(ph_nat_sip_port_str), "%d", mappedAddr.port); |
|---|
| | 3301 | stunCloseSocket(sock); |
|---|
| | 3302 | } |
|---|
| | 3303 | |
|---|
| | 3304 | |
|---|
| | 3305 | } |
|---|
| | 3306 | |
|---|
| | 3307 | |
|---|
| 3308 | 3308 | } |
|---|
| 3309 | 3309 | else if (!strncasecmp(phcfg.nattype, "fcone", 5) || |
|---|
| … | … | |
| 3315 | 3315 | } |
|---|
| 3316 | 3316 | else if (phcfg.use_tunnel) |
|---|
| 3317 | | { |
|---|
| 3318 | | ntstr = "open"; |
|---|
| 3319 | | } |
|---|
| 3320 | | |
|---|
| | 3317 | { |
|---|
| | 3318 | ntstr = "open"; |
|---|
| | 3319 | } |
|---|
| | 3320 | |
|---|
| 3321 | 3321 | if (ntstr) |
|---|
| 3322 | 3322 | { |
|---|
| … | … | |
| 3324 | 3324 | if (!phcfg.nat_refresh_time) |
|---|
| 3325 | 3325 | phcfg.nat_refresh_time = 15; |
|---|
| 3326 | | |
|---|
| | 3326 | |
|---|
| 3327 | 3327 | strncpy(ph_nat_type_str, ntstr, sizeof(ph_nat_type_str)); |
|---|
| 3328 | 3328 | if (ph_nat_router_addr[0] && strcmp(ntstr, "sym")) |
|---|
| … | … | |
| 3332 | 3332 | eXosip_set_firewallport(ph_nat_sip_port_str); |
|---|
| 3333 | 3333 | } |
|---|
| 3334 | | |
|---|
| | 3334 | |
|---|
| 3335 | 3335 | } |
|---|
| 3336 | 3336 | else |
|---|