|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* Copyright © 2013-2014 University of Wisconsin-La Crosse.
|
|
Packit Service |
c5cf8c |
* All rights reserved.
|
|
Packit Service |
c5cf8c |
* Copyright © 2013 Cisco Systems, Inc. All rights reserved.
|
|
Packit Service |
c5cf8c |
* Copyright © 2015-2016 Inria. All rights reserved.
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* $COPYRIGHT$
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* Additional copyrights may follow
|
|
Packit Service |
c5cf8c |
* See COPYING in top-level directory.
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* $HEADER$
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define _GNU_SOURCE /* See feature_test_macros(7) */
|
|
Packit Service |
c5cf8c |
#include <stdlib.h>
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#include <private/autogen/config.h>
|
|
Packit Service |
c5cf8c |
#include <private/netloc.h>
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
static int cur_uid = 0;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
netloc_edge_t * netloc_edge_construct(void)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
netloc_edge_t *edge = NULL;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
edge = (netloc_edge_t*)malloc(sizeof(netloc_edge_t));
|
|
Packit Service |
c5cf8c |
if( NULL == edge ) {
|
|
Packit Service |
c5cf8c |
return NULL;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
edge->id = cur_uid;
|
|
Packit Service |
c5cf8c |
cur_uid++;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
edge->dest = NULL;
|
|
Packit Service |
c5cf8c |
edge->node = NULL;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
utarray_new(edge->physical_links, &ut_ptr_icd);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
edge->total_gbits = 0;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
utarray_new(edge->partitions, &ut_int_icd);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
utarray_new(edge->subnode_edges, &ut_ptr_icd);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
edge->userdata = NULL;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
return edge;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
char * netloc_edge_pretty_print(netloc_edge_t* edge)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
// TODO
|
|
Packit Service |
c5cf8c |
return "TODO";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int netloc_edge_destruct(netloc_edge_t * edge)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
utarray_free(edge->physical_links);
|
|
Packit Service |
c5cf8c |
utarray_free(edge->partitions);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
for (unsigned int e = 0; e < netloc_edge_get_num_subedges(edge); e++) {
|
|
Packit Service |
c5cf8c |
netloc_edge_t *subedge;
|
|
Packit Service |
c5cf8c |
subedge = netloc_edge_get_subedge(edge, e);
|
|
Packit Service |
c5cf8c |
netloc_edge_destruct(subedge);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
utarray_free(edge->subnode_edges);
|
|
Packit Service |
c5cf8c |
free(edge);
|
|
Packit Service |
c5cf8c |
return NETLOC_SUCCESS;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
void netloc_edge_reset_uid(void)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
cur_uid = 0;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int netloc_edge_is_in_partition(netloc_edge_t *edge, int partition)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
for (unsigned int i = 0; i < netloc_get_num_partitions(edge); i++) {
|
|
Packit Service |
c5cf8c |
if (netloc_get_partition(edge, i) == partition)
|
|
Packit Service |
c5cf8c |
return 1;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
return NETLOC_SUCCESS;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|