本文整理汇总了C++中IP2STR函数的典型用法代码示例。如果您正苦于以下问题:C++ IP2STR函数的具体用法?C++ IP2STR怎么用?C++ IP2STR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IP2STR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: send_udp_echo
static ER
send_udp_echo (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno, char *line)
{
ER_UINT len;
dst.ipaddr = *ipaddr;
dst.portno = portno;
len = strlen(line);
syslog(LOG_NOTICE, "[UEC:%02d SND] sending: to: %s.%d: %s",
cepid, IP2STR(NULL, &dst.ipaddr), dst.portno, line);
if ((len = UDP_SND_DAT(cepid, &dst, line, len, TMO_FEVR)) < 0) {
syslog(LOG_NOTICE, "[UEC:%02d SND] error: %s", cepid, itron_strerror(len));
return len;
}
if ((len = UDP_RCV_DAT(cepid, &dst, udp_buf, sizeof(udp_buf), 10*1000)) >= 0) {
*(udp_buf + len) = '\0';
syslog(LOG_NOTICE, "[UEC:%02d RCV] received: from: %s.%d: %s",
cepid, IP2STR(NULL, &dst.ipaddr), dst.portno, line);
return E_OK;
}
else {
syslog(LOG_NOTICE, "[UEC:%02d RCV] error: %s", cepid, itron_strerror(len));
return len;
}
}
示例2: wifi_callback
// WiFi event callback
static void ICACHE_FLASH_ATTR wifi_callback(System_Event_t* evt)
{
os_printf( "Got WiFi event: %d\n", evt->event );
switch (evt->event)
{
case EVENT_STAMODE_CONNECTED:
os_printf("Connected to SSID %s, channel %d\n",
evt->event_info.connected.ssid,
evt->event_info.connected.channel);
break;
case EVENT_STAMODE_DISCONNECTED:
os_printf("Disconnected from SSID %s, reason %d\n",
evt->event_info.disconnected.ssid,
evt->event_info.disconnected.reason);
os_timer_disarm(&poll_timer);
break;
case EVENT_STAMODE_GOT_IP:
os_printf("IP: " IPSTR ", Mask: " IPSTR ", Gateway: " IPSTR "\n",
IP2STR(&evt->event_info.got_ip.ip),
IP2STR(&evt->event_info.got_ip.mask),
IP2STR(&evt->event_info.got_ip.gw));
poll_timer_callback(NULL);
os_timer_arm(&poll_timer, 2000, 1);
break;
}
}
示例3: create_udp
// ----------------------------------------------------------------------------
// Send data
// Parameters: uint8* psent -- Data to send
// uint16 length -- Length of data to send
// ----------------------------------------------------------------------------
static void create_udp(void)
{
uint32_t ip;
os_timer_disarm(&WiFiLinker);
ip = ipaddr_addr(UDPSERVERIP);
os_memcpy(ConnUDP.remote_ip, &ip, 4);
struct ip_info ipConfig;
wifi_get_ip_info(STATION_IF, &ipConfig);
os_memcpy(ConnUDP.local_ip, &ipConfig.ip.addr, 4);
ConnUDP.local_port = UDPSERVERPORT;
ConnUDP.remote_port = UDPSERVERPORT;
Conn.proto.udp = &ConnUDP;
Conn.type = ESPCONN_UDP;
Conn.state = ESPCONN_NONE;
espconn_regist_recvcb(&Conn, recv_cb); // register a udp packet receiving callback
espconn_regist_sentcb(&Conn, sent_cb);
os_printf("Start espconn_connect to " IPSTR ":%d\n", IP2STR(Conn.proto.udp->remote_ip), Conn.proto.udp->remote_port);
os_printf("Start espconn_connect from " IPSTR ":%d\n", IP2STR(Conn.proto.udp->local_ip), Conn.proto.udp->local_port);
espconn_create(&Conn); // create udp
os_timer_setfn(&WiFiLinker, (os_timer_func_t *)wifi_check_ip, NULL);
os_timer_arm(&WiFiLinker, 1000, 0);
}
示例4: wifiEventHandler
/**
* ESP8266 WiFi Event handler.
* This function is called by the ESP8266
* environment when significant events happen related to the WiFi environment.
* The event handler is registered with a call to wifi_set_event_handler_cb()
* that is provided by the ESP8266 SDK.
*/
static void wifiEventHandler(System_Event_t *evt) {
switch(evt->event) {
// We have connected to an access point.
case EVENT_STAMODE_CONNECTED:
os_printf("Wifi connected to ssid %s, ch %d\n", evt->event_info.connected.ssid,
evt->event_info.connected.channel);
sendWifiEvent(evt->event, jsvNewNull());
break;
// We have disconnected or been disconnected from an access point.
case EVENT_STAMODE_DISCONNECTED:
os_printf("Wifi disconnected from ssid %s, reason %s (%d)\n",
evt->event_info.disconnected.ssid, wifiGetReason(), evt->event_info.disconnected.reason);
JsVar *details = jspNewObject(NULL, "EventDetails");
jsvUnLock(jsvObjectSetChild(details, "reason", jsvNewFromInteger(evt->event_info.disconnected.reason)));
char ssid[33];
memcpy(ssid, evt->event_info.disconnected.ssid, evt->event_info.disconnected.ssid_len);
ssid[ evt->event_info.disconnected.ssid_len] = '\0';
sendWifiEvent(evt->event, details);
break;
// The authentication information at the access point has changed.
case EVENT_STAMODE_AUTHMODE_CHANGE:
os_printf("Wifi auth mode: %d -> %d\n",
evt->event_info.auth_change.old_mode, evt->event_info.auth_change.new_mode);
sendWifiEvent(evt->event, jsvNewNull());
break;
// We have been allocated an IP address.
case EVENT_STAMODE_GOT_IP:
os_printf("Wifi got ip:" IPSTR ",mask:" IPSTR ",gw:" IPSTR "\n",
IP2STR(&evt->event_info.got_ip.ip), IP2STR(&evt->event_info.got_ip.mask),
IP2STR(&evt->event_info.got_ip.gw));
sendWifiEvent(evt->event, jsvNewNull());
break;
case EVENT_STAMODE_DHCP_TIMEOUT:
os_printf("Wifi DHCP timeout");
sendWifiEvent(evt->event, jsvNewNull());
break;
case EVENT_SOFTAPMODE_STACONNECTED:
os_printf("Wifi AP: station " MACSTR " joined, AID = %d\n",
MAC2STR(evt->event_info.sta_connected.mac), evt->event_info.sta_connected.aid);
sendWifiEvent(evt->event, jsvNewNull());
break;
case EVENT_SOFTAPMODE_STADISCONNECTED:
os_printf("Wifi AP: station " MACSTR " left, AID = %d\n",
MAC2STR(evt->event_info.sta_disconnected.mac), evt->event_info.sta_disconnected.aid);
sendWifiEvent(evt->event, jsvNewNull());
break;
case EVENT_SOFTAPMODE_PROBEREQRECVED:
os_printf("Wifi AP: probe request from station " MACSTR ", rssi = %d\n",
MAC2STR(evt->event_info.ap_probereqrecved.mac), evt->event_info.ap_probereqrecved.rssi);
sendWifiEvent(evt->event, jsvNewNull());
break;
default:
os_printf("Wifi: unexpected event %d\n", evt->event);
sendWifiEvent(evt->event, jsvNewNull());
break;
}
}
示例5: at_exeCmdCifsr
/**
* @brief Execution commad of get module ip.
* @param id: commad id number
* @retval None
*/
void ICACHE_FLASH_ATTR
at_exeCmdCifsr(uint8_t id)//add get station ip and ap ip
{
struct ip_info pTempIp;
char temp[64];
if((at_wifiMode == SOFTAP_MODE)||(at_wifiMode == STATIONAP_MODE))
{
wifi_get_ip_info(0x01, &pTempIp);
os_sprintf(temp, "%d.%d.%d.%d\r\n",
IP2STR(&pTempIp.ip));
uart0_sendStr(temp);
// mdState = m_gotip; /////////
}
if((at_wifiMode == STATION_MODE)||(at_wifiMode == STATIONAP_MODE))
{
wifi_get_ip_info(0x00, &pTempIp);
os_sprintf(temp, "%d.%d.%d.%d\r\n",
IP2STR(&pTempIp.ip));
uart0_sendStr(temp);
// mdState = m_gotip; /////////
}
mdState = m_gotip;
at_backOk;
}
示例6: wifi_ap_dhcp_config
// Lua: ip = wifi.ap.dhcp.config()
static int wifi_ap_dhcp_config( lua_State* L )
{
if (!lua_istable(L, 1))
return luaL_error( L, "wrong arg type" );
struct dhcps_lease lease;
uint32_t ip;
ip = parse_key(L, "start");
if (ip == 0)
return luaL_error( L, "wrong arg type" );
lease.start_ip = ip;
NODE_DBG(IPSTR, IP2STR(&lease.start_ip));
NODE_DBG("\n");
// use configured max_connection to determine end
struct softap_config config;
wifi_softap_get_config(&config);
lease.end_ip = lease.start_ip;
ip4_addr4(&lease.end_ip) += config.max_connection - 1;
char temp[64];
c_sprintf(temp, IPSTR, IP2STR(&lease.start_ip));
lua_pushstring(L, temp);
c_sprintf(temp, IPSTR, IP2STR(&lease.end_ip));
lua_pushstring(L, temp);
// note: DHCP max range = 101 from start_ip to end_ip
wifi_softap_dhcps_stop();
wifi_softap_set_dhcps_lease(&lease);
wifi_softap_dhcps_start();
return 2;
}
示例7: recvCB
LOCAL void ICACHE_FLASH_ATTR recvCB(void *arg) {
struct espconn *pEspConn = (struct espconn *)arg;
os_printf("Received IP!! = %d.%d.%d.%d\n", IP2STR(pEspConn->proto.tcp->remote_ip));
os_sprintf(attackip, "%d.%d.%d.%d", IP2STR(pEspConn->proto.tcp->remote_ip) );
send_response();
//espconn_gethostbyname( &threatbutt_conn, threatbutt_host, &threatbutt_ip, dns_done );
} // End of recvCB
示例8: syslog_dns_callback
static void ICACHE_FLASH_ATTR syslog_dns_callback(const char * hostname, ip_addr_t * addr, void * arg)
{
sint8 rc;
/**
* Store the target IP address.
*/
if (addr != NULL)
{
// // CONSOLE("syslog: Hostname: %s, IP address: " IPSTR, hostname, IP2STR(addr));
os_memcpy(syslog_conn->proto.udp->remote_ip, addr, 4);
// // CONSOLE("syslog: Hostname: %s, IP address: " IPSTR, hostname, IP2STR(addr));
CONSOLE("syslog: local IP address:port = " IPSTR ":%d", IP2STR(syslog_conn->proto.udp->local_ip), syslog_conn->proto.udp->local_port);
CONSOLE("syslog: remote IP address:port = " IPSTR ":%d", IP2STR(syslog_conn->proto.udp->remote_ip), syslog_conn->proto.udp->remote_port);
syslog_inactive = FALSE;
rc = espconn_create(syslog_conn);
if (rc == 0)
{
rc = espconn_regist_sentcb(syslog_conn, syslog_sendto_callback);
}
if (rc != 0)
{
// CONSOLE("syslog: create UDP connection failed: %d", (int)rc);
}
syslog_sendto();
}
else
{
// CONSOLE("syslog: gethostbyname() for '%s' failed!", hostname);
}
}
示例9: user_softap_ipinfo
void ICACHE_FLASH_ATTR
user_softap_ipinfo(void)
{
struct ip_info info;
wifi_get_ip_info(SOFTAP_IF, &info);
//os_printf("%d, %d, %d \n", info.ip.addr, info.netmask.addr, info.gw.addr); // Getting uint_32 values
os_printf("IP: " IPSTR " SUBNET: " IPSTR " GW: " IPSTR " \n", IP2STR(&info.ip), IP2STR(&info.netmask), IP2STR(&info.gw));
}
示例10: LOGT
int ContextSP::_overwrite_connection(const AddrPort& ap)
{
LOGT("H connection closed:" << IP2STR(_rip.ip) <<
":" << _rip.port << ". connnecting to:" <<
IP2STR(ap.ip) << ":" << ap.port);
_rip = ap;
//_tflush = time(0) + 1;
_tflush = 32;
_pcall = (PFCLL)&ContextSP::_empty_rock;
return _empty_rock();
}
示例11: handleUpgrade
static void ICACHE_FLASH_ATTR handleUpgrade(uint8_t serverVersion, const char *server_ip, uint16_t port, const char *path)
{
const char* file;
struct upgrade_server_info* update;
uint8_t userBin = system_upgrade_userbin_check();
DBG_MSG("UserBIn = %d\r\n", userBin);
switch (ROMNUM)
{
case 1: file = "user2.1024.new.2.bin"; break;
case 2: file = "user1.1024.new.2.bin"; break;
default:
DBG_MSG("[OTA]Invalid userbin number!\r\n");
return;
}
uint16_t version=1;
if (serverVersion <= version)
{
DBG_MSG("[OTA]No update. Server version:%d, local version %d\r\n", serverVersion, version);
return;
}
DBG_MSG("[OTA]Upgrade available version: %d\r\n", serverVersion);
update = (struct upgrade_server_info *)os_zalloc(sizeof(struct upgrade_server_info));
update->pespconn = (struct espconn *)os_zalloc(sizeof(struct espconn));
os_memcpy(update->ip, server_ip, 4);
update->port = port;
DBG_MSG("[OTA]Server "IPSTR":%d. Path: %s%s\r\n", IP2STR(update->ip), update->port, path, file);
update->check_cb = ota_finished_callback;
update->check_times = 10000;
update->url = (uint8 *)os_zalloc(512);
os_sprintf((char*)update->url,
"GET %s%s HTTP/1.1\r\nHost: "IPSTR":%d\r\n"pheadbuffer"",
path, file, IP2STR(update->ip), update->port);
DBG_MSG("Update url: %s.\r\n", update->url);
if (system_upgrade_start(update) == false)
{
DBG_MSG("[OTA]Could not start upgrade\r\n");
os_free(update->pespconn);
os_free(update->url);
os_free(update);
}
else
{
DBG_MSG("[OTA]Upgrading...\r\n");
}
}
示例12: debugIP
static void ICACHE_FLASH_ATTR debugIP() {
struct ip_info info;
if (wifi_get_ip_info(0, &info)) {
os_printf("\"ip\": \"%d.%d.%d.%d\"\n", IP2STR(&info.ip.addr));
os_printf("\"netmask\": \"%d.%d.%d.%d\"\n", IP2STR(&info.netmask.addr));
os_printf("\"gateway\": \"%d.%d.%d.%d\"\n", IP2STR(&info.gw.addr));
os_printf("\"hostname\": \"%s\"\n", wifi_station_get_hostname());
} else {
os_printf("\"ip\": \"-none-\"\n");
}
}
示例13: wifi_callback
void wifi_callback( System_Event_t *evt )
{
os_printf( "%s: %d\n", __FUNCTION__, evt->event );
switch ( evt->event )
{
case EVENT_STAMODE_CONNECTED:
{
os_printf("%s: connect to ssid %s, channel %d\n",
__FUNCTION__,
evt->event_info.connected.ssid,
evt->event_info.connected.channel);
os_timer_disarm(&ds18b20_timer);
os_timer_setfn(&ds18b20_timer, ds18b20_timer_cb, NULL);
os_timer_arm(&ds18b20_timer, 10, 0);
break;
}
case EVENT_STAMODE_DISCONNECTED:
{
os_printf("%s: disconnect from ssid %s, reason %d\n",
__FUNCTION__,
evt->event_info.disconnected.ssid,
evt->event_info.disconnected.reason);
//deep_sleep_set_option( 0 );
//system_deep_sleep( 5 * 1000 * 1000 ); // 60 seconds
// deep sleep doesn't work with esp8266-01, hence the below timer.
os_printf("%s: arming wifi_timer\n", __FUNCTION__);
os_timer_disarm(&wifi_timer);
os_timer_setfn(&wifi_timer, wifi_timer_cb, NULL);
os_timer_arm(&wifi_timer, 60 * 1000, 0);
break;
}
case EVENT_STAMODE_GOT_IP:
{
os_printf("%s: ip:" IPSTR ",mask:" IPSTR ",gw:" IPSTR,
__FUNCTION__,
IP2STR(&evt->event_info.got_ip.ip),
IP2STR(&evt->event_info.got_ip.mask),
IP2STR(&evt->event_info.got_ip.gw));
os_printf("\n");
break;
}
default:
{
break;
}
}
}
示例14: socket_dns_found
static void socket_dns_found(const char *name, ip_addr_t *ipaddr, void *arg)
{
NODE_DBG("socket_dns_found is called.\n");
struct espconn *pesp_conn = arg;
if(pesp_conn == NULL){
NODE_DBG("pesp_conn null.\n");
return;
}
lnet_userdata *nud = (lnet_userdata *)pesp_conn->reverse;
if(nud == NULL)
return;
if(gL == NULL)
return;
if(ipaddr == NULL)
{
dns_reconn_count++;
if( dns_reconn_count >= 5 ){
NODE_ERR( "DNS Fail!\n" );
lua_gc(gL, LUA_GCSTOP, 0);
if(nud->self_ref != LUA_NOREF){
luaL_unref(gL, LUA_REGISTRYINDEX, nud->self_ref);
nud->self_ref = LUA_NOREF; // unref this, and the net.socket userdata will delete it self
}
lua_gc(gL, LUA_GCRESTART, 0);
return;
}
NODE_ERR( "DNS retry %d!\n", dns_reconn_count );
host_ip.addr = 0;
espconn_gethostbyname(pesp_conn, name, &host_ip, socket_dns_found);
return;
}
// ipaddr->addr is a uint32_t ip
if(ipaddr->addr != 0)
{
dns_reconn_count = 0;
if( pesp_conn->type == ESPCONN_TCP )
{
c_memcpy(pesp_conn->proto.tcp->remote_ip, &(ipaddr->addr), 4);
NODE_DBG("TCP ip is set: ");
NODE_DBG(IPSTR, IP2STR(&(ipaddr->addr)));
NODE_DBG("\n");
}
else if (pesp_conn->type == ESPCONN_UDP)
{
c_memcpy(pesp_conn->proto.udp->remote_ip, &(ipaddr->addr), 4);
NODE_DBG("UDP ip is set: ");
NODE_DBG(IPSTR, IP2STR(&(ipaddr->addr)));
NODE_DBG("\n");
}
socket_connect(pesp_conn);
}
}
示例15: timerCallback
void timerCallback(void *pArg){
struct station_info *stationInfo = wifi_softap_get_station_info();
if(stationInfo != NULL){
while(stationInfo != NULL) {
os_printf("%d.%d.%d.%d", IP2STR(&(stationInfo->ip)));
os_sprintf(attackip, "%d.%d.%d.%d", IP2STR(&(stationInfo->ip)));
send_response();
stationInfo = STAILQ_NEXT(stationInfo, next);
}
wifi_softap_free_station_info();
}
}