Revision
14667
Author
brian
Date
2009-08-28 15:30:03 -0500 (Fri, 28 Aug 2009)

Log Message

 add host_lookup api call 

Modified Paths

Diff

Modified: freeswitch/trunk/src/include/switch_utils.h (14666 => 14667)


--- freeswitch/trunk/src/include/switch_utils.h	2009-08-28 20:04:05 UTC (rev 14666)
+++ freeswitch/trunk/src/include/switch_utils.h	2009-08-28 20:30:03 UTC (rev 14667)
@@ -165,7 +165,7 @@
 (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);
 
 
 /*!

Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (14666 => 14667)


--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	2009-08-28 20:04:05 UTC (rev 14666)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	2009-08-28 20:30:03 UTC (rev 14667)
@@ -45,6 +45,23 @@
 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_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;

Modified: freeswitch/trunk/src/switch_utils.c (14666 => 14667)


--- freeswitch/trunk/src/switch_utils.c	2009-08-28 20:04:05 UTC (rev 14666)
+++ freeswitch/trunk/src/switch_utils.c	2009-08-28 20:30:03 UTC (rev 14667)
@@ -867,7 +867,7 @@
 #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;