You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by mt...@apache.org on 2005/04/16 17:46:36 UTC
cvs commit: jakarta-tomcat-connectors/jni/native/src info.c network.c
mturk 2005/04/16 08:46:36
Modified: jni/java/org/apache/tomcat/jni Address.java Sockaddr.java
jni/native/src info.c network.c
Log:
Add missing Address.getip -> apr_sockaddr_ip_get call and remove
unneeded fields for Sockaddr.
Revision Changes Path
1.3 +11 -1 jakarta-tomcat-connectors/jni/java/org/apache/tomcat/jni/Address.java
Index: Address.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jni/java/org/apache/tomcat/jni/Address.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Address.java 14 Jan 2005 14:42:37 -0000 1.2
+++ Address.java 16 Apr 2005 15:46:36 -0000 1.3
@@ -24,6 +24,7 @@
public class Address {
+ static public String APR_ANYADDR = "0.0.0.0";
/**
* Fill the Address class from apr_sockaddr_t
* @param info Sockaddr class to fill
@@ -65,6 +66,15 @@
*/
public static native String getnameinfo(long sa, int flags);
+ /**
+ * Return the IP address (in numeric address string format) in
+ * an APR socket address. APR will allocate storage for the IP address
+ * string from the pool of the apr_sockaddr_t.
+ * @param ss The socket address to reference.
+ * @return The IP address.
+ */
+ public static native String getip(long sa);
+
/**
* Given an apr_sockaddr_t and a service name, set the port for the service
* @param sockaddr The apr_sockaddr_t that will have its port set
1.3 +1 -11 jakarta-tomcat-connectors/jni/java/org/apache/tomcat/jni/Sockaddr.java
Index: Sockaddr.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jni/java/org/apache/tomcat/jni/Sockaddr.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Sockaddr.java 14 Jan 2005 14:42:37 -0000 1.2
+++ Sockaddr.java 16 Apr 2005 15:46:36 -0000 1.3
@@ -34,16 +34,6 @@
public int port;
/** The family */
public int family;
- /** How big is the sockaddr we're using? */
- public int salen;
- /** How big is the ip address structure we're using? */
- public int ipaddr_len;
- /** How big should the address buffer be? 16 for v4 or 46 for v6
- * used in inet_ntop... */
- public int addr_str_len;
- /** This points to the IP address structure within the appropriate
- * sockaddr structure. */
- public long ipaddr_ptr;
/** If multiple addresses were found by apr_sockaddr_info_get(), this
* points to a representation of the next address. */
public long next;
1.3 +0 -12 jakarta-tomcat-connectors/jni/native/src/info.c
Index: info.c
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jni/native/src/info.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- info.c 17 Jan 2005 07:21:13 -0000 1.2
+++ info.c 16 Apr 2005 15:46:36 -0000 1.3
@@ -115,10 +115,6 @@
DECLARE_AINFO_FIELD(servname);
DECLARE_AINFO_FIELD(port);
DECLARE_AINFO_FIELD(family);
-DECLARE_AINFO_FIELD(salen);
-DECLARE_AINFO_FIELD(ipaddr_len);
-DECLARE_AINFO_FIELD(addr_str_len);
-DECLARE_AINFO_FIELD(ipaddr_ptr);
DECLARE_AINFO_FIELD(next);
static int finfo_class_initialized = 0;
@@ -173,10 +169,6 @@
GET_AINFO_S(servname);
GET_AINFO_I(port);
GET_AINFO_I(family);
- GET_AINFO_I(salen);
- GET_AINFO_I(ipaddr_len);
- GET_AINFO_I(addr_str_len);
- GET_AINFO_J(ipaddr_ptr);
GET_AINFO_J(next);
ainfo_class_initialized = 1;
@@ -215,10 +207,6 @@
SET_AINFO_S(servname, info->servname);
SET_AINFO_I(port, info->port);
SET_AINFO_I(family, info->family);
- SET_AINFO_I(salen, info->salen);
- SET_AINFO_I(ipaddr_len, info->ipaddr_len);
- SET_AINFO_I(addr_str_len, info->addr_str_len);
- SET_AINFO_J(ipaddr_ptr, P2J(info->ipaddr_ptr));
SET_AINFO_J(next, P2J(info->next));
}
1.10 +12 -0 jakarta-tomcat-connectors/jni/native/src/network.c
Index: network.c
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jni/native/src/network.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- network.c 16 Apr 2005 14:53:36 -0000 1.9
+++ network.c 16 Apr 2005 15:46:36 -0000 1.10
@@ -69,6 +69,18 @@
return NULL;
}
+TCN_IMPLEMENT_CALL(jstring, Address, getip)(TCN_STDARGS, jlong sa)
+{
+ apr_sockaddr_t *s = J2P(sa, apr_sockaddr_t *);
+ char *ipaddr;
+
+ UNREFERENCED(o);
+ if (apr_sockaddr_ip_get(&ipaddr, s) == APR_SUCCESS)
+ return AJP_TO_JSTRING(ipaddr);
+ else
+ return NULL;
+}
+
TCN_IMPLEMENT_CALL(jlong, Address, get)(TCN_STDARGS, jint which,
jlong sock)
{
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org