示例#1
0
//---------------------------------------------------------------------------------------------------------------------
int pmip_pcap_loop_start(void)
{
    dbg("Getting ingress informations\n");
    mag_get_ingress_info(&g_pcap_iif, g_pcap_devname);

    if (pthread_create(&pcap_listener, NULL, pmip_pcap_loop, NULL))
                return -1;
    return 0;
}
//---------------------------------------------------------------------------------------------------------------------
int pmip_mag_init(void)
//---------------------------------------------------------------------------------------------------------------------
{
	pmip_common_init();
	conf.OurAddress = conf.MagAddressEgress;
	conf.HomeNetworkPrefix = get_node_prefix(&conf.MagAddressIngress); //copy Home network prefix.
	dbg("Running as MAG entity\n");
	dbg("Entity Egress Address: %x:%x:%x:%x:%x:%x:%x:%x\n", NIP6ADDR(&conf.OurAddress));
	dbg("Entity Ingress Address: %x:%x:%x:%x:%x:%x:%x:%x\n", NIP6ADDR(&conf.MagAddressIngress));
	dbg("Home Network Prefix Address: %x:%x:%x:%x:%x:%x:%x:%x\n", NIP6ADDR(&conf.HomeNetworkPrefix));
	if (mag_init_fsm() < 0) {
		dbg("Initialization of FSM failed...exit\n");
		exit(-1);
	}
	init_iface_ra();
	init_mag_icmp_sock();
	dbg("Initializing the NA handler\n");
	// to capture NA message
	icmp6_handler_reg(ND_NEIGHBOR_ADVERT, &pmip_mag_recv_na_handler);
	dbg("Initializing the RS handler\n");
	// to capture RS message
	icmp6_handler_reg(ND_ROUTER_SOLICIT, &pmip_mag_rs_handler);
	dbg("Initializing the PBA handler\n");
	//To capture PBA/ message.
	mh_handler_reg(IP6_MH_TYPE_BACK, &pmip_mag_pba_handler);
	//Anh Khuong: handle RO messages
	mh_handler_reg(IP6_MH_TYPE_ROI, &pmip_mag_roi_handler);
	mh_handler_reg(IP6_MH_TYPE_ROS, &pmip_mag_ros_handler);
	mh_handler_reg(IP6_MH_TYPE_ROSA, &pmip_mag_rosa_handler);
	mh_handler_reg(IP6_MH_TYPE_ETM, &pmip_mag_etm_handler);
	mh_handler_reg(IP6_MH_TYPE_HI, &pmip_mag_hi_handler);
	mh_handler_reg(IP6_MH_TYPE_HA, &pmip_mag_ha_handler);
	/**
	* Deletes the default route for MN prefix so routing is per unicast MN address!
	**/
	route_del((int) NULL, RT6_TABLE_MAIN, IP6_RT_PRIO_ADDRCONF, &in6addr_any, 0, &conf.HomeNetworkPrefix, 64, NULL);
	dbg("Initializing the HNP cache\n");
	if (pmip_mn_to_hnp_cache_init() < 0) {
		exit (-1);
	}

    char devname[32];
	int iif;
	dbg("Getting ingress informations\n");
	mag_get_ingress_info(&iif, devname);
	dbg("Starting capturing AP messages for incoming MNs detection\n");
	pmip_pcap_loop(devname, iif);

	return 0;
}
示例#3
0
int start_odtone_listener(void)
{

    dbg("Getting ingress informations\n");
    mag_get_ingress_info(&g_pcap_iif, g_pcap_devname);

    int res=0;
    srand(time(NULL));
    transaction_id  = rand();

    res=start_MIHF_socket();

    if(res <0)
    {
        dbg("Error opening socket to MIHF");
        return res;
    }

    res =pthread_create(&socket_listener, NULL, process_incoming_message, NULL);

    if(res<0)
    {
        dbg ("Error starting thread that listens that waits for MIHF messages\n");
        return res;
    }

    res=send_user_reg_indication();

    if(res<0)
    {
        dbg ("error sending user registration to MIHF\n");
        return res;
    }

    transaction_id  = rand();
    send_capability_discover_request();
    return res;

}