@@ -497,6 +497,7 @@ void AccountNatConfig::readObject(const ContainerNode &node)
497497 NODE_READ_UNSIGNED ( this_node, udpKaIntervalSec);
498498 NODE_READ_STRING ( this_node, udpKaData);
499499 NODE_READ_INT ( this_node, contactUseSrcPort);
500+ NODE_READ_STRINGV ( this_node, iceManualHost);
500501}
501502
502503void AccountNatConfig::writeObject (ContainerNode &node) const
@@ -534,6 +535,7 @@ void AccountNatConfig::writeObject(ContainerNode &node) const
534535 NODE_WRITE_UNSIGNED ( this_node, udpKaIntervalSec);
535536 NODE_WRITE_STRING ( this_node, udpKaData);
536537 NODE_WRITE_INT ( this_node, contactUseSrcPort);
538+ NODE_WRITE_STRINGV (this_node, iceManualHost);
537539}
538540
539541// /////////////////////////////////////////////////////////////////////////////
@@ -758,6 +760,25 @@ void AccountConfig::toPj(pjsua_acc_config &ret) const
758760 ret.ice_cfg .enable_ice = natConfig.iceEnabled ;
759761 ret.ice_cfg .ice_opt .trickle = natConfig.iceTrickle ;
760762 ret.ice_cfg .ice_max_host_cands = natConfig.iceMaxHostCands ;
763+ ret.ice_cfg .ice_manual_host_cnt = 0 ;
764+ if (natConfig.iceManualHost .size () >
765+ PJ_ARRAY_SIZE (ret.ice_cfg .ice_manual_host ))
766+ {
767+ PJSUA2_RAISE_ERROR (PJ_ETOOMANY);
768+ }
769+ for (i=0 ; i<natConfig.iceManualHost .size (); ++i) {
770+ pj_str_t tmp = pj_str (const_cast <char *>
771+ (natConfig.iceManualHost [i].c_str ()));
772+ pj_sockaddr* addr =
773+ &ret.ice_cfg .ice_manual_host [ret.ice_cfg .ice_manual_host_cnt ];
774+ if (pj_sockaddr_set_str_addr (pj_AF_INET (), addr, &tmp)==PJ_SUCCESS ||
775+ pj_sockaddr_set_str_addr (pj_AF_INET6 (), addr, &tmp)==PJ_SUCCESS)
776+ {
777+ ret.ice_cfg .ice_manual_host_cnt ++;
778+ } else {
779+ PJSUA2_RAISE_ERROR (PJ_EINVAL);
780+ }
781+ }
761782 ret.ice_cfg .ice_opt .aggressive = natConfig.iceAggressiveNomination ;
762783 ret.ice_cfg .ice_opt .nominated_check_delay =
763784 natConfig.iceNominatedCheckDelayMsec ;
@@ -933,6 +954,14 @@ void AccountConfig::fromPj(const pjsua_acc_config &prm,
933954 natConfig.iceEnabled = PJ2BOOL (prm.ice_cfg .enable_ice );
934955 natConfig.iceTrickle = prm.ice_cfg .ice_opt .trickle ;
935956 natConfig.iceMaxHostCands = prm.ice_cfg .ice_max_host_cands ;
957+ natConfig.iceManualHost .clear ();
958+ for (i=0 ; i<prm.ice_cfg .ice_manual_host_cnt ; ++i) {
959+ char buf[PJ_INET6_ADDRSTRLEN];
960+ const pj_sockaddr *addr = &prm.ice_cfg .ice_manual_host [i];
961+ if (pj_sockaddr_print (addr, buf, sizeof (buf), 0 ) != NULL ) {
962+ natConfig.iceManualHost .push_back (std::string (buf));
963+ }
964+ }
936965 natConfig.iceAggressiveNomination =
937966 PJ2BOOL (prm.ice_cfg .ice_opt .aggressive );
938967 natConfig.iceNominatedCheckDelayMsec =
0 commit comments