예제 #1
0
/*
 * Class:     be_ac_ucl_ingi_cbgp_net_Node
 * Method:    traceRoute
 * Signature: (Ljava/lang/String;)Lbe/ac/ucl/ingi/cbgp/IPTrace;
 */
JNIEXPORT jobject JNICALL Java_be_ac_ucl_ingi_cbgp_net_Node_traceRoute
  (JNIEnv * jEnv, jobject joNode, jstring jsDestination)
{
  net_node_t * node;
  jobject joIPTrace;
  ip_dest_t dest;
  ip_trace_t * trace;
  net_error_t error;

  jni_lock(jEnv);

  /* Get the node */
  node= (net_node_t*) jni_proxy_lookup(jEnv, joNode);
  if (node == NULL)
    return_jni_unlock(jEnv, NULL);

  /* Convert the destination */
  if (ip_jstring_to_address(jEnv, jsDestination, &dest.addr) != 0)
    return_jni_unlock(jEnv, NULL);
  dest.type= NET_DEST_ADDRESS;

  /* Trace the IP-level route */
  error= icmp_trace_route(NULL, node, NET_ADDR_ANY,
			  dest.addr, 0, &trace);

  /* Convert to an IPTrace object */
  joIPTrace= cbgp_jni_new_IPTrace(jEnv, trace);

  ip_trace_destroy(&trace);

  return_jni_unlock(jEnv, joIPTrace);
}
예제 #2
0
/*
 * Class:     be_ac_ucl_ingi_cbgp_bgp_Peer
 * Method:    recv
 * Signature: (Ljava/lang/String;)V
 */
JNIEXPORT void JNICALL Java_be_ac_ucl_ingi_cbgp_bgp_Peer_recv
  (JNIEnv * jEnv, jobject joPeer, jstring jsMesg)
{
  bgp_peer_t * peer;
  const char * cMesg;
  bgp_msg_t * msg;
  int result;

  jni_lock(jEnv);

  peer= (bgp_peer_t *) jni_proxy_lookup(jEnv, joPeer);
  if (peer == NULL)
    return_jni_unlock2(jEnv);

  /* Check that the peer is virtual */
  if (!bgp_peer_flag_get(peer, PEER_FLAG_VIRTUAL)) {
    throw_CBGPException(jEnv, "only virtual peers can do that");
    return_jni_unlock2(jEnv);
  }

  /* Build a message from the MRT-record */
  cMesg= (*jEnv)->GetStringUTFChars(jEnv, jsMesg, NULL);
  result= mrtd_msg_from_line(peer->router, peer, cMesg,
			     &msg);
  (*jEnv)->ReleaseStringUTFChars(jEnv, jsMesg, cMesg);

  if (result >= 0) {
    if (bgp_peer_handle_message(peer, msg) != 0)
      throw_CBGPException(jEnv, "could not handle message");
  } else
    throw_CBGPException(jEnv, "could not understand MRT message (%s)",
			mrtd_strerror(result));

  jni_unlock(jEnv);
}
예제 #3
0
/*
 * Class:     be_ac_ucl_ingi_cbgp_net_Node
 * Method:    getAddresses
 * Signature: ()Ljava/util/Vector;
 */
JNIEXPORT jobject JNICALL Java_be_ac_ucl_ingi_cbgp_net_Node_getAddresses
  (JNIEnv * jEnv, jobject joNode)
{
  net_node_t * pNode;
  jobject joVector= NULL;
  jni_ctx_t sCtx;

  jni_lock(jEnv);

  /* Get the node */
  pNode= (net_node_t*) jni_proxy_lookup(jEnv, joNode);
  if (pNode == NULL)
    return_jni_unlock(jEnv, NULL); 

  if ((joVector= cbgp_jni_new_Vector(jEnv)) == NULL)
    return_jni_unlock(jEnv, NULL);

  sCtx.jEnv= jEnv;
  sCtx.joVector= joVector;

  if (node_addresses_for_each(pNode, _getAddresses, &sCtx) != 0)
    return_jni_unlock(jEnv, NULL);

  return_jni_unlock(jEnv, joVector);
}
예제 #4
0
/*
 * Class:     be_ac_ucl_ingi_cbgp_net_Node
 * Method:    hasProtocol
 * Signature: (Ljava/lang/String;)Z
 */
JNIEXPORT jboolean JNICALL Java_be_ac_ucl_ingi_cbgp_net_Node_hasProtocol
  (JNIEnv * jEnv, jobject joNode, jstring jsProtocol)
{
  net_node_t * pNode;
  const char * pcProtocol;
  net_protocol_id_t tProtoID;
  net_error_t error;

  jni_lock(jEnv);

  /* Get the node */
  pNode= (net_node_t*) jni_proxy_lookup(jEnv, joNode);
  if (pNode == NULL)
    return_jni_unlock(jEnv, JNI_FALSE);

  /* Find protocol index */
  pcProtocol= (*jEnv)->GetStringUTFChars(jEnv, jsProtocol, NULL);
  error= net_str2protocol(pcProtocol, &tProtoID);
  (*jEnv)->ReleaseStringUTFChars(jEnv, jsProtocol, pcProtocol);

  /* Protocol name unknown */
  if (error != ESUCCESS)
    return_jni_unlock(jEnv, JNI_FALSE);

  /* Check if protocol is supported */
  if (node_get_protocol(pNode, tProtoID) != NULL)
    return_jni_unlock(jEnv, JNI_TRUE);

  return_jni_unlock(jEnv, JNI_FALSE);
}
예제 #5
0
/*
 * Class:     be_ac_ucl_ingi_cbgp_net_Node
 * Method:    getInterfaces
 * Signature: ()Ljava/util/Vector;
 */
JNIEXPORT jobject JNICALL Java_be_ac_ucl_ingi_cbgp_net_Node_getInterfaces
  (JNIEnv * jEnv, jobject joNode)
{
  net_node_t * node;
  jobject joVector;
  jni_ctx_t sCtx;

  jni_lock(jEnv);

  /* Get the node */
  node= (net_node_t*) jni_proxy_lookup(jEnv, joNode);
  if (node == NULL)
    return_jni_unlock(jEnv, NULL); 

  /* Create new Vector */
  if ((joVector= cbgp_jni_new_Vector(jEnv)) == NULL)
    return_jni_unlock(jEnv, NULL);

  sCtx.joVector= joVector;
  sCtx.jEnv= jEnv;
  sCtx.joCBGP= NULL/*jni_proxy_get_CBGP(jEnv, joNode)*/;
  if (node_links_for_each(node, _cbgp_jni_get_iface, &sCtx) != 0)
    return_jni_unlock(jEnv, NULL);
  
  return_jni_unlock(jEnv, joVector);
}
예제 #6
0
/*
 * Class:     be_ac_ucl_ingi_cbgp_net_Node
 * Method:    getProtocols
 * Signature: ()Ljava/util/Vector;
 */
JNIEXPORT jobject JNICALL Java_be_ac_ucl_ingi_cbgp_net_Node_getProtocols
  (JNIEnv * jEnv, jobject joNode)
{
  net_node_t * pNode;
  jobject joVector= NULL;
  net_protocol_id_t tProtoID;
  jstring jsProtocol;

  jni_lock(jEnv);

  /* Get the node */
  pNode= (net_node_t*) jni_proxy_lookup(jEnv, joNode);
  if (pNode == NULL)
    return_jni_unlock(jEnv, NULL);

  /* Create Vector object */
  joVector= cbgp_jni_new_Vector(jEnv);
  if (joVector == NULL)
    return_jni_unlock(jEnv, NULL);

  /* Populate with identifier of supported protocols */
  for (tProtoID= 0; tProtoID < NET_PROTOCOL_MAX; tProtoID++) {
    if (node_get_protocol(pNode, tProtoID)) {
      jsProtocol= cbgp_jni_new_String(jEnv, net_protocol2str(tProtoID));
      if (jsProtocol == NULL)
	return_jni_unlock(jEnv, NULL);
      cbgp_jni_Vector_add(jEnv, joVector, jsProtocol);
    }
  }

  return_jni_unlock(jEnv, joVector);
}
예제 #7
0
/*
 * Class:     be_ac_ucl_ingi_cbgp_net_Node
 * Method:    getBGP
 * Signature: ()Lbe/ac/ucl/ingi/cbgp/bgp/Router;
 */
JNIEXPORT jobject JNICALL Java_be_ac_ucl_ingi_cbgp_net_Node_getBGP
  (JNIEnv * jEnv, jobject joNode)
{
  net_node_t * node;
  bgp_router_t * router;
  net_protocol_t * protocol;
  jobject joRouter;

  jni_lock(jEnv);

  /* Get the node */
  node= (net_node_t*) jni_proxy_lookup(jEnv, joNode);
  if (node == NULL)
    return_jni_unlock(jEnv, NULL);

  /* Get the BGP handler */
  if ((protocol= node_get_protocol(node, NET_PROTOCOL_BGP)) == NULL)
    return_jni_unlock(jEnv, NULL);
  router= (bgp_router_t *) protocol->handler;

  /* Create bgp.Router instance */
  if ((joRouter= cbgp_jni_new_bgp_Router(jEnv,
					 NULL/*jni_proxy_get_CBGP(jEnv, joNode)*/,
					 router)) == NULL)
    return_jni_unlock(jEnv, NULL);
  
  return_jni_unlock(jEnv, joRouter);
}
예제 #8
0
/*
 * Class:     be_ac_ucl_ingi_cbgp_net_Node
 * Method:    addRoute
 * Signature: (Ljava/lang/String;Ljava/lang/String;I)I
 */
JNIEXPORT void JNICALL Java_be_ac_ucl_ingi_cbgp_net_Node_addRoute
  (JNIEnv * jEnv, jobject joNode, jstring jsPrefix,
   jstring jsNexthop, jint jiWeight)
{
  net_node_t * node;
  ip_pfx_t prefix;
  net_addr_t next_hop;
  net_iface_id_t tIfaceID;
  int error;

  jni_lock(jEnv);

  /* Get the node */
  node= (net_node_t*) jni_proxy_lookup(jEnv, joNode);
  if (node == NULL)
    return_jni_unlock2(jEnv);

  if (ip_jstring_to_prefix(jEnv, jsPrefix, &prefix) != 0)
    return_jni_unlock2(jEnv);

  if (ip_jstring_to_address(jEnv, jsNexthop, &next_hop) != 0)
    return_jni_unlock2(jEnv);

  tIfaceID.network= next_hop;
  tIfaceID.mask= 32;
  error= node_rt_add_route(node, prefix, tIfaceID,
			   next_hop, jiWeight, NET_ROUTE_STATIC);
  if (error != ESUCCESS) {
    throw_CBGPException(jEnv, "could not add route (%s)",
			network_strerror(error));
    return_jni_unlock2(jEnv);
  }

  jni_unlock(jEnv);
}
예제 #9
0
/*
 * Class:     be_ac_ucl_ingi_cbgp_net_Node
 * Method:    getDomain
 * Signature: ()Lbe/ac/ucl/ingi/cbgp/net/IGPDomain;
 */
JNIEXPORT jobject JNICALL Java_be_ac_ucl_ingi_cbgp_net_Node_getDomain
  (JNIEnv * jEnv, jobject joNode)
{
  net_node_t * node;
  igp_domain_t * domain= NULL;
  jobject joDomain= NULL;

  jni_lock(jEnv);

  /* Get the node */
  node= (net_node_t*) jni_proxy_lookup(jEnv, joNode);
  if (node == NULL)
    return_jni_unlock(jEnv, NULL);

  /* Get the domain */
  if ((node->domains != NULL) &&
      (uint16_array_size(node->domains) > 0)) {
    domain= network_find_igp_domain(node->network,
				    node->domains->data[0]);
    joDomain= cbgp_jni_new_net_IGPDomain(jEnv, NULL, domain);
  }

  jni_unlock(jEnv);
  return joDomain;
}
예제 #10
0
/*
 * Class:     be_ac_ucl_ingi_cbgp_net_Node
 * Method:    loadTraffic
 * Signature: (Ljava/lang/String;)V
 */
JNIEXPORT void JNICALL Java_be_ac_ucl_ingi_cbgp_net_Node_loadTraffic
  (JNIEnv * jEnv, jobject joNode, jstring jsFileName)
{
  net_node_t * node;
  const char * filename;
  uint8_t options= 0;
  int result;

  jni_lock(jEnv);

  // Get the node
  node= (net_node_t*) jni_proxy_lookup(jEnv, joNode);
  if (node == NULL)
    return_jni_unlock2(jEnv);

  // Load Netflow from file
  filename= (char *) (*jEnv)->GetStringUTFChars(jEnv, jsFileName, NULL);
  result= node_load_netflow(node, filename, options, NULL);
  (*jEnv)->ReleaseStringUTFChars(jEnv, jsFileName, filename);
  if (result != ESUCCESS) {
    throw_CBGPException(jEnv, "could not load Netflow");
    return_jni_unlock2(jEnv);
  }

  jni_unlock(jEnv);
}
예제 #11
0
void GC_locker::jni_lock_slow() {
  MutexLocker mu(JNICritical_lock);
  // Block entering threads if we know at least one thread is in a
  // JNI critical region and we need a GC.
  // We check that at least one thread is in a critical region before
  // blocking because blocked threads are woken up by a thread exiting
  // a JNI critical region.
  while ((is_jni_active() && needs_gc()) || _doing_gc) {
    JNICritical_lock->wait();
  }
  jni_lock();
}
예제 #12
0
/*
 * Class:     be_ac_ucl_ingi_cbgp_bgp_Peer
 * Method:    getSessionState
 * Signature: ()B
 */
JNIEXPORT jbyte JNICALL Java_be_ac_ucl_ingi_cbgp_bgp_Peer_getSessionState
  (JNIEnv * jEnv, jobject joObject)
{
  bgp_peer_t * peer;
  
  jni_lock(jEnv);

  peer= (bgp_peer_t *) jni_proxy_lookup(jEnv, joObject);
  if (peer == NULL)
    return_jni_unlock(jEnv, JNI_FALSE);

  return_jni_unlock(jEnv, peer->session_state);
}
예제 #13
0
JNIEXPORT jfloat JNICALL Java_be_ac_ucl_ingi_cbgp_net_Node_getLongitude
(JNIEnv * jEnv, jobject joNode)
{
  net_node_t * node;

  jni_lock(jEnv);

  /* Get the node */
  node= (net_node_t*) jni_proxy_lookup(jEnv, joNode);
  if (node == NULL)
    return_jni_unlock(jEnv, 0);

  return_jni_unlock(jEnv, node->coord.longitude);
}
예제 #14
0
/*
 * Class:     be_ac_ucl_ingi_cbgp_net_Node
 * Method:    addPTPLink
 * Signature: (Lbe/ac/ucl/ingi/cbgp/net/Node;Ljava/lang/String;Ljava/lang/String;Z)Lbe/ac/ucl/ingi/cbgp/net/Link;
 */
JNIEXPORT jobject JNICALL Java_be_ac_ucl_ingi_cbgp_net_Node_addPTPLink
  (JNIEnv * jEnv, jobject joNode, jobject joDst, jstring jsSrcIface,
   jstring jsDstIface, jboolean jbBidir)
{
  net_node_t * pNode;
  net_node_t * pNodeDst;
  int iResult;
  net_iface_t * pIface;
  net_iface_id_t tSrcIfaceID;
  net_iface_id_t tDstIfaceID;
  jobject joIface;

  jni_lock(jEnv);

  /* Get the node */
  pNode= (net_node_t*) jni_proxy_lookup(jEnv, joNode);
  if (pNode == NULL)
    return_jni_unlock(jEnv, NULL); 

  /* Get the destination */
  pNodeDst= (net_node_t*) jni_proxy_lookup(jEnv, joDst);
  if (pNodeDst == NULL)
    return_jni_unlock(jEnv, NULL); 

  /* Get the source's interface ID */
  if (ip_jstring_to_prefix(jEnv, jsSrcIface, &tSrcIfaceID) != 0)
    return_jni_unlock(jEnv, NULL);

  /* Get the destination's interface ID */
  if (ip_jstring_to_prefix(jEnv, jsDstIface, &tDstIfaceID) != 0)
    return_jni_unlock(jEnv, NULL);

  /* Add link */
  iResult= net_link_create_ptp(pNode, tSrcIfaceID,
			       pNodeDst, tDstIfaceID,
			       (jbBidir==JNI_TRUE) ? BIDIR : UNIDIR,
			       &pIface);
  if (iResult != ESUCCESS) {
    throw_CBGPException(jEnv, "could not create link (%s)",
			network_strerror(iResult));
    return_jni_unlock(jEnv, NULL);
  }

  /* Retrieve new link */
  joIface= cbgp_jni_new_net_Interface(jEnv,
				 NULL/*jni_proxy_get_CBGP(jEnv, joNode)*/,
				 pIface);

  return_jni_unlock(jEnv, joIface);
}
예제 #15
0
/*
 * Class:     be_ac_ucl_ingi_cbgp_bgp_Peer
 * Method:    closeSession
 * Signature: (Z)V
 */
JNIEXPORT void JNICALL Java_be_ac_ucl_ingi_cbgp_bgp_Peer_closeSession
  (JNIEnv * jEnv, jobject joObject)
{
  bgp_peer_t * peer;

  jni_lock(jEnv);
  
  peer= (bgp_peer_t *) jni_proxy_lookup(jEnv, joObject);
  if (peer == NULL)
    return_jni_unlock2(jEnv);

  bgp_peer_close_session(peer);

  jni_unlock(jEnv);
}
예제 #16
0
/*
 * Class:     be_ac_ucl_ingi_cbgp_net_Iface
 * Method:    setState
 * Signature: (Z)V
 */
JNIEXPORT void JNICALL Java_be_ac_ucl_ingi_cbgp_net_Interface_setState
  (JNIEnv * jEnv, jobject joIface, jboolean bState)
{
  net_iface_t * pIface;

  jni_lock(jEnv);

  pIface= (net_iface_t *) jni_proxy_lookup(jEnv, joIface);
  if (pIface == NULL)
    return_jni_unlock2(jEnv);
    
  net_iface_set_enabled(pIface, (bState == JNI_TRUE)?1:0);

  jni_unlock(jEnv);
}
예제 #17
0
/*
 * Class:     be_ac_ucl_ingi_cbgp_bgp_Peer
 * Method:    isInternal
 * Signature: ()Z
 */
JNIEXPORT jboolean JNICALL Java_be_ac_ucl_ingi_cbgp_bgp_Peer_isInternal
  (JNIEnv * jEnv, jobject joPeer)
{
  bgp_peer_t * peer;
  jboolean jResult;

  jni_lock(jEnv);

  peer= (bgp_peer_t *) jni_proxy_lookup(jEnv, joPeer);
  if (peer == NULL)
    return_jni_unlock(jEnv, JNI_FALSE);

  jResult= (peer->asn == peer->router->asn)?JNI_TRUE:JNI_FALSE;

  return_jni_unlock(jEnv, jResult);
}
예제 #18
0
/*
 * Class:     be_ac_ucl_ingi_cbgp_bgp_Peer
 * Method:    getUpdateSource
 * Signature: ()Lbe/ac/ucl/ingi/cbgp/IPAddress;
 */
JNIEXPORT jobject JNICALL Java_be_ac_ucl_ingi_cbgp_bgp_Peer_getUpdateSource
  (JNIEnv * jEnv, jobject joPeer)
{
  bgp_peer_t * peer;
  jobject joAddress;

  jni_lock(jEnv);

  peer= (bgp_peer_t *) jni_proxy_lookup(jEnv, joPeer);
  if (peer == NULL)
    return_jni_unlock(jEnv, JNI_FALSE);

  joAddress= cbgp_jni_new_IPAddress(jEnv, peer->src_addr);

  return_jni_unlock(jEnv, joAddress);
}
예제 #19
0
/*
 * Class:     be_ac_ucl_ingi_cbgp_net_Iface
 * Method:    getState
 * Signature: ()Z
 */
JNIEXPORT jboolean JNICALL Java_be_ac_ucl_ingi_cbgp_net_Interface_getState
  (JNIEnv * jEnv, jobject joIface)
{
  net_iface_t * pIface;
  jboolean jbState;

  jni_lock(jEnv);
  
  pIface= (net_iface_t *) jni_proxy_lookup(jEnv, joIface);
  if (pIface == NULL)
    return_jni_unlock(jEnv, JNI_FALSE);

  jbState= net_iface_is_enabled(pIface)?JNI_TRUE:JNI_FALSE;

  return_jni_unlock(jEnv, jbState);
}
예제 #20
0
/*
 * Class:     bgp.Peer
 * Method:    setReflectorClient
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_be_ac_ucl_ingi_cbgp_bgp_Peer_setReflectorClient
  (JNIEnv * jEnv, jobject joPeer)
{
  bgp_peer_t * peer;

  jni_lock(jEnv);

  peer= (bgp_peer_t *) jni_proxy_lookup(jEnv, joPeer);
  if (peer == NULL)
    return_jni_unlock2(jEnv);

  peer->router->reflector= 1;
  bgp_peer_flag_set(peer, PEER_FLAG_RR_CLIENT, 1);

  jni_unlock(jEnv);
}
예제 #21
0
/*
 * Class:     be_ac_ucl_ingi_cbgp_bgp_Peer
 * Method:    setNextHopSelf
 * Signature: (Z)V
 */
JNIEXPORT void JNICALL Java_be_ac_ucl_ingi_cbgp_bgp_Peer_setNextHopSelf
  (JNIEnv * jEnv, jobject joPeer, jboolean state)
{
  bgp_peer_t * peer;

  jni_lock(jEnv);

  peer= (bgp_peer_t *) jni_proxy_lookup(jEnv, joPeer);
  if (peer == NULL)
    return_jni_unlock2(jEnv);

  bgp_peer_flag_set(peer, PEER_FLAG_NEXT_HOP_SELF,
		    (state==JNI_TRUE)?1:0);

  jni_unlock(jEnv);
}
예제 #22
0
/*
 * Class:     bgp.Peer
 * Method:    setVirtual
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_be_ac_ucl_ingi_cbgp_bgp_Peer_setVirtual
  (JNIEnv * jEnv, jobject joPeer)
{
  bgp_peer_t * peer;

  jni_lock(jEnv);

  peer= (bgp_peer_t *) jni_proxy_lookup(jEnv, joPeer);
  if (peer == NULL)
    return_jni_unlock2(jEnv);

  bgp_peer_flag_set(peer, PEER_FLAG_VIRTUAL, 1);
  bgp_peer_flag_set(peer, PEER_FLAG_SOFT_RESTART, 1);

  jni_unlock(jEnv);
}
예제 #23
0
JNIEXPORT void JNICALL Java_be_ac_ucl_ingi_cbgp_net_Node_setLatitude
(JNIEnv * jEnv, jobject joNode, jfloat jfLatitude)
{
  net_node_t * node;

  jni_lock(jEnv);

  /* Get the node */
  node= (net_node_t*) jni_proxy_lookup(jEnv, joNode);
  if (node == NULL)
    return_jni_unlock2(jEnv);

  node->coord.latitude= jfLatitude;

  jni_unlock(jEnv);
}
예제 #24
0
/**
 * Class:     be_ac_ucl_ingi_cbgp_net_Iface
 * Method:    getWeight
 * Signature: ()J
 */
JNIEXPORT jlong JNICALL Java_be_ac_ucl_ingi_cbgp_net_Interface_getWeight
  (JNIEnv * jEnv, jobject joIface)
{
  net_iface_t * pIface;
  jlong jlResult;

  jni_lock(jEnv);

  pIface= (net_iface_t *) jni_proxy_lookup(jEnv, joIface);
  if (pIface == NULL)
    return_jni_unlock(jEnv, 0);

  jlResult= (jlong) net_iface_get_metric(pIface, 0);

  return_jni_unlock(jEnv, jlResult);
}
예제 #25
0
/**
 * Class:     bgp.Peer
 * Method:    hasSoftRestart
 * Signature: ()Z
 */
JNIEXPORT jboolean JNICALL Java_be_ac_ucl_ingi_cbgp_bgp_Peer_hasSoftRestart
  (JNIEnv * jEnv, jobject joPeer)
{
  bgp_peer_t * peer;
  jboolean jResult;

  jni_lock(jEnv);

  peer= (bgp_peer_t *) jni_proxy_lookup(jEnv, joPeer);
  if (peer == NULL)
    return_jni_unlock(jEnv, JNI_FALSE);

  jResult= (bgp_peer_flag_get(peer, PEER_FLAG_SOFT_RESTART) != 0)?
    JNI_TRUE:JNI_FALSE;

  return_jni_unlock(jEnv, jResult);
}
예제 #26
0
/**
 * Class:     bgp.Peer
 * Method:    isReflectorClient
 * Signature: ()Z
 */
JNIEXPORT jboolean JNICALL Java_be_ac_ucl_ingi_cbgp_bgp_Peer_isReflectorClient
  (JNIEnv * jEnv, jobject joPeer)
{
  bgp_peer_t * peer;
  jboolean jResult;

  jni_lock(jEnv);

  peer= (bgp_peer_t *) jni_proxy_lookup(jEnv, joPeer);
  if (peer == NULL)
    return_jni_unlock(jEnv, JNI_FALSE);

  jResult= (bgp_peer_flag_get(peer, PEER_FLAG_RR_CLIENT) != 0)?
    JNI_TRUE:JNI_FALSE;

  return_jni_unlock(jEnv, jResult);
}									       
예제 #27
0
/*
 * Class:     be_ac_ucl_ingi_cbgp_bgp_Peer
 * Method:    getNextHopSelf
 * Signature: ()Z
 */
JNIEXPORT jboolean JNICALL Java_be_ac_ucl_ingi_cbgp_bgp_Peer_getNextHopSelf
  (JNIEnv * jEnv, jobject joPeer)
{
  bgp_peer_t * peer;
  jboolean jbNextHopSelf;

  jni_lock(jEnv);

  peer= (bgp_peer_t *) jni_proxy_lookup(jEnv, joPeer);
  if (peer == NULL)
    return_jni_unlock(jEnv, JNI_FALSE);

  jbNextHopSelf= bgp_peer_flag_get(peer, PEER_FLAG_NEXT_HOP_SELF)?
    JNI_TRUE:JNI_FALSE;

  return_jni_unlock(jEnv, jbNextHopSelf);
}
예제 #28
0
/*
 * Class:     be_ac_ucl_ingi_cbgp_net_Interface
 * Method:    getType
 * Signature: ()Ljava/lang/String;
 */
JNIEXPORT jstring JNICALL Java_be_ac_ucl_ingi_cbgp_net_Interface_getType
(JNIEnv * jEnv, jobject joIface)
{
  net_iface_t * iface;
  jstring jsType;

  jni_lock(jEnv);

  /* Get interface */
  iface= (net_iface_t *) jni_proxy_lookup(jEnv, joIface);
  if (iface == NULL)
    return_jni_unlock(jEnv, NULL);

  jsType= cbgp_jni_new_String(jEnv, net_iface_type2str(iface->type));

  return_jni_unlock(jEnv, jsType);
}
예제 #29
0
/*
 * Class:     be_ac_ucl_ingi_cbgp_bgp_Peer
 * Method:    isAutoConfigured
 * Signature: ()Z
 */
JNIEXPORT jboolean JNICALL Java_be_ac_ucl_ingi_cbgp_bgp_Peer_isAutoConfigured
  (JNIEnv * jEnv, jobject joPeer)
{
  bgp_peer_t * peer;
  jboolean jResult;

  jni_lock(jEnv);

  peer= (bgp_peer_t *) jni_proxy_lookup(jEnv, joPeer);
  if (peer == NULL)
    return_jni_unlock(jEnv, JNI_FALSE);

  jResult= (bgp_peer_flag_get(peer, PEER_FLAG_AUTOCONF) != 0)?
    JNI_TRUE:JNI_FALSE;

  return_jni_unlock(jEnv, jResult);
}
예제 #30
0
/*
 * Class:     be_ac_ucl_ingi_cbgp_net_Iface
 * Method:    getLoad
 * Signature: ()J
 */
JNIEXPORT jlong JNICALL Java_be_ac_ucl_ingi_cbgp_net_Interface_getLoad
  (JNIEnv * jEnv, jobject joIface)
{
  net_iface_t * pIface;
  jlong jlLoad= 0;

  jni_lock(jEnv);

  /* Get interface */
  pIface= (net_iface_t *) jni_proxy_lookup(jEnv, joIface);
  if (pIface == NULL)
    return_jni_unlock(jEnv, -1);

  jlLoad= net_iface_get_load(pIface);

  return_jni_unlock(jEnv, jlLoad);
}