source: trunk/libtransmission/natpmp.c @ 5592

Last change on this file since 5592 was 5592, checked in by charles, 14 years ago

#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit#864: crash on exit

  • Property svn:keywords set to Date Rev Author Id
File size: 6.1 KB
Line 
1/*
2 * This file Copyright (C) 2007-2008 Charles Kerr <charles@rebelbase.com>
3 *
4 * This file is licensed by the GPL version 2.  Works owned by the
5 * Transmission project are granted a special exemption to clause 2(b)
6 * so that the bulk of its code can remain under the MIT license.
7 * This exemption does not extend to derived works not owned by
8 * the Transmission project.
9 *
10 * $Id: natpmp.c 5592 2008-04-12 02:26:45Z charles $
11 */
12
13#include <assert.h>
14#include <errno.h>
15#include <time.h>
16#include <inttypes.h>
17
18#ifdef WIN32
19#include <winsock2.h> /* inet_ntoa */
20#else
21#include <arpa/inet.h> /* inet_ntoa */
22#endif
23
24#include <libnatpmp/natpmp.h>
25
26#include "transmission.h"
27#include "natpmp.h"
28#include "port-forwarding.h"
29#include "utils.h"
30
31#define LIFETIME_SECS 3600
32#define COMMAND_WAIT_SECS 8
33
34static const char * getKey( void ) { return _( "Port Forwarding (NAT-PMP)" ); }
35
36typedef enum
37{
38    TR_NATPMP_IDLE,
39    TR_NATPMP_ERR,
40    TR_NATPMP_DISCOVER,
41    TR_NATPMP_RECV_PUB,
42    TR_NATPMP_SEND_MAP,
43    TR_NATPMP_RECV_MAP,
44    TR_NATPMP_SEND_UNMAP,
45    TR_NATPMP_RECV_UNMAP
46}
47tr_natpmp_state;
48   
49struct tr_natpmp
50{
51    int port;
52    unsigned int isMapped      : 1;
53    unsigned int hasDiscovered : 1;
54    time_t renewTime;
55    time_t commandTime;
56    tr_natpmp_state state;
57    natpmp_t natpmp;
58};
59
60/**
61***
62**/
63
64static void
65logVal( const char * func, int ret )
66{
67    if( ret==NATPMP_TRYAGAIN )
68        tr_ndbg( getKey(),  "%s responded \"try again\"", func );
69    else if( ret >= 0 )
70        tr_ninf( getKey(), _( "%s succeeded (%d)" ), func, ret );
71    else
72        tr_ninf( getKey(), _( "%s failed (%d): %s (%d)" ), func, ret, tr_strerror(errno), errno );
73}
74
75struct tr_natpmp*
76tr_natpmpInit( void )
77{
78    struct tr_natpmp * nat;
79    nat = tr_new0( struct tr_natpmp, 1 );
80    nat->state = TR_NATPMP_DISCOVER;
81    nat->port = -1;
82    return nat;
83}
84
85void
86tr_natpmpClose( tr_natpmp * nat )
87{
88    if( nat )
89    {
90        closenatpmp( &nat->natpmp );
91        tr_free( nat );
92    }
93}
94
95static int
96canSendCommand( const struct tr_natpmp * nat )
97{
98    return time(NULL) >= nat->commandTime;
99}
100
101static void
102setCommandTime( struct tr_natpmp * nat )
103{
104    nat->commandTime = time(NULL) + COMMAND_WAIT_SECS;
105}
106
107static void
108setErrorState( struct tr_natpmp * nat )
109{
110    tr_ninf( getKey(), _( "If your router supports NAT-PMP, please make sure NAT-PMP is enabled!" ) );
111    tr_ninf( getKey(), _( "NAT-PMP port forwarding unsuccessful, trying UPnP next" ) );
112    nat->state = TR_NATPMP_ERR;
113}
114
115int
116tr_natpmpPulse( struct tr_natpmp * nat, int port, int isEnabled )
117{
118    int ret;
119
120    if( isEnabled && ( nat->state == TR_NATPMP_DISCOVER ) )
121    {
122        int val = initnatpmp( &nat->natpmp );
123        logVal( "initnatpmp", val );
124        val = sendpublicaddressrequest( &nat->natpmp );
125        logVal( "sendpublicaddressrequest", val );
126        nat->state = val < 0 ? TR_NATPMP_ERR : TR_NATPMP_RECV_PUB;
127        nat->hasDiscovered = 1;
128        setCommandTime( nat );
129    }
130
131    if( ( nat->state == TR_NATPMP_RECV_PUB ) && canSendCommand( nat ) )
132    {
133        natpmpresp_t response;
134        const int val = readnatpmpresponseorretry( &nat->natpmp, &response );
135        logVal( "readnatpmpresponseorretry", val );
136        if( val >= 0 ) {
137            tr_ninf( getKey(), _( "Found public address \"%s\"" ), inet_ntoa( response.publicaddress.addr ) );
138            nat->state = TR_NATPMP_IDLE;
139        } else if( val != NATPMP_TRYAGAIN ) {
140            setErrorState( nat );
141        }
142    }
143
144    if( ( nat->state == TR_NATPMP_IDLE ) || ( nat->state == TR_NATPMP_ERR ) )
145    {
146        if( nat->isMapped && ( !isEnabled || ( nat->port != port ) ) )
147            nat->state = TR_NATPMP_SEND_UNMAP;
148    }
149
150    if( ( nat->state == TR_NATPMP_SEND_UNMAP ) && canSendCommand( nat ) )
151    {
152        const int val = sendnewportmappingrequest( &nat->natpmp, NATPMP_PROTOCOL_TCP, nat->port, nat->port, 0 );
153        logVal( "sendnewportmappingrequest", val );
154        nat->state = val < 0 ? TR_NATPMP_ERR : TR_NATPMP_RECV_UNMAP;
155        setCommandTime( nat );
156    }
157
158    if( nat->state == TR_NATPMP_RECV_UNMAP )
159    {
160        natpmpresp_t resp;
161        const int val = readnatpmpresponseorretry( &nat->natpmp, &resp );
162        logVal( "readnatpmpresponseorretry", val );
163        if( val >= 0 ) {
164            tr_ninf( getKey(), _( "no longer forwarding port %d" ), nat->port );
165            nat->state = TR_NATPMP_IDLE;
166            nat->port = -1;
167            nat->isMapped = 0;
168        } else if( val != NATPMP_TRYAGAIN ) {
169            setErrorState( nat );
170        }
171    }
172
173    if( nat->state == TR_NATPMP_IDLE )
174    {
175        if( isEnabled && !nat->isMapped && nat->hasDiscovered )
176            nat->state = TR_NATPMP_SEND_MAP;
177
178        else if( nat->isMapped && time(NULL) >= nat->renewTime )
179            nat->state = TR_NATPMP_SEND_MAP;
180    }
181
182    if( ( nat->state == TR_NATPMP_SEND_MAP ) && canSendCommand( nat ) )
183    {
184        const int val = sendnewportmappingrequest( &nat->natpmp, NATPMP_PROTOCOL_TCP, port, port, LIFETIME_SECS );
185        logVal( "sendnewportmappingrequest", val );
186        nat->state = val < 0 ? TR_NATPMP_ERR : TR_NATPMP_RECV_MAP;
187        setCommandTime( nat );
188    }
189
190    if( nat->state == TR_NATPMP_RECV_MAP )
191    {
192        natpmpresp_t resp;
193        const int val = readnatpmpresponseorretry( &nat->natpmp, &resp );
194        logVal( "readnatpmpresponseorretry", val );
195        if( val >= 0 ) {
196            nat->state = TR_NATPMP_IDLE;
197            nat->isMapped = 1;
198            nat->renewTime = time( NULL ) + LIFETIME_SECS;
199            nat->port = resp.newportmapping.privateport;
200            tr_ninf( getKey(), _( "port %d forwarded successfully" ), nat->port );
201        } else if( val != NATPMP_TRYAGAIN ) {
202            setErrorState( nat );
203        }
204    }
205
206    switch( nat->state ) {
207        case TR_NATPMP_IDLE:        ret = nat->isMapped ? TR_NAT_TRAVERSAL_MAPPED : TR_NAT_TRAVERSAL_UNMAPPED; break;
208        case TR_NATPMP_DISCOVER:    ret = TR_NAT_TRAVERSAL_UNMAPPED; break;
209        case TR_NATPMP_RECV_PUB:
210        case TR_NATPMP_SEND_MAP:
211        case TR_NATPMP_RECV_MAP:    ret = TR_NAT_TRAVERSAL_MAPPING; break;
212        case TR_NATPMP_SEND_UNMAP:
213        case TR_NATPMP_RECV_UNMAP:  ret = TR_NAT_TRAVERSAL_UNMAPPING; break;
214        default:                    ret = TR_NAT_TRAVERSAL_ERROR; break;
215    }
216    return ret;
217}
Note: See TracBrowser for help on using the repository browser.