예제 #1
0
파일: extractl3.c 프로젝트: j2s2/netmagis
void output_link (FILE *fp, struct node *n, char *cloudname)
{
    int nl1, i ;
    iptext_t ipaddr ;
    l3tol1_t tab [MAXIFPERIP] ;

    if (! MK_ISSELECTED (n))
	return ;

    nl1 = get_l3tol1 (fp, n, tab, NTAB(tab)) ;
    for (i = 0 ; i < nl1 ; i++)
    {
	l3tol1_t *p ;

	p = &tab [i] ;
	fprintf (fp, "link %s", n->eq->name) ;
	if (tab [i].r != NULL)
	    fprintf (fp, ":%s", p->r->u.router.name) ;

	fprintf (fp, " %s.%d", p->l1->u.l1.ifname, p->l2->u.l2.vlan) ;

	/* XXX : should we really print preflen ? */
	ip_ntop (&n->u.l3.addr, ipaddr, 1) ;
	fprintf (fp, " %s", ipaddr) ;

	if (p->l1->u.l1.link != NULL)
	    fprintf (fp, " %s", p->l1->u.l1.link) ;
	else
	    fprintf (fp, " (nolink)") ;

	fprintf (fp, " %s", cloudname) ;

	fprintf (fp, "\n") ;
    }
}
예제 #2
0
파일: casan.cpp 프로젝트: Alpam/casan
void Casan::mk_ctl_msg (Msg &out)
{
    int i ;

    for (i = 0 ; i < NTAB (casan_namespace) ; i++)
    {
	option path (option::MO_Uri_Path, (void *) casan_namespace [i].path,
					casan_namespace [i].len) ;
	out.push_option (path) ;
    }
}
예제 #3
0
PROCESS_THREAD(test, ev, data)
{

	static struct etimer et;

	PROCESS_BEGIN();
		myaddr = init_l2addr_154_char("45:67");

		l2 = startL2_154( myaddr, CHANNEL, PANID); 
		ca = initCasan(l2, MTU, slaveid);

		r1 = initResource (R1_name, R1_title, R1_rt) ;
		setHandlerResource(r1, COAP_CODE_GET, process_temp );
		register_resource(ca, r1);

		r2 = initResource (R2_name, R2_title, R2_rt) ;
		setHandlerResource(r2, COAP_CODE_GET, process_temp );
		register_resource(ca, r2);

		while(1) {    

			if (n % NTAB (resname) == 0)
	    		print_resources (ca) ;
	    	test_resource (ca, l2, resname [n++ % NTAB (resname)]) ;
			
	    	printf("\n");
	    	printf("*************************************************************************");
	    	printf("\n");

	        etimer_set(&et,5*CLOCK_SECOND); 
        	PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
	    }



   	PROCESS_END();
}
예제 #4
0
파일: casan.cpp 프로젝트: Alpam/casan
bool Casan::is_ctl_msg (Msg &m)
{
    int i = 0 ;

    m.reset_next_option () ;
    for (option *o = m.next_option () ; o != NULL ; o = m.next_option ())
    {
	if (o->optcode () == option::MO_Uri_Path)
	{
	    if (i >= NTAB (casan_namespace))
		return false ;
	    if (casan_namespace [i].len != o->optlen ())
		return false ;
	    if (memcmp (casan_namespace [i].path, o->optval ((int *) 0), o->optlen ()))
		return false ;
	    i++ ;
	}
    }
    m.reset_next_option () ;
    if (i != NTAB (casan_namespace))
	return false ;

    return true ;
}
예제 #5
0
파일: extractl3.c 프로젝트: j2s2/netmagis
void output_direct (FILE *fp, struct node *n [2])
{
    int nl1 ;
    iptext_t ipaddr ;
    l3tol1_t tab [MAXIFPERIP] ;
    l3tol1_t *p ;
    int peer ;

    if (! (MK_ISSELECTED (n [0]) && MK_ISSELECTED (n [1])))
	return ;

    fprintf (fp, "direct ") ;

    for (peer = 0 ; peer < 2 ; peer++)
    {
	nl1 = get_l3tol1 (fp, n [peer], tab, NTAB(tab)) ;
	if (nl1 != 1)
	{
	    fprintf (stderr, "Direct link detected with 2 L1 on the same L3 node\n") ;
	    exit (1) ;
	}

	p = &tab [0] ;
	fprintf (fp, " %s", n [peer]->eq->name) ;
	if (tab [0].r != NULL)
	    fprintf (fp, ":%s", p->r->u.router.name) ;

	fprintf (fp, " %s.%d", p->l1->u.l1.ifname, p->l2->u.l2.vlan) ;

	/* XXX : should we really print preflen ? */
	ip_ntop (&n [peer]->u.l3.addr, ipaddr, 1) ;
	fprintf (fp, " %s", ipaddr) ;

	if (peer == 0)
	{
	    if (p->l1->u.l1.link != NULL)
		fprintf (fp, " %s", p->l1->u.l1.link) ;
	    else
		fprintf (fp, " (nolink)") ;
	}
    }

    fprintf (fp, "\n") ;
}
예제 #6
0
파일: extractl3.c 프로젝트: j2s2/netmagis
void output_cloud (FILE *fp, struct node *n, char *cloudname, size_t size)
{
    static int cloudno = 0 ;
    struct node *l1node, *l2node ;
    vlanset_t vs ;
    ip_t tabnet [MAXNET] ;
    int ntab ;
    iptext_t addr ;
    int i ;

    cloudno++ ;
    snprintf (cloudname, size, CLOUDFORMAT, cloudno) ;

    fprintf (fp, "cloud %s", cloudname) ;

    /*
     * Reference to the broadcast domain
     * - get the first marked L1 interface
     * - name of equipement of this L1
     * - get the first marked L2 from this L1
     */

    find_interface (&l1node, &l2node) ;
    if (l1node == NULL || l2node == NULL)
    {
	/*
	 * Degenerated case such as an L3 node not connected to the
	 * rest of the world...
	 */
	if (l2node == NULL)
	    l2node = get_neighbour (n, NT_L2) ;

	if (l2node != NULL)
	    fprintf (fp, " {%s %s %d}", l2node->eq->name, "-", l2node->u.l2.vlan) ;
	else
	    fprintf (fp, " {%s %s %d}", "-", "-", 0) ;
    }
    else
	fprintf (fp, " {%s %s %d}",
			    l1node->eq->name, l1node->u.l1.ifname, l2node->u.l2.vlan) ;

    /*
     * Get all vlan used
     */

    traversed_vlans (vs) ;
    fprintf (fp, " {") ;
    print_vlanlist (fp, vs, 1) ;
    fprintf (fp, "}") ;

    /*
     * Get all network CIDR from L3 nodes
     */

    ntab = find_networks (tabnet, NTAB (tabnet)) ;
    fprintf (fp, " {") ;
    for (i = 0 ; i < ntab ; i++)
    {
	if (i != 0)
	    fprintf (fp, " ") ;
	ip_ntop (&tabnet [i], addr, 1) ;
	fprintf (fp, "%s", addr) ;
    }
    fprintf (fp, "}") ;

    fprintf (fp, "\n") ;
}