static void jni_create_router(struct mm *mm)
{
	struct jni_env jni_env;
	jobject jrouter;
	int err;

	info("mm_platform_android: jni_create_router: router=%p\n", java.router);

	if (java.router)
		return;
	
	err = jni_attach(&jni_env);
	if (err) { 
		error("mediamgr_platform_android: jni_create_router: "
		      "attach failed\n");
		return;
	}

	jrouter = cbgp_jni_new(jni_env.env, java.arClass, java.arConstructor,
			       "(Landroid/content/Context;)V",
			       java.ctx, (jlong)mm);
	java.router = (*jni_env.env)->NewGlobalRef(jni_env.env, jrouter);
	java.mediamgr = mm;

	jni_detach(&jni_env);

	info("mm_platform_android: jni_create_router: jrouter=%p "
	     "java.router=%p mm=%p\n", jrouter, java.router, java.mediamgr);	
}
Ejemplo n.º 2
0
/**
 * This function creates a new instance of the Node object from a CBGP
 * node.
 */
jobject cbgp_jni_new_net_Node(JNIEnv * jEnv, jobject joCBGP,
			      net_node_t * node)
{
  jobject joNode;
  jobject joAddress;

  /* Java proxy object already existing ? */
  joNode= jni_proxy_get(jEnv, node);
  if (joNode != NULL)
    return joNode;

  /* Convert node attributes to Java objects */
  joAddress= cbgp_jni_new_IPAddress(jEnv, node->rid);

  /* Check that the conversion was successful */
  if (joAddress == NULL)
    return NULL;

  /* Create new Node object */
  if ((joNode= cbgp_jni_new(jEnv, CLASS_Node, CONSTR_Node,
			    joCBGP,
			    joAddress)) == NULL)
    return NULL;

  // Add reference into proxy repository
  jni_proxy_add(jEnv, joNode, node);

  return joNode;
}
Ejemplo n.º 3
0
/**
 * This function creates a new instance of the Link object from a CBGP
 * link.
 */
jobject cbgp_jni_new_net_Interface(JNIEnv * jEnv, jobject joCBGP,
			      net_iface_t * iface)
{
  jobject joLink;
  jobject joPrefix;

  /* Java proxy object already existing ? */
  joLink= jni_proxy_get(jEnv, iface);
  if (joLink != NULL)
    return joLink;

  /* Convert link attributes to Java objects */
  joPrefix= cbgp_jni_new_IPPrefix(jEnv, net_iface_dst_prefix(iface));
  if (joPrefix == NULL)
    return NULL;

  /* Create new Link object */
  if ((joLink= cbgp_jni_new(jEnv, CLASS_Link, CONSTR_Link,
			    joCBGP, joPrefix,
			    (jlong) net_iface_get_delay(iface))) == NULL)
    return NULL;

  // Add reference into proxy repository
  jni_proxy_add(jEnv, joLink, iface);

  return joLink;
}
Ejemplo n.º 4
0
/**
 * This function creates a new instance of the bgp.Peer object from a
 * CBGP peer.
 */
jobject cbgp_jni_new_bgp_Peer(JNIEnv * jEnv, jobject joCBGP,
			      bgp_peer_t * peer)
{
  jobject joIPAddress;
  jobject joPeer;

  /* Java proxy object already existing ? */
  joPeer= jni_proxy_get(jEnv, peer);
  if (joPeer != NULL)
    return joPeer;

  /* Convert peer attributes to Java objects */
  if ((joIPAddress= cbgp_jni_new_IPAddress(jEnv, peer->addr)) == NULL)
    return NULL;

  /* Create new BGPPeer object */
  if ((joPeer= cbgp_jni_new(jEnv, CLASS_BGPPeer, CONSTR_BGPPeer,
			    joCBGP,
		            joIPAddress,
		            (jint) peer->asn)) == NULL)
    return NULL;

  // Add reference into proxy repository
  jni_proxy_add(jEnv, joPeer, peer);

  return joPeer;
}
Ejemplo n.º 5
0
/**
 * This function creates a new instance of the bgp.FilterRule object
 * from a CBGP filter rule.
 */
jobject cbgp_jni_new_bgp_FilterRule(JNIEnv * jEnv, jobject joCBGP,
				    bgp_ft_rule_t * rule)
{
  jobject joRule;

  /* Java proxy object already existing ? */
  joRule= jni_proxy_get(jEnv, rule);
  if (joRule != NULL)
    return joRule;

  /* Create new Filter object */
  if ((joRule= cbgp_jni_new(jEnv, CLASS_BGPFilterRule, CONSTR_BGPFilterRule,
			    joCBGP)) == NULL)
    return NULL;

  // Add reference into proxy repository
  jni_proxy_add(jEnv, joRule, rule);

  return joRule;
}