- return 1;
- }
-
- if ((errcode=gras_socket_client_ext(gras_socket_peer_name(expeditor),request->host.port,
- request->buf_size,1,&rawOut))) {
- ERROR3("Error '%s' encountered while opening a raw socket to %s:%d",
- xbt_error_name(errcode),gras_socket_peer_name(expeditor),request->host.port);
- /* FIXME: tell error to remote */
- return 1;
- }
-
- answer->buf_size=request->buf_size;
- answer->exp_size=request->exp_size;
- answer->msg_size=request->msg_size;
- answer->host.port=gras_socket_my_port(rawIn);
-
- if ((errcode=gras_msg_send(expeditor,gras_msgtype_by_name("BW handshake ACK"),&answer))) {
- ERROR1("Error %s encountered while sending the answer.",
- xbt_error_name(errcode));
- gras_socket_close(rawIn);
- gras_socket_close(rawOut);
- /* FIXME: tell error to remote */
- return 1;
- }
- INFO4("BW handshake answered. buf_size=%d exp_size=%d msg_size=%d port=%d",
- answer->buf_size,answer->exp_size,answer->msg_size,answer->host.port);
-
- if ((errcode=gras_socket_raw_recv(rawIn, 120,request->exp_size,request->msg_size)) ||
- (errcode=gras_socket_raw_send(rawOut,120,1,1))) {
- ERROR1("Error %s encountered while receiving the experiment.",
- xbt_error_name(errcode));
- gras_socket_close(rawIn);
- gras_socket_close(rawOut);
- /* FIXME: tell error to remote ? */
- return 1;
- }
- gras_socket_close(rawIn);
- gras_socket_close(rawOut);
- return 1;
-}
-
-int amok_bw_cb_bw_request(gras_socket_t expeditor,
- void *payload) {return 1;}
-
-int amok_bw_cb_sat_start(gras_socket_t expeditor,
- void *payload) {return 1;}
-int amok_bw_cb_sat_begin(gras_socket_t expeditor,
- void *payload) {return 1;}
-
-#if 0
-/* function to request a BW test between two external hosts */
-xbt_error_t grasbw_request(const char* from_name,unsigned int from_port,
- const char* to_name,unsigned int to_port,
- unsigned int bufSize,unsigned int expSize,unsigned int msgSize,
- /*OUT*/ double *sec, double*bw) {
-
- gras_sock_t *sock;
- gras_msg_t *answer;
- xbt_error_t errcode;
- /* The request */
- BwExp_t *request;
- msgHost_t *target;
-
- if((errcode=gras_sock_client_open(from_name,from_port,&sock))) {
- fprintf(stderr,"grasbw_request(): Error %s encountered while contacting the actuator\n",
- xbt_error_name(errcode));
- return errcode;
- }
- if (!(request=(BwExp_t *)malloc(sizeof(BwExp_t))) ||
- !(target=(msgHost_t*)malloc(sizeof(msgHost_t)))) {
- fprintf(stderr,"grasbw_test(): Malloc error\n");
- gras_sock_close(sock);
- return malloc_error;
- }
-
- request->bufSize=bufSize;
- request->expSize=expSize;
- request->msgSize=msgSize;
- strcpy(target->host,to_name);
- target->port=to_port;
-
- if ((errcode=gras_msg_new_and_send(sock,GRASMSG_BW_REQUEST, 2,
- target,1,
- request,1))) {
- fprintf(stderr,"grasbw_request(): Error %s encountered while sending the request.\n",
- xbt_error_name(errcode));
- gras_sock_close(sock);
- return errcode;
- }
- if ((errcode=gras_msg_wait(240,GRASMSG_BW_RESULT,&answer))) {
- fprintf(stderr,"grasbw_request(): Error %s encountered while waiting for the answer.\n",
- xbt_error_name(errcode));
- gras_sock_close(sock);
- return errcode;
- }
-
- if((errcode=gras_msg_ctn(answer,0,0,msgError_t).errcode)) {
- fprintf(stderr,"grasbw_request(): Peer reported error %s (%s).\n",
- xbt_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
- gras_msg_free(answer);
- gras_sock_close(sock);
- return errcode;
- }
-
- /* fprintf(stderr,"sec=%p",gras_msg_ctn(answer,1,0,msgResult_t)); */
- *sec=gras_msg_ctn(answer,1,0,msgResult_t).value;
- *bw=gras_msg_ctn(answer,1,1,msgResult_t).value;
-
- gras_msg_free(answer);
- gras_sock_close(sock);
- return no_error;
-}
-
-int grasbw_cbBWRequest(gras_msg_t *msg) {
- /* specification of the test to run */
- char* to_name=gras_msg_ctn(msg,0,0,msgHost_t).host;
- unsigned int to_port=gras_msg_ctn(msg,0,0,msgHost_t).port;
-
- unsigned int bufSize=gras_msg_ctn(msg,1,0,BwExp_t).bufSize;
- unsigned int expSize=gras_msg_ctn(msg,1,0,BwExp_t).expSize;
- unsigned int msgSize=gras_msg_ctn(msg,1,0,BwExp_t).msgSize;
- /* our answer */
- msgError_t *error;
- msgResult_t *res;
-
- if (!(error=(msgError_t *)malloc(sizeof(msgError_t))) ||
- !(res=(msgResult_t *)malloc(sizeof(msgResult_t) * 2))) {
- fprintf(stderr,"%s:%d:grasbw_cbRequest: Malloc error\n",__FILE__,__LINE__);
- return malloc_error;
- }
-
- if ((error->errcode=grasbw_test(to_name,to_port,bufSize,expSize,msgSize,
- &(res[0].value),&(res[1].value) ))) {
- fprintf(stderr,
- "%s:%d:grasbw_cbRequest: Error %s encountered while doing the test\n",
- __FILE__,__LINE__,xbt_error_name(error->errcode));
- strncpy(error->errmsg,"Error within grasbw_test",ERRMSG_LEN);
- gras_msg_new_and_send(msg->sock,GRASMSG_BW_RESULT,2,
- error,1,
- res,2);
- return 1;