mturk       2005/05/19 11:30:13

  Modified:    jni/native/src network.c
  Added:       jni/java/org/apache/tomcat/jni Multicast.java
  Log:
  Added Multicast.java and apr_mcast_* wrappers.
  
  Revision  Changes    Path
  1.1                  
jakarta-tomcat-connectors/jni/java/org/apache/tomcat/jni/Multicast.java
  
  Index: Multicast.java
  ===================================================================
  /*
   *  Copyright 1999-2004 The Apache Software Foundation
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  
  package org.apache.tomcat.jni;
  
  /** Multicast
   *
   * @author Mladen Turk
   * @version $Revision: 1.1 $, $Date: 2005/05/19 18:30:13 $
   */
  
  public class Multicast {
  
      /**
       * Join a Multicast Group
       * @param sock The socket to join a multicast group
       * @param join The address of the multicast group to join
       * @param iface Address of the interface to use.  If NULL is passed, the
       *              default multicast interface will be used. (OS Dependent)
       * @param source Source Address to accept transmissions from (non-NULL
       *               implies Source-Specific Multicast)
       */
      public static native int join(long sock, long join,
                                    long iface, long source);
  
      /**
       * Leave a Multicast Group.  All arguments must be the same as
       * apr_mcast_join.
       * @param sock The socket to leave a multicast group
       * @param addr The address of the multicast group to leave
       * @param iface Address of the interface to use.  If NULL is passed, the
       *              default multicast interface will be used. (OS Dependent)
       * @param source Source Address to accept transmissions from (non-NULL
       *               implies Source-Specific Multicast)
       */
      public static native int leave(long sock, long addr,
                                     long iface, long source);
  
      /**
       * Set the Multicast Time to Live (ttl) for a multicast transmission.
       * @param sock The socket to set the multicast ttl
       * @param ttl Time to live to Assign. 0-255, default=1
       * @remark If the TTL is 0, packets will only be seen by sockets on
       * the local machine, and only when multicast loopback is enabled.
       */
      public static native int hops(long sock, int ttl);
  
      /**
       * Toggle IP Multicast Loopback
       * @param sock The socket to set multicast loopback
       * @param opt false=disable, true=enable
       */
      public static native int loopback(long sock, boolean opt);
  
  
      /**
       * Set the Interface to be used for outgoing Multicast Transmissions.
       * @param sock The socket to set the multicast interface on
       * @param iface Address of the interface to use for Multicast
       */
      public static native int ointerface(long sock, long iface);
  
  }
  
  
  
  1.19      +49 -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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- network.c 19 May 2005 18:00:00 -0000      1.18
  +++ network.c 19 May 2005 18:30:13 -0000      1.19
  @@ -594,3 +594,52 @@
       return (jint)APR_ENOTIMPL;
   #endif
   }
  +
  +TCN_IMPLEMENT_CALL(jint, Mulicast, join)(TCN_STDARGS,
  +                                         jlong sock, jlong join,
  +                                         jlong iface, jlong source)
  +{
  +    apr_socket_t *s = J2P(sock, apr_socket_t *);
  +    apr_sockaddr_t *ja = J2P(join, apr_sockaddr_t *);
  +    apr_sockaddr_t *ia = J2P(iface, apr_sockaddr_t *);
  +    apr_sockaddr_t *sa = J2P(source, apr_sockaddr_t *);
  +    UNREFERENCED_STDARGS;
  +    return (jint)apr_mcast_join(s, ja, ia, sa);
  +};
  +
  +TCN_IMPLEMENT_CALL(jint, Mulicast, leave)(TCN_STDARGS,
  +                                          jlong sock, jlong addr,
  +                                          jlong iface, jlong source)
  +{
  +    apr_socket_t *s = J2P(sock, apr_socket_t *);
  +    apr_sockaddr_t *aa = J2P(addr, apr_sockaddr_t *);
  +    apr_sockaddr_t *ia = J2P(iface, apr_sockaddr_t *);
  +    apr_sockaddr_t *sa = J2P(source, apr_sockaddr_t *);
  +    UNREFERENCED_STDARGS;
  +    return (jint)apr_mcast_leave(s, aa, ia, sa);
  +};
  +
  +TCN_IMPLEMENT_CALL(jint, Mulicast, hops)(TCN_STDARGS,
  +                                         jlong sock, jint ttl)
  +{
  +    apr_socket_t *s = J2P(sock, apr_socket_t *);
  +    UNREFERENCED_STDARGS;
  +    return (jint)apr_mcast_hops(s, (apr_byte_t)ttl);
  +};
  +
  +TCN_IMPLEMENT_CALL(jint, Mulicast, loopback)(TCN_STDARGS,
  +                                             jlong sock, jboolean opt)
  +{
  +    apr_socket_t *s = J2P(sock, apr_socket_t *);
  +    UNREFERENCED_STDARGS;
  +    return (jint)apr_mcast_loopback(s, opt == JNI_TRUE ? 1 : 0);
  +};
  +
  +TCN_IMPLEMENT_CALL(jint, Mulicast, ointerface)(TCN_STDARGS,
  +                                               jlong sock, jlong iface)
  +{
  +    apr_socket_t *s = J2P(sock, apr_socket_t *);
  +    apr_sockaddr_t *ia = J2P(iface, apr_sockaddr_t *);
  +    UNREFERENCED_STDARGS;
  +    return (jint)apr_mcast_interface(s, ia);
  +};
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to