// Peer-To-Peer CAN simulator 050406 by Dytto ESIAL //
//////////////////////////////////////////////////////
// Peer-To-Peer CAN simulator 050406 by Dytto ESIAL //
//////////////////////////////////////////////////////
//#include "types.h" // header alone containing the typedef struct of a node // include can_tests.c must be OFF.
//XBT_LOG_NEW_DEFAULT_CATEGORY(can,"Messages specific to this example"); // include can_tests.c must be OFF.
//#include "types.h" // header alone containing the typedef struct of a node // include can_tests.c must be OFF.
//XBT_LOG_NEW_DEFAULT_CATEGORY(can,"Messages specific to this example"); // include can_tests.c must be OFF.
// struct of a "get_successor" message, when a node look after the area in which he want to be.
GRAS_DEFINE_TYPE(s_get_suc,
// struct of a "get_successor" message, when a node look after the area in which he want to be.
GRAS_DEFINE_TYPE(s_get_suc,
// registering messages types
static void register_messages(){
gras_msgtype_declare("can_get_suc",gras_datadesc_by_symbol(s_get_suc));
// registering messages types
static void register_messages(){
gras_msgtype_declare("can_get_suc",gras_datadesc_by_symbol(s_get_suc));
// a forwarding function for a "get_suc" message.
static void forward_get_suc(get_suc_t msg, char host[1024], int port){
// a forwarding function for a "get_suc" message.
static void forward_get_suc(get_suc_t msg, char host[1024], int port){
xbt_ex_t e; // the error variable used in TRY.. CATCH tokens.
//INFO2("Transmiting message to %s:%d",host,port);
TRY{
xbt_ex_t e; // the error variable used in TRY.. CATCH tokens.
//INFO2("Transmiting message to %s:%d",host,port);
TRY{
-static void node_get_suc_handler(gras_socket_t expeditor,void *payload_data){
- get_suc_t *incoming=(get_suc_t*)payload_data;
+static int node_get_suc_handler(gras_msg_cb_ctx_t ctx,void *payload_data){
+ gras_socket_t expeditor=gras_msg_cb_ctx_from(ctx);
+ get_suc_t *incoming=(get_suc_t*)payload_data;
xbt_ex_t e; // the error variable used in TRY.. CATCH tokens.
node_data_t *globals=(node_data_t*)gras_userdata_get();
xbt_ex_t e; // the error variable used in TRY.. CATCH tokens.
node_data_t *globals=(node_data_t*)gras_userdata_get();
}
if(validate==1){ // the area for the new node has been defined, then send theses informations to the new node.
INFO2("Sending environment informations to node %s:%d",incoming->host,incoming->port);
}
if(validate==1){ // the area for the new node has been defined, then send theses informations to the new node.
INFO2("Sending environment informations to node %s:%d",incoming->host,incoming->port);
INFO4("My area is [%d;%d;%d;%d]",globals->x1,globals->x2,globals->y1,globals->y2);
//INFO0("Closing node, all has been done!");
}
INFO4("My area is [%d;%d;%d;%d]",globals->x1,globals->x2,globals->y1,globals->y2);
//INFO0("Closing node, all has been done!");
}
globals->y2=1000;
}else{ // asking for an area.
INFO1("Contacting %s so as to request for an area",argv[4]);
globals->y2=1000;
}else{ // asking for an area.
INFO1("Contacting %s so as to request for an area",argv[4]);