Exemplo n.º 1
0
// Get the self IP address
UINT DCGetMyIp(DDNS_CLIENT *c, bool ipv6, char *dst, UINT dst_size, char *replace_v6)
{
	UINT ret = ERR_INTERNAL_ERROR;

	ret = DCGetMyIpMain(c, ipv6, dst, dst_size, false, replace_v6);


	if (ret == ERR_NO_ERROR)
	{
		IP ip;

		if (StrToIP(&ip, dst))
		{
			if (ipv6 == false && IsIP4(&ip))
			{
				SetCurrentGlobalIP(&ip, false);
			}
			else if (ipv6 && IsIP6(&ip))
			{
				SetCurrentGlobalIP(&ip, true);
			}
		}
	}

	return ret;
}
Exemplo n.º 2
0
// Get an IP address type
bool CfgGetIp(FOLDER *f, char *name, struct IP *ip)
{
	char tmp[MAX_SIZE];
	// Validate arguments
	if (f == NULL || name == NULL || ip == NULL)
	{
		return false;
	}

	Zero(ip, sizeof(IP));

	if (CfgGetStr(f, name, tmp, sizeof(tmp)) == false)
	{
		return false;
	}

	if (StrToIP(ip, tmp) == false)
	{
		return false;
	}

	return true;
}
Exemplo n.º 3
0
//____________________________________________________________
//			Tcp::connect
//____________________________________________________________
void TcpClient::connect() {

//LOGF(" Connecting ");
//	ets_memset(_conn, 0, sizeof(_conn));
_conn->type = ESPCONN_TCP;
_conn->state = ESPCONN_NONE;
//	_conn->proto.tcp = (esp_tcp *) malloc(sizeof(esp_tcp));
ets_memset(_conn->proto.tcp, 0, sizeof(esp_tcp));
_conn->proto.tcp->local_port = espconn_port();
_conn->proto.tcp->remote_port = _remote_port;
_conn->reverse = this;
//registerCb(_conn);
espconn_regist_connectcb(_conn, connectCb);

if (StrToIP(_host, _conn->proto.tcp->remote_ip)) {
	LOGF("TCP: Connect to ip  %s:%d", _host, _remote_port);
	espconn_connect(_conn);
} else {
	LOGF("TCP: Connect to domain %s:%d", _host, _remote_port);
	espconn_gethostbyname(_conn, _host, &_remote_ip.ipAddr, Tcp::dnsFoundCb);
}

}