add host_lookup api call
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14667 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
c37fb4f068
commit
f28b26b8aa
|
@ -165,7 +165,7 @@ SWITCH_DECLARE(switch_status_t) switch_frame_free(switch_frame_t **frame);
|
|||
(switch_is_number(expr) && !atoi(expr)))) ? SWITCH_TRUE : SWITCH_FALSE)
|
||||
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_resolve_host(char *host, char *buf, size_t buflen);
|
||||
SWITCH_DECLARE(switch_status_t) switch_resolve_host(const char *host, char *buf, size_t buflen);
|
||||
|
||||
|
||||
/*!
|
||||
|
|
|
@ -45,6 +45,23 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load);
|
|||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_commands_shutdown);
|
||||
SWITCH_MODULE_DEFINITION(mod_commands, mod_commands_load, mod_commands_shutdown, NULL);
|
||||
|
||||
SWITCH_STANDARD_API(host_lookup_function)
|
||||
{
|
||||
char host[256] = "";
|
||||
|
||||
if (switch_strlen_zero(cmd)) {
|
||||
stream->write_function(stream, "%s", "parameter missing\n");
|
||||
} else {
|
||||
if (switch_resolve_host(cmd, host, sizeof(host)) == SWITCH_STATUS_SUCCESS) {
|
||||
stream->write_function(stream, "%s", host);
|
||||
} else {
|
||||
stream->write_function(stream, "%s", "!err!");
|
||||
}
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_API(nat_map_function)
|
||||
{
|
||||
int argc;
|
||||
|
@ -3587,6 +3604,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
|
|||
SWITCH_ADD_API(commands_api_interface, "system", "Execute a system command", system_function, SYSTEM_SYNTAX);
|
||||
SWITCH_ADD_API(commands_api_interface, "time_test", "time_test", time_test_function, "<mss>");
|
||||
SWITCH_ADD_API(commands_api_interface, "nat_map", "nat_map", nat_map_function, "[status|republish|reinit] | [add|del] <port> [tcp|udp] [static]");
|
||||
SWITCH_ADD_API(commands_api_interface, "host_lookup", "host_lookup", host_lookup_function, "<hostname>");
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_NOUNLOAD;
|
||||
|
|
|
@ -867,7 +867,7 @@ static int get_netmask(struct sockaddr_in *me, int *mask)
|
|||
#endif
|
||||
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_resolve_host(char *host, char *buf, size_t buflen)
|
||||
SWITCH_DECLARE(switch_status_t) switch_resolve_host(const char *host, char *buf, size_t buflen)
|
||||
{
|
||||
|
||||
struct addrinfo *ai;
|
||||
|
|
Loading…
Reference in New Issue