You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sa...@apache.org on 2006/01/25 15:25:06 UTC
svn commit: r372222 - in /webservices/axis2/trunk/c:
include/axis2_network_handler.h modules/util/Makefile.am
modules/util/network_handler.c test/util/test_util.c
Author: sahan
Date: Wed Jan 25 06:24:52 2006
New Revision: 372222
URL: http://svn.apache.org/viewcvs?rev=372222&view=rev
Log:
added uuid_gen supporting functions and test case
Modified:
webservices/axis2/trunk/c/include/axis2_network_handler.h
webservices/axis2/trunk/c/modules/util/Makefile.am
webservices/axis2/trunk/c/modules/util/network_handler.c
webservices/axis2/trunk/c/test/util/test_util.c
Modified: webservices/axis2/trunk/c/include/axis2_network_handler.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_network_handler.h?rev=372222&r1=372221&r2=372222&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_network_handler.h (original)
+++ webservices/axis2/trunk/c/include/axis2_network_handler.h Wed Jan 25 06:24:52 2006
@@ -80,6 +80,12 @@
AXIS2_DECLARE(int)
axis2_network_handler_svr_socket_accept(axis2_env_t **env, int socket);
+/**
+ * Returns the mac address of the first interface
+ * @return MAC address of the first interface
+ */
+AXIS2_DECLARE(char *)
+axis2_network_handler_get_mac_addr(axis2_env_t **env);
/** @} */
#ifdef __cplusplus
Modified: webservices/axis2/trunk/c/modules/util/Makefile.am
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/Makefile.am?rev=372222&r1=372221&r2=372222&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/util/Makefile.am (original)
+++ webservices/axis2/trunk/c/modules/util/Makefile.am Wed Jan 25 06:24:52 2006
@@ -16,7 +16,8 @@
file_diff.c\
class_loader.c\
network_handler.c \
- file.c
+ file.c\
+ uuid_gen.c
libaxis2_util_la_LIBADD =
INCLUDES = -I$(top_builddir)/include \
Modified: webservices/axis2/trunk/c/modules/util/network_handler.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/network_handler.c?rev=372222&r1=372221&r2=372222&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/util/network_handler.c (original)
+++ webservices/axis2/trunk/c/modules/util/network_handler.c Wed Jan 25 06:24:52 2006
@@ -23,6 +23,8 @@
#include <netinet/in.h>
#include <netdb.h>
#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <linux/if.h>
int AXIS2_CALL
axis2_network_handler_open_socket(axis2_env_t **env, char *server, int port)
@@ -148,7 +150,7 @@
return AXIS2_FAILURE;
}
-AXIS2_DECLARE(int)
+int AXIS2_CALL
axis2_network_handler_svr_socket_accept(axis2_env_t **env, int svr_socket)
{
int cli_socket = -1;
@@ -160,10 +162,38 @@
cli_len = sizeof(cli_addr);
cli_socket = accept(svr_socket, (struct sockaddr *)&cli_addr, &cli_len);
if (cli_socket < 0)
- perror("Accept Failed ");
- else
- printf("cli_socket = %d\n", cli_socket);
- return cli_socket;
+ AXIS2_LOG_WRITE((*env)->log, "[Axis2][network_handler] Socket accept \
+ failed", AXIS2_LOG_ERROR);
+ return cli_socket;
}
-
+char * AXIS2_CALL
+axis2_network_handler_get_mac_addr(axis2_env_t **env)
+{
+ struct ifreq ifr;
+ struct sockaddr *sa;
+ int s = 0;
+ int i = 0;
+ char *buffer = NULL;
+
+ AXIS2_ENV_CHECK(env, NULL);
+
+ if ((s = socket(PF_INET, SOCK_DGRAM, 0)) < 0)
+ return NULL;
+ sprintf(ifr.ifr_name, "eth0");
+ if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0)
+ {
+ close(s);
+ return NULL;
+ }
+ buffer = AXIS2_MALLOC((*env)->allocator, 6*sizeof(char));
+ if(NULL == buffer)
+ {
+ AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ }
+ sa = (struct sockaddr *)&ifr.ifr_addr;
+ for (i = 0; i < 6; i++)
+ buffer[i] = (unsigned char)(sa->sa_data[i] & 0xff);
+ close(s);
+ return buffer;
+}
Modified: webservices/axis2/trunk/c/test/util/test_util.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/test/util/test_util.c?rev=372222&r1=372221&r2=372222&view=diff
==============================================================================
--- webservices/axis2/trunk/c/test/util/test_util.c (original)
+++ webservices/axis2/trunk/c/test/util/test_util.c Wed Jan 25 06:24:52 2006
@@ -22,6 +22,7 @@
#include <axis2_stream_default.h>
#include <axis2_array_list.h>
#include <axis2_platform_auto_sense.h>
+#include <axis2_uuid_gen.h>
typedef struct a
{
@@ -187,6 +188,18 @@
}
+void test_uuid_gen(axis2_env_t *env)
+{
+ char *uuid = NULL;
+ printf("starting uuid_gen test...\n");
+ uuid = axis2_uuid_gen(&env);
+ printf("Generated UUID 1:%s\n", uuid);
+ AXIS2_FREE(env->allocator, uuid);
+ uuid = axis2_uuid_gen(&env);
+ printf("Generated UUID 2:%s\n", uuid);
+ AXIS2_FREE(env->allocator, uuid);
+ printf("finished uuid_gen test...\n");
+}
int main(void)
{
@@ -195,6 +208,7 @@
test_hash_get(env);
test_env_null();
test_array_list(env);
+ test_uuid_gen(env);
return 0;
}