]> sjero.net Git - linphone/commitdiff
- do not register outside of tunnel when tunnel is activated but not yet connected.
authorSimon Morlat <simon.morlat@linphone.org>
Fri, 10 May 2013 13:05:42 +0000 (15:05 +0200)
committerSimon Morlat <simon.morlat@linphone.org>
Fri, 10 May 2013 13:07:01 +0000 (15:07 +0200)
- move TUNNEL_ENABLED to config.h, which avoids recompilation issues with -D flags.

configure.ac
coreapi/TunnelManager.cc
coreapi/TunnelManager.hh
coreapi/linphone_tunnel.cc
coreapi/linphone_tunnel.h
coreapi/linphone_tunnel_stubs.c
coreapi/proxy.c

index 7bc526bbb288f379be0ad3ceae3f86cf1930a86b..5bd0570cc35efd6710283249d6b2d7d5667024c2 100644 (file)
@@ -656,9 +656,7 @@ AC_ARG_ENABLE(tunnel,
 AM_CONDITIONAL(BUILD_TUNNEL, test x$enable_tunnel = xtrue)
 if test x$enable_tunnel = xtrue; then
        PKG_CHECK_MODULES(TUNNEL, tunnel >= 0.3.3)
 AM_CONDITIONAL(BUILD_TUNNEL, test x$enable_tunnel = xtrue)
 if test x$enable_tunnel = xtrue; then
        PKG_CHECK_MODULES(TUNNEL, tunnel >= 0.3.3)
-       TUNNEL_CFLAGS+="-DTUNNEL_ENABLED"
-       AC_SUBST(TUNNEL_CFLAGS)
-       AC_SUBST(TUNNEL_LIBS)
+       AC_DEFINE(TUNNEL_ENABLED,1,[Tells tunnel extension is built-in])
 fi
 
 AC_ARG_ENABLE(msg-storage,
 fi
 
 AC_ARG_ENABLE(msg-storage,
index d1020b1b2782f6d431fefa607771a1ea4bd05173..409f9c42a83635c41ba6ff2890b7166aae46d9f6 100644 (file)
@@ -189,7 +189,7 @@ bool TunnelManager::isStarted() {
 }
 
 bool TunnelManager::isReady() const {
 }
 
 bool TunnelManager::isReady() const {
-       return mTunnelClient && mTunnelClient->isReady();
+       return mTunnelClient && mTunnelClient->isReady() && mReady;
 }
 
 int TunnelManager::customSendto(struct _RtpTransport *t, mblk_t *msg , int flags, const struct sockaddr *to, socklen_t tolen){
 }
 
 int TunnelManager::customSendto(struct _RtpTransport *t, mblk_t *msg , int flags, const struct sockaddr *to, socklen_t tolen){
@@ -214,6 +214,7 @@ TunnelManager::TunnelManager(LinphoneCore* lc) :TunnelClientController()
 ,mEnabled(false)
 ,mTunnelClient(NULL)
 ,mAutoDetectStarted(false)
 ,mEnabled(false)
 ,mTunnelClient(NULL)
 ,mAutoDetectStarted(false)
+,mReady(false)
 ,mHttpProxyPort(0){
 
        mExosipTransport.data=this;
 ,mHttpProxyPort(0){
 
        mExosipTransport.data=this;
@@ -271,6 +272,7 @@ void TunnelManager::processTunnelEvent(const Event &ev){
                if (lProxy) {
                        linphone_proxy_config_done(lProxy);
                }
                if (lProxy) {
                        linphone_proxy_config_done(lProxy);
                }
+               mReady=true;
        }else if (mEnabled && !mTunnelClient->isReady()){
                /* we got disconnected from the tunnel */
                if (lProxy && linphone_proxy_config_is_registered(lProxy)) {
        }else if (mEnabled && !mTunnelClient->isReady()){
                /* we got disconnected from the tunnel */
                if (lProxy && linphone_proxy_config_is_registered(lProxy)) {
@@ -278,6 +280,7 @@ void TunnelManager::processTunnelEvent(const Event &ev){
                        linphone_proxy_config_edit(lProxy);
                        linphone_core_iterate(mCore);
                }
                        linphone_proxy_config_edit(lProxy);
                        linphone_core_iterate(mCore);
                }
+               mReady=false;
        }
 }
 
        }
 }
 
@@ -317,7 +320,7 @@ void TunnelManager::enable(bool isEnable) {
                
                mEnabled=false;
                stopClient();
                
                mEnabled=false;
                stopClient();
-               
+               mReady=false;
                linphone_core_set_rtp_transport_factories(mCore,NULL);
 
                eXosip_transport_hook_register(NULL);
                linphone_core_set_rtp_transport_factories(mCore,NULL);
 
                eXosip_transport_hook_register(NULL);
index d4c1458fcfc933c122b8cec44604fe298a974958..113f76786c5ca3fa90291dd952b2f826d3c8aa59 100644 (file)
@@ -129,6 +129,7 @@ class UdpMirrorClient;
                 */
                LinphoneCore *getLinphoneCore();
                virtual void setHttpProxy(const char *host,int port, const char *username, const char *passwd);
                 */
                LinphoneCore *getLinphoneCore();
                virtual void setHttpProxy(const char *host,int port, const char *username, const char *passwd);
+               virtual bool isReady() const;
        private:
                enum EventType{
                        UdpMirrorClientEvent,
        private:
                enum EventType{
                        UdpMirrorClientEvent,
@@ -143,7 +144,6 @@ class UdpMirrorClient;
                };
                typedef std::list<UdpMirrorClient> UdpMirrorClientList;
                virtual bool isStarted();
                };
                typedef std::list<UdpMirrorClient> UdpMirrorClientList;
                virtual bool isStarted();
-               virtual bool isReady() const;
                void onIterate();
                static int customSendto(struct _RtpTransport *t, mblk_t *msg , int flags, const struct sockaddr *to, socklen_t tolen);
                static int customRecvfrom(struct _RtpTransport *t, mblk_t *msg, int flags, struct sockaddr *from, socklen_t *fromlen);
                void onIterate();
                static int customSendto(struct _RtpTransport *t, mblk_t *msg , int flags, const struct sockaddr *to, socklen_t tolen);
                static int customRecvfrom(struct _RtpTransport *t, mblk_t *msg, int flags, struct sockaddr *from, socklen_t *fromlen);
@@ -173,6 +173,7 @@ class UdpMirrorClient;
                Mutex mMutex;
                static Mutex sMutex;
                bool mAutoDetectStarted;
                Mutex mMutex;
                static Mutex sMutex;
                bool mAutoDetectStarted;
+               bool mReady;
                LinphoneRtpTransportFactories mTransportFactories;
                std::string mHttpUserName;
                std::string mHttpPasswd;
                LinphoneRtpTransportFactories mTransportFactories;
                std::string mHttpUserName;
                std::string mHttpPasswd;
index f0de56694d02a564cf1ea8376a981d2b584b6c8b..079074aa8d2b76e23331476f2bd60bd5bfacdc71 100644 (file)
@@ -233,6 +233,10 @@ bool_t linphone_tunnel_enabled(LinphoneTunnel *tunnel){
        return bcTunnel(tunnel)->isEnabled();
 }
 
        return bcTunnel(tunnel)->isEnabled();
 }
 
+bool_t linphone_tunnel_connected(LinphoneTunnel *tunnel){
+       return bcTunnel(tunnel)->isReady();
+}
+
 static OrtpLogFunc tunnelOrtpLogHandler=NULL;
 
 /*
 static OrtpLogFunc tunnelOrtpLogHandler=NULL;
 
 /*
index e42a054dcc4023bb9385979eb788f28b3f650c0f..f02baab5473ee6d8f7f29b03808eb253667b47a8 100644 (file)
@@ -165,6 +165,12 @@ void linphone_tunnel_enable(LinphoneTunnel *tunnel, bool_t enabled);
 **/
 bool_t linphone_tunnel_enabled(LinphoneTunnel *tunnel);
 
 **/
 bool_t linphone_tunnel_enabled(LinphoneTunnel *tunnel);
 
+/**
+ * @param  tunnel object
+ * Returns a boolean indicating whether tunnel is connected successfully.
+**/
+bool_t linphone_tunnel_connected(LinphoneTunnel *tunnel);
+
 /**
  * @param  tunnel object
  * Forces reconnection to the tunnel server.
 /**
  * @param  tunnel object
  * Forces reconnection to the tunnel server.
index 0560b3956d945a150b6cda0f74f599e55257aeb4..0865704a0dfd904158f91a1cb320f9cbbbf8f3d9 100644 (file)
@@ -59,6 +59,10 @@ bool_t linphone_tunnel_enabled(LinphoneTunnel *tunnel){
         return FALSE;
 }
 
         return FALSE;
 }
 
+bool_t linphone_tunnel_connected(LinphoneTunnel *tunnel){
+       return FALSE;
+}
+
 
 void linphone_tunnel_enable_logs_with_handler(LinphoneTunnel *tunnel, bool_t enabled, OrtpLogFunc logHandler){
 }
 
 void linphone_tunnel_enable_logs_with_handler(LinphoneTunnel *tunnel, bool_t enabled, OrtpLogFunc logHandler){
 }
index 42c21f01b29a36000a9f0ed4b7ef882613c545f2..05258c1d1f26bdf2212ca9d6083b48f2370e58b1 100644 (file)
@@ -413,7 +413,7 @@ static dial_plan_t const dial_plans[]={
        {"Bahrain"                      ,"BH"           , "973"     , 8     , "00"  },
        {"Bangladesh"                   ,"BD"           , "880"     , 10    , "00"  },
        {"Barbados"                     ,"BB"           , "1"       , 10    , "011"     },
        {"Bahrain"                      ,"BH"           , "973"     , 8     , "00"  },
        {"Bangladesh"                   ,"BD"           , "880"     , 10    , "00"  },
        {"Barbados"                     ,"BB"           , "1"       , 10    , "011"     },
-    {"Belarus"                      ,"BY"              , "375"     , 9     , "00"  },
+       {"Belarus"                      ,"BY"           , "375"     , 9     , "00"  },
        {"Belgium"                      ,"BE"           , "32"      , 9     , "00"  },
        {"Belize"                       ,"BZ"           , "501"     , 7     , "00"  },
        {"Benin"                        ,"BJ"           , "229"     , 8     , "00"      },
        {"Belgium"                      ,"BE"           , "32"      , 9     , "00"  },
        {"Belize"                       ,"BZ"           , "501"     , 7     , "00"  },
        {"Benin"                        ,"BJ"           , "229"     , 8     , "00"      },
@@ -422,12 +422,12 @@ static dial_plan_t const dial_plans[]={
        {"Bolivia"                      ,"BO"           , "591"     , 8     , "00"      },
        {"Bosnia and Herzegovina"       ,"BA"           , "387"     , 8     , "00"  },
        {"Botswana"                     ,"BW"           , "267"     , 8     , "00"  },
        {"Bolivia"                      ,"BO"           , "591"     , 8     , "00"      },
        {"Bosnia and Herzegovina"       ,"BA"           , "387"     , 8     , "00"  },
        {"Botswana"                     ,"BW"           , "267"     , 8     , "00"  },
-    {"Brazil"                       ,"BR"              , "55"      , 10        , "00"  },
+       {"Brazil"                       ,"BR"           , "55"      , 10        , "00"  },
        {"Brunei Darussalam"            ,"BN"           , "673"     , 7         , "00"  },
        {"Bulgaria"                     ,"BG"           , "359"     , 9         , "00"  },
        {"Burkina Faso"                 ,"BF"           , "226"     , 8         , "00"  },
        {"Burundi"                      ,"BI"           , "257"     , 8     , "011" },
        {"Brunei Darussalam"            ,"BN"           , "673"     , 7         , "00"  },
        {"Bulgaria"                     ,"BG"           , "359"     , 9         , "00"  },
        {"Burkina Faso"                 ,"BF"           , "226"     , 8         , "00"  },
        {"Burundi"                      ,"BI"           , "257"     , 8     , "011" },
-    {"Cambodia"                     ,"KH"              , "855"     , 9         , "00"  },
+       {"Cambodia"                     ,"KH"           , "855"     , 9         , "00"  },
        {"Cameroon"                     ,"CM"           , "237"     , 8         , "00"  },
        {"Canada"                       ,"CA"           , "1"       , 10        , "011" },
        {"Cape Verde"                   ,"CV"           , "238"     , 7         , "00"  },
        {"Cameroon"                     ,"CM"           , "237"     , 8         , "00"  },
        {"Canada"                       ,"CA"           , "1"       , 10        , "011" },
        {"Cape Verde"                   ,"CV"           , "238"     , 7         , "00"  },
@@ -436,188 +436,188 @@ static dial_plan_t const dial_plans[]={
        {"Chad"                         ,"TD"           , "235"     , 8         , "00"  },
        {"Chile"                        ,"CL"           , "56"      , 9     , "00"  },
        {"China"                        ,"CN"           , "86"      , 11        , "00"  },
        {"Chad"                         ,"TD"           , "235"     , 8         , "00"  },
        {"Chile"                        ,"CL"           , "56"      , 9     , "00"  },
        {"China"                        ,"CN"           , "86"      , 11        , "00"  },
-    {"Colombia"                     ,"CO"       , "57"      , 10       , "00"  },
-    {"Comoros"                      ,"KM"              , "269"     , 7     , "00"      },
-    {"Congo"                        ,"CG"              , "242"     , 9         , "00"  },
-    {"Congo Democratic Republic"       ,"CD"           , "243"     , 9         , "00"  },
-    {"Cook Islands"                 ,"CK"              , "682"     , 5         , "00"  },
-    {"Costa Rica"                   ,"CR"              , "506"     , 8     , "00"      },
-    {"C�te d'Ivoire"             ,"AD"               , "225"     , 8     , "00"  },
-    {"Croatia"                      ,"HR"              , "385"     , 9         , "00"  },
-    {"Cuba"                         ,"CU"              , "53"      , 8     , "119" },
-    {"Cyprus"                       ,"CY"              , "357"     , 8     , "00"      },
-    {"Czech Republic"               ,"CZ"              , "420"     , 9     , "00"  },
-    {"Denmark"                      ,"DK"              , "45"      , 8         , "00"  },
-    {"Djibouti"                     ,"DJ"              , "253"     , 8         , "00"  },
-    {"Dominica"                     ,"DM"              , "1"       , 10        , "011" },
-    {"Dominican Republic"              ,"DO"           , "1"       , 10        , "011" },
-    {"Ecuador"                      ,"EC"       , "593"     , 9                , "00"  },
-    {"Egypt"                        ,"EG"              , "20"      , 10        , "00"  },
-    {"El Salvador"                  ,"SV"              , "503"     , 8         , "00"  },
-    {"Equatorial Guinea"            ,"GQ"              , "240"     , 9         , "00"  },
-    {"Eritrea"                      ,"ER"              , "291"     , 7         , "00"  },
-    {"Estonia"                      ,"EE"              , "372"     , 8     , "00"      },
-    {"Ethiopia"                     ,"ET"              , "251"     , 9     , "00"  },
-    {"Falkland Islands"                    ,"FK"               , "500"     , 5         , "00"  },
-    {"Faroe Islands"               ,"FO"               , "298"     , 6     , "00"  },
-    {"Fiji"                         ,"FJ"              , "679"     , 7     , "00"      },
-    {"Finland"                      ,"FI"              , "358"     , 9     , "00"  },
-    {"France"                       ,"FR"              , "33"      , 9         , "00"  },
-    {"French Guiana"                           ,"GF"           , "594"     , 9         , "00"  },
-    {"French Polynesia"             ,"PF"              , "689"     , 6     , "00"  },
-    {"Gabon"                        ,"GA"              , "241"     , 8     , "00"  },
-    {"Gambia"                       ,"GM"       , "220"     , 7                , "00"  },
-    {"Georgia"                      ,"GE"              , "995"     , 9     , "00"      },
-    {"Germany"                      ,"DE"              , "49"      , 11        , "00"  },
-    {"Ghana"                        ,"GH"              , "233"     , 9         , "00"  },
-    {"Gibraltar"                    ,"GI"              , "350"     , 8         , "00"  },
-    {"Greece"                       ,"GR"              , "30"      ,10     , "00"      },
-    {"Greenland"                    ,"GL"              , "299"     , 6         , "00"  },
-    {"Grenada"                      ,"GD"              , "1"       , 10        , "011" },
-    {"Guadeloupe"                   ,"GP"              , "590"     , 9     , "00"  },
-    {"Guam"                         ,"GU"              , "1"       , 10        , "011" },
-    {"Guatemala"                    ,"GT"              , "502"     , 8     , "00"  },
-    {"Guinea"                       ,"GN"              , "224"     , 8         , "00"  },
-    {"Guinea-Bissau"                           ,"GW"           , "245"     , 7         , "00"  },
-    {"Guyana"                       ,"GY"              , "592"     , 7     , "001" },
-    {"Haiti"                        ,"HT"              , "509"     , 8     , "00"  },
-    {"Honduras"                     ,"HN"       , "504"     , 8                , "00"  },
-    {"Hong Kong"                    ,"HK"              , "852"     , 8     , "001"     },
-    {"Hungary"                      ,"HU"              , "36"      , 9     , "00"  },
-    {"Iceland"                      ,"IS"              , "354"     , 9     , "00"  },
-    {"India"                        ,"IN"              , "91"      , 10    , "00"  },
-    {"Indonesia"                    ,"ID"              , "62"      , 10        , "001" },
-    {"Iran"                         ,"IR"              , "98"      , 10        , "00"  },
-    {"Iraq"                         ,"IQ"              , "964"     , 10        , "00"  },
-    {"Ireland"                      ,"IE"              , "353"     , 9         , "00"  },
-    {"Israel"                       ,"IL"              , "972"     , 9     , "00"      },
-    {"Italy"                        ,"IT"              , "39"      , 10        , "00"  },
-    {"Jamaica"                      ,"JM"              , "1"       , 10        , "011" },
-    {"Japan"                        ,"JP"              , "81"      , 10        , "010" },
-    {"Jordan"                       ,"JO"              , "962"     , 9     , "00"      },
-    {"Kazakhstan"                   ,"KZ"              , "7"       , 10    , "00"  },
-    {"Kenya"                        ,"KE"              , "254"     , 9         , "000" },
-    {"Kiribati"                     ,"KI"              , "686"     , 5         , "00"  },
-    {"Korea, North"                 ,"KP"              , "850"     , 12        , "99"  },
-    {"Korea, South"                 ,"KR"       , "82"      , 12       , "001" },
-    {"Kuwait"                       ,"KW"              , "965"     , 8     , "00"      },
-    {"Kyrgyzstan"                   ,"KG"              , "996"     , 9     , "00"  },
-    {"Laos"                         ,"LA"              , "856"     , 10    , "00"  },
-    {"Latvia"                       ,"LV"              , "371"     , 8     , "00"      },
-    {"Lebanon"                      ,"LB"              , "961"     , 7     , "00"      },
-    {"Lesotho"                      ,"LS"              , "266"     , 8         , "00"  },
-    {"Liberia"                      ,"LR"              , "231"     , 8         , "00"  },
-    {"Libya"                        ,"LY"              , "218"     , 8         , "00"  },
-    {"Liechtenstein"                ,"LI"              , "423"     , 7     , "00"      },
-    {"Lithuania"                    ,"LT"              , "370"     , 8         , "00"  },
-    {"Luxembourg"                   ,"LU"              , "352"     , 9         , "00"  },
-    {"Macau"                        ,"MO"              , "853"     , 8     , "00"  },
-    {"Macedonia"                    ,"MK"              , "389"     , 8     , "00"      },
-    {"Madagascar"                   ,"MG"              , "261"     , 9     , "00"  },
-    {"Malawi"                       ,"MW"              , "265"     , 9         , "00"  },
-    {"Malaysia"                     ,"MY"              , "60"      , 9         , "00"  },
-    {"Maldives"                     ,"MV"              , "960"     , 7     , "00"  },
-    {"Mali"                         ,"ML"              , "223"     , 8     , "00"  },
-    {"Malta"                        ,"MT"       , "356"     , 8                , "00"  },
-    {"Marshall Islands"                                ,"MH"           , "692"     , 7     , "011"     },
-    {"Martinique"                   ,"MQ"              , "596"     , 9     , "00"  },
-    {"Mauritania"                   ,"MR"              , "222"     , 8     , "00"  },
-    {"Mauritius"                    ,"MU"              , "230"     , 7     , "00"      },
-    {"Mayotte Island"               ,"YT"              , "262"     , 9     , "00"      },
-    {"Mexico"                       ,"MX"              , "52"      , 10        , "00"  },
-    {"Micronesia"                   ,"FM"              , "691"     , 7         , "011" },
-    {"Moldova"                      ,"MD"              , "373"     , 8         , "00"  },
-    {"Monaco"                       ,"MC"              , "377"     , 8     , "00"      },
-    {"Mongolia"                     ,"MN"              , "976"     , 8     , "001" },
-    {"Montenegro"                   ,"ME"              , "382"     , 8         , "00"  },
-    {"Montserrat"                   ,"MS"              , "664"     , 10        , "011" },
-    {"Morocco"                      ,"MA"              , "212"     , 9     , "00"      },
-    {"Mozambique"                   ,"MZ"              , "258"     , 9     , "00"  },
-    {"Myanmar"                      ,"MM"              , "95"      , 8         , "00"  },
-    {"Namibia"                      ,"NA"              , "264"     , 9         , "00"  },
-    {"Nauru"                        ,"NR"              , "674"     , 7     , "00"  },
-    {"Nepal"                        ,"NP"              , "43"      , 10        , "00"  },
-    {"Netherlands"                  ,"NL"       , "31"      , 9                , "00"  },
-    {"New Caledonia"                           ,"NC"           , "687"     , 6     , "00"      },
-    {"New Zealand"                  ,"NZ"              , "64"      , 10        , "00"  },
-    {"Nicaragua"                    ,"NI"              , "505"     , 8     , "00"  },
-    {"Niger"                        ,"NE"              , "227"     , 8     , "00"      },
-    {"Nigeria"                      ,"NG"              , "234"     , 10        , "009" },
-    {"Niue"                         ,"NU"              , "683"     , 4         , "00"  },
-    {"Norfolk Island"              ,"NF"               , "672"     , 5         , "00"  },
-    {"Northern Mariana Islands"            ,"MP"               , "1"       , 10        , "011" },
-    {"Norway"                       ,"NO"              , "47"      , 8     , "00"      },
-    {"Oman"                         ,"OM"              , "968"     , 8         , "00"  },
-    {"Pakistan"                     ,"PK"              , "92"      , 10        , "00"  },
-    {"Palau"                        ,"PW"              , "680"     , 7     , "011" },
-    {"Palestine"                    ,"PS"              , "970"     , 9     , "00"      },
-    {"Panama"                       ,"PA"              , "507"     , 8     , "00"  },
-    {"Papua New Guinea"                    ,"PG"               , "675"     , 8         , "00"  },
-    {"Paraguay"                     ,"PY"              , "595"     , 9         , "00"  },
-    {"Peru"                         ,"PE"              , "51"      , 9     , "00"  },
-    {"Philippines"                  ,"PH"              , "63"      , 10        , "00"  },
-    {"Poland"                       ,"PL"       , "48"      , 9                , "00"  },
-    {"Portugal"                     ,"PT"              , "351"     , 9     , "00"      },
-    {"Puerto Rico"                  ,"PR"              , "1"       , 10        , "011" },
-    {"Qatar"                        ,"QA"              , "974"     , 8     , "00"  },
-    {"R�union Island"                                ,"RE"           , "262"     , 9     , "011"     },
-    {"Romania"                      ,"RO"              , "40"      , 9     , "00"      },
-    {"Russian Federation"           ,"RU"              , "7"       , 10        , "8"   },
-    {"Rwanda"                       ,"RW"              , "250"     , 9         , "00"  },
-    {"Saint Helena"                 ,"SH"              , "290"     , 4         , "00"  },
-    {"Saint Kitts and Nevis"           ,"KN"           , "1"       , 10        , "011" },
-    {"Saint Lucia"                  ,"LC"              , "1"       , 10        , "011" },
-    {"Saint Pierre and Miquelon"    ,"PM"              , "508"     , 6         , "00"  },
-    {"Saint Vincent and the Grenadines","VC"   , "1"       , 10        , "011" },
-    {"Samoa"                        ,"WS"              , "685"     , 7     , "0"       },
-    {"San Marino"                   ,"SM"              , "378"     , 10        , "00"  },
-    {"S�o Tom� and Pr�ncipe"        ,"ST"                , "239"     , 7         , "00"  },
-    {"Saudi Arabia"                 ,"SA"              , "966"     , 9         , "00"  },
-    {"Senegal"                      ,"SN"              , "221"     , 9     , "00"  },
-    {"Serbia"                       ,"RS"              , "381"     , 9     , "00"  },
-    {"Seychelles"                   ,"SC"       , "248"     , 7                , "00"  },
-    {"Sierra Leone"                 ,"SL"              , "232"     , 8     , "00"      },
-    {"Singapore"                    ,"SG"              , "65"      , 8     , "001" },
-    {"Slovakia"                     ,"SK"              , "421"     , 9     , "00"  },
-    {"Slovenia"                     ,"SI"              , "386"     , 8     , "00"      },
-    {"Solomon Islands"              ,"SB"              , "677"     , 7     , "00"      },
-    {"Somalia"                      ,"SO"              , "252"     , 8         , "00"  },
-    {"South Africa"                 ,"ZA"              , "27"      , 9         , "00"  },
-    {"Spain"                        ,"ES"              , "34"      , 9         , "00"  },
-    {"Sri Lanka"                    ,"LK"              , "94"      , 9     , "00"      },
-    {"Sudan"                        ,"SD"              , "249"     , 9         , "00"  },
-    {"Suriname"                     ,"SR"              , "597"     , 7         , "00"  },
-    {"Swaziland"                    ,"SZ"              , "268"     , 8     , "00"  },
-    {"Sweden"                       ,"SE"              , "1"       , 9     , "00"      },
-    {"Switzerland"                  ,"XK"              , "41"      , 9         , "00"  },
-    {"Syria"                        ,"SY"              , "963"     , 9         , "00"  },
-    {"Taiwan"                       ,"TW"              , "886"     , 9         , "810" },
-    {"Tajikistan"                   ,"TJ"              , "992"     , 9     , "002" },
-    {"Tanzania"                     ,"TZ"              , "255"     , 9     , "000" },
-    {"Thailand"                     ,"TH"       , "66"      , 9                , "001" },
-    {"Togo"                         ,"TG"              , "228"     , 8     , "00"      },
-    {"Tokelau"                      ,"TK"              , "690"     , 4     , "00"  },
-    {"Tonga"                        ,"TO"              , "676"     , 5     , "00"  },
-    {"Trinidad and Tobago"                     ,"TT"           , "1"       , 10    , "011"     },
-    {"Tunisia"                      ,"TN"              , "216"     , 8     , "00"      },
-    {"Turkey"                       ,"TR"              , "90"      , 10        , "00"  },
-    {"Turkmenistan"                 ,"TM"              , "993"     , 8         , "00"  },
-    {"Turks and Caicos Islands"            ,"TC"               , "1"       , 7         , "0"   },
-    {"Tuvalu"                       ,"TV"              , "688"     , 5     , "00"      },
-    {"Uganda"                       ,"UG"              , "256"     , 9     , "000" },
-    {"Ukraine"                      ,"UA"              , "380"     , 9         , "00"  },
-    {"United Arab Emirates"            ,"AE"           , "971"     , 9     , "00"  },
-    {"United Kingdom"               ,"UK"              , "44"      , 10        , "00"  },
-    {"United States"                ,"US"              , "1"       , 10        , "011" },
-    {"Uruguay"                      ,"UY"              , "598"     , 8         , "00"  },
-    {"Uzbekistan"                   ,"UZ"              , "998"     , 9         , "8"   },
-    {"Vanuatu"                      ,"VU"              , "678"     , 7     , "00"  },
-    {"Venezuela"                    ,"VE"              , "58"      , 10        , "00"  },
-    {"Vietnam"                      ,"VN"              , "84"      , 9     , "00"  },
-    {"Wallis and Futuna"               ,"WF"           , "681"     , 5         , "00"  },
-    {"Yemen"                        ,"YE"              , "967"     , 9     , "00"  },
-    {"Zambia"                       ,"ZM"              , "260"     , 9     , "00"      },
-    {"Zimbabwe"                     ,"ZW"              , "263"     , 9     , "00"  },
+       {"Colombia"                     ,"CO"       , "57"      , 10    , "00"  },
+       {"Comoros"                      ,"KM"           , "269"     , 7     , "00"      },
+       {"Congo"                        ,"CG"           , "242"     , 9         , "00"  },
+       {"Congo Democratic Republic"    ,"CD"           , "243"     , 9         , "00"  },
+       {"Cook Islands"                 ,"CK"           , "682"     , 5         , "00"  },
+       {"Costa Rica"                   ,"CR"           , "506"     , 8     , "00"      },
+       {"C�te d'Ivoire"                  ,"AD"               , "225"     , 8     , "00"  },
+       {"Croatia"                      ,"HR"           , "385"     , 9         , "00"  },
+       {"Cuba"                         ,"CU"           , "53"      , 8     , "119" },
+       {"Cyprus"                       ,"CY"           , "357"     , 8     , "00"      },
+       {"Czech Republic"               ,"CZ"           , "420"     , 9     , "00"  },
+       {"Denmark"                      ,"DK"           , "45"      , 8         , "00"  },
+       {"Djibouti"                     ,"DJ"           , "253"     , 8         , "00"  },
+       {"Dominica"                     ,"DM"           , "1"       , 10        , "011" },
+       {"Dominican Republic"           ,"DO"           , "1"       , 10        , "011" },
+       {"Ecuador"                      ,"EC"       , "593"     , 9             , "00"  },
+       {"Egypt"                        ,"EG"           , "20"      , 10        , "00"  },
+       {"El Salvador"                  ,"SV"           , "503"     , 8         , "00"  },
+       {"Equatorial Guinea"            ,"GQ"           , "240"     , 9         , "00"  },
+       {"Eritrea"                      ,"ER"           , "291"     , 7         , "00"  },
+       {"Estonia"                      ,"EE"           , "372"     , 8     , "00"      },
+       {"Ethiopia"                     ,"ET"           , "251"     , 9     , "00"  },
+       {"Falkland Islands"                 ,"FK"               , "500"     , 5         , "00"  },
+       {"Faroe Islands"                    ,"FO"               , "298"     , 6     , "00"  },
+       {"Fiji"                         ,"FJ"           , "679"     , 7     , "00"      },
+       {"Finland"                      ,"FI"           , "358"     , 9     , "00"  },
+       {"France"                       ,"FR"           , "33"      , 9         , "00"  },
+       {"French Guiana"                                ,"GF"           , "594"     , 9         , "00"  },
+       {"French Polynesia"             ,"PF"           , "689"     , 6     , "00"  },
+       {"Gabon"                        ,"GA"           , "241"     , 8     , "00"  },
+       {"Gambia"                       ,"GM"       , "220"     , 7             , "00"  },
+       {"Georgia"                      ,"GE"           , "995"     , 9     , "00"      },
+       {"Germany"                      ,"DE"           , "49"      , 11        , "00"  },
+       {"Ghana"                        ,"GH"           , "233"     , 9         , "00"  },
+       {"Gibraltar"                    ,"GI"           , "350"     , 8         , "00"  },
+       {"Greece"                       ,"GR"           , "30"      ,10     , "00"      },
+       {"Greenland"                    ,"GL"           , "299"     , 6         , "00"  },
+       {"Grenada"                      ,"GD"           , "1"       , 10        , "011" },
+       {"Guadeloupe"                   ,"GP"           , "590"     , 9     , "00"  },
+       {"Guam"                         ,"GU"           , "1"       , 10        , "011" },
+       {"Guatemala"                    ,"GT"           , "502"     , 8     , "00"  },
+       {"Guinea"                       ,"GN"           , "224"     , 8         , "00"  },
+       {"Guinea-Bissau"                                ,"GW"           , "245"     , 7         , "00"  },
+       {"Guyana"                       ,"GY"           , "592"     , 7     , "001" },
+       {"Haiti"                        ,"HT"           , "509"     , 8     , "00"  },
+       {"Honduras"                     ,"HN"       , "504"     , 8             , "00"  },
+       {"Hong Kong"                    ,"HK"           , "852"     , 8     , "001"     },
+       {"Hungary"                      ,"HU"           , "36"      , 9     , "00"  },
+       {"Iceland"                      ,"IS"           , "354"     , 9     , "00"  },
+       {"India"                        ,"IN"           , "91"      , 10    , "00"  },
+       {"Indonesia"                    ,"ID"           , "62"      , 10        , "001" },
+       {"Iran"                         ,"IR"           , "98"      , 10        , "00"  },
+       {"Iraq"                         ,"IQ"           , "964"     , 10        , "00"  },
+       {"Ireland"                      ,"IE"           , "353"     , 9         , "00"  },
+       {"Israel"                       ,"IL"           , "972"     , 9     , "00"      },
+       {"Italy"                        ,"IT"           , "39"      , 10        , "00"  },
+       {"Jamaica"                      ,"JM"           , "1"       , 10        , "011" },
+       {"Japan"                        ,"JP"           , "81"      , 10        , "010" },
+       {"Jordan"                       ,"JO"           , "962"     , 9     , "00"      },
+       {"Kazakhstan"                   ,"KZ"           , "7"       , 10    , "00"  },
+       {"Kenya"                        ,"KE"           , "254"     , 9         , "000" },
+       {"Kiribati"                     ,"KI"           , "686"     , 5         , "00"  },
+       {"Korea, North"                 ,"KP"           , "850"     , 12        , "99"  },
+       {"Korea, South"                 ,"KR"       , "82"      , 12    , "001" },
+       {"Kuwait"                       ,"KW"           , "965"     , 8     , "00"      },
+       {"Kyrgyzstan"                   ,"KG"           , "996"     , 9     , "00"  },
+       {"Laos"                         ,"LA"           , "856"     , 10    , "00"  },
+       {"Latvia"                       ,"LV"           , "371"     , 8     , "00"      },
+       {"Lebanon"                      ,"LB"           , "961"     , 7     , "00"      },
+       {"Lesotho"                      ,"LS"           , "266"     , 8         , "00"  },
+       {"Liberia"                      ,"LR"           , "231"     , 8         , "00"  },
+       {"Libya"                        ,"LY"           , "218"     , 8         , "00"  },
+       {"Liechtenstein"                ,"LI"           , "423"     , 7     , "00"      },
+       {"Lithuania"                    ,"LT"           , "370"     , 8         , "00"  },
+       {"Luxembourg"                   ,"LU"           , "352"     , 9         , "00"  },
+       {"Macau"                        ,"MO"           , "853"     , 8     , "00"  },
+       {"Macedonia"                    ,"MK"           , "389"     , 8     , "00"      },
+       {"Madagascar"                   ,"MG"           , "261"     , 9     , "00"  },
+       {"Malawi"                       ,"MW"           , "265"     , 9         , "00"  },
+       {"Malaysia"                     ,"MY"           , "60"      , 9         , "00"  },
+       {"Maldives"                     ,"MV"           , "960"     , 7     , "00"  },
+       {"Mali"                         ,"ML"           , "223"     , 8     , "00"  },
+       {"Malta"                        ,"MT"       , "356"     , 8             , "00"  },
+       {"Marshall Islands"                             ,"MH"           , "692"     , 7     , "011"     },
+       {"Martinique"                   ,"MQ"           , "596"     , 9     , "00"  },
+       {"Mauritania"                   ,"MR"           , "222"     , 8     , "00"  },
+       {"Mauritius"                    ,"MU"           , "230"     , 7     , "00"      },
+       {"Mayotte Island"               ,"YT"           , "262"     , 9     , "00"      },
+       {"Mexico"                       ,"MX"           , "52"      , 10        , "00"  },
+       {"Micronesia"                   ,"FM"           , "691"     , 7         , "011" },
+       {"Moldova"                      ,"MD"           , "373"     , 8         , "00"  },
+       {"Monaco"                       ,"MC"           , "377"     , 8     , "00"      },
+       {"Mongolia"                     ,"MN"           , "976"     , 8     , "001" },
+       {"Montenegro"                   ,"ME"           , "382"     , 8         , "00"  },
+       {"Montserrat"                   ,"MS"           , "664"     , 10        , "011" },
+       {"Morocco"                      ,"MA"           , "212"     , 9     , "00"      },
+       {"Mozambique"                   ,"MZ"           , "258"     , 9     , "00"  },
+       {"Myanmar"                      ,"MM"           , "95"      , 8         , "00"  },
+       {"Namibia"                      ,"NA"           , "264"     , 9         , "00"  },
+       {"Nauru"                        ,"NR"           , "674"     , 7     , "00"  },
+       {"Nepal"                        ,"NP"           , "43"      , 10        , "00"  },
+       {"Netherlands"                  ,"NL"       , "31"      , 9             , "00"  },
+       {"New Caledonia"                                ,"NC"           , "687"     , 6     , "00"      },
+       {"New Zealand"                  ,"NZ"           , "64"      , 10        , "00"  },
+       {"Nicaragua"                    ,"NI"           , "505"     , 8     , "00"  },
+       {"Niger"                        ,"NE"           , "227"     , 8     , "00"      },
+       {"Nigeria"                      ,"NG"           , "234"     , 10        , "009" },
+       {"Niue"                         ,"NU"           , "683"     , 4         , "00"  },
+       {"Norfolk Island"                   ,"NF"               , "672"     , 5         , "00"  },
+       {"Northern Mariana Islands"         ,"MP"               , "1"       , 10        , "011" },
+       {"Norway"                       ,"NO"           , "47"      , 8     , "00"      },
+       {"Oman"                         ,"OM"           , "968"     , 8         , "00"  },
+       {"Pakistan"                     ,"PK"           , "92"      , 10        , "00"  },
+       {"Palau"                        ,"PW"           , "680"     , 7     , "011" },
+       {"Palestine"                    ,"PS"           , "970"     , 9     , "00"      },
+       {"Panama"                       ,"PA"           , "507"     , 8     , "00"  },
+       {"Papua New Guinea"                 ,"PG"               , "675"     , 8         , "00"  },
+       {"Paraguay"                     ,"PY"           , "595"     , 9         , "00"  },
+       {"Peru"                         ,"PE"           , "51"      , 9     , "00"  },
+       {"Philippines"                  ,"PH"           , "63"      , 10        , "00"  },
+       {"Poland"                       ,"PL"       , "48"      , 9             , "00"  },
+       {"Portugal"                     ,"PT"           , "351"     , 9     , "00"      },
+       {"Puerto Rico"                  ,"PR"           , "1"       , 10        , "011" },
+       {"Qatar"                        ,"QA"           , "974"     , 8     , "00"  },
+       {"R�union Island"                             ,"RE"           , "262"     , 9     , "011"     },
+       {"Romania"                      ,"RO"           , "40"      , 9     , "00"      },
+       {"Russian Federation"           ,"RU"           , "7"       , 10        , "8"   },
+       {"Rwanda"                       ,"RW"           , "250"     , 9         , "00"  },
+       {"Saint Helena"                 ,"SH"           , "290"     , 4         , "00"  },
+       {"Saint Kitts and Nevis"                ,"KN"           , "1"       , 10        , "011" },
+       {"Saint Lucia"                  ,"LC"           , "1"       , 10        , "011" },
+       {"Saint Pierre and Miquelon"    ,"PM"           , "508"     , 6         , "00"  },
+       {"Saint Vincent and the Grenadines","VC"        , "1"       , 10        , "011" },
+       {"Samoa"                        ,"WS"           , "685"     , 7     , "0"       },
+       {"San Marino"                   ,"SM"           , "378"     , 10        , "00"  },
+       {"S�o Tom� and Pr�ncipe"        ,"ST"             , "239"     , 7         , "00"  },
+       {"Saudi Arabia"                 ,"SA"           , "966"     , 9         , "00"  },
+       {"Senegal"                      ,"SN"           , "221"     , 9     , "00"  },
+       {"Serbia"                       ,"RS"           , "381"     , 9     , "00"  },
+       {"Seychelles"                   ,"SC"       , "248"     , 7             , "00"  },
+       {"Sierra Leone"                 ,"SL"           , "232"     , 8     , "00"      },
+       {"Singapore"                    ,"SG"           , "65"      , 8     , "001" },
+       {"Slovakia"                     ,"SK"           , "421"     , 9     , "00"  },
+       {"Slovenia"                     ,"SI"           , "386"     , 8     , "00"      },
+       {"Solomon Islands"              ,"SB"           , "677"     , 7     , "00"      },
+       {"Somalia"                      ,"SO"           , "252"     , 8         , "00"  },
+       {"South Africa"                 ,"ZA"           , "27"      , 9         , "00"  },
+       {"Spain"                        ,"ES"           , "34"      , 9         , "00"  },
+       {"Sri Lanka"                    ,"LK"           , "94"      , 9     , "00"      },
+       {"Sudan"                        ,"SD"           , "249"     , 9         , "00"  },
+       {"Suriname"                     ,"SR"           , "597"     , 7         , "00"  },
+       {"Swaziland"                    ,"SZ"           , "268"     , 8     , "00"  },
+       {"Sweden"                       ,"SE"           , "1"       , 9     , "00"      },
+       {"Switzerland"                  ,"XK"           , "41"      , 9         , "00"  },
+       {"Syria"                        ,"SY"           , "963"     , 9         , "00"  },
+       {"Taiwan"                       ,"TW"           , "886"     , 9         , "810" },
+       {"Tajikistan"                   ,"TJ"           , "992"     , 9     , "002" },
+       {"Tanzania"                     ,"TZ"           , "255"     , 9     , "000" },
+       {"Thailand"                     ,"TH"       , "66"      , 9             , "001" },
+       {"Togo"                         ,"TG"           , "228"     , 8     , "00"      },
+       {"Tokelau"                      ,"TK"           , "690"     , 4     , "00"  },
+       {"Tonga"                        ,"TO"           , "676"     , 5     , "00"  },
+       {"Trinidad and Tobago"                  ,"TT"           , "1"       , 10    , "011"     },
+       {"Tunisia"                      ,"TN"           , "216"     , 8     , "00"      },
+       {"Turkey"                       ,"TR"           , "90"      , 10        , "00"  },
+       {"Turkmenistan"                 ,"TM"           , "993"     , 8         , "00"  },
+       {"Turks and Caicos Islands"         ,"TC"               , "1"       , 7         , "0"   },
+       {"Tuvalu"                       ,"TV"           , "688"     , 5     , "00"      },
+       {"Uganda"                       ,"UG"           , "256"     , 9     , "000" },
+       {"Ukraine"                      ,"UA"           , "380"     , 9         , "00"  },
+       {"United Arab Emirates"         ,"AE"           , "971"     , 9     , "00"  },
+       {"United Kingdom"               ,"UK"           , "44"      , 10        , "00"  },
+       {"United States"                ,"US"           , "1"       , 10        , "011" },
+       {"Uruguay"                      ,"UY"           , "598"     , 8         , "00"  },
+       {"Uzbekistan"                   ,"UZ"           , "998"     , 9         , "8"   },
+       {"Vanuatu"                      ,"VU"           , "678"     , 7     , "00"  },
+       {"Venezuela"                    ,"VE"           , "58"      , 10        , "00"  },
+       {"Vietnam"                      ,"VN"           , "84"      , 9     , "00"  },
+       {"Wallis and Futuna"            ,"WF"           , "681"     , 5         , "00"  },
+       {"Yemen"                        ,"YE"           , "967"     , 9     , "00"  },
+       {"Zambia"                       ,"ZM"           , "260"     , 9     , "00"      },
+       {"Zimbabwe"                     ,"ZW"           , "263"     , 9     , "00"  },
        {NULL                           ,NULL       ,  ""       , 0     , NULL  }
 };
 static dial_plan_t most_common_dialplan={ "generic" ,"", "", 10, "00"};
        {NULL                           ,NULL       ,  ""       , 0     , NULL  }
 };
 static dial_plan_t most_common_dialplan={ "generic" ,"", "", 10, "00"};
@@ -1092,29 +1092,40 @@ SipSetup *linphone_proxy_config_get_sip_setup(LinphoneProxyConfig *cfg){
        return NULL;
 }
 
        return NULL;
 }
 
+static bool_t can_register(LinphoneProxyConfig *cfg){
+       LinphoneCore *lc=cfg->lc;
+#ifdef BUILD_UPNP
+       if (linphone_core_get_firewall_policy(lc)==LinphonePolicyUseUpnp){
+               if(lc->sip_conf.register_only_when_upnp_is_ok && 
+                       (lc->upnp == NULL || !linphone_upnp_context_is_ready_for_register(lc->upnp))) {
+                       return FALSE;
+               }
+       }
+#endif //BUILD_UPNP
+       if (lc->sip_conf.register_only_when_network_is_up){
+               LinphoneTunnel *tunnel=linphone_core_get_tunnel(lc);
+               if (tunnel && linphone_tunnel_enabled(tunnel)){
+                       return linphone_tunnel_connected(tunnel);
+               }else{
+                       return lc->network_reachable;
+               }
+       }
+       return TRUE;
+}
+
 void linphone_proxy_config_update(LinphoneProxyConfig *cfg){
        LinphoneCore *lc=cfg->lc;
        if (cfg->commit){
                if (cfg->type && cfg->ssctx==NULL){
                        linphone_proxy_config_activate_sip_setup(cfg);
                }
 void linphone_proxy_config_update(LinphoneProxyConfig *cfg){
        LinphoneCore *lc=cfg->lc;
        if (cfg->commit){
                if (cfg->type && cfg->ssctx==NULL){
                        linphone_proxy_config_activate_sip_setup(cfg);
                }
-               switch(linphone_core_get_firewall_policy(lc)) {
-                       case LinphonePolicyUseUpnp:
-#ifdef BUILD_UPNP
-                       if(lc->sip_conf.register_only_when_upnp_is_ok && 
-                          (lc->upnp == NULL || !linphone_upnp_context_is_ready_for_register(lc->upnp))) {
-                               break;
-                       }
-#endif //BUILD_UPNP
-                       default:
-                       if ((!lc->sip_conf.register_only_when_network_is_up || lc->network_reachable)) {
-                               linphone_proxy_config_register(cfg);
+               if (can_register(cfg)){
+                       linphone_proxy_config_register(cfg);
+                       if (cfg->publish && cfg->publish_op==NULL){
+                               linphone_proxy_config_send_publish(cfg,lc->presence_mode);
                        }
                        }
-               }       
-               if (cfg->publish && cfg->publish_op==NULL){
-                       linphone_proxy_config_send_publish(cfg,lc->presence_mode);
+                       cfg->commit=FALSE;
                }
                }
-               cfg->commit=FALSE;
        }
 }
 
        }
 }