/* $Id$ */
-/* gras_rl - implementation of GRAS on real life */
+/* gras_rl - legacy implementation of GRAS on real life */
+/* This file should be KILLED whenever the raw sockets work in the new gras */
-/* Authors: Martin Quinson */
-/* Copyright (C) 2003 the OURAGAN project. */
+/* Copyright (c) 2003 Martin Quinson. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
- under the terms of the license (GNU LGPL) which comes with this package. */
+ * under the terms of the license (GNU LGPL) which comes with this package. */
#include "gras_rl.h"
#include "timeouts.h"
#include "protocol.h"
-GRAS_LOG_NEW_DEFAULT_CATEGORY(rl,"Real Life");
+/* XBT_LOG_NEW_DEFAULT_CATEGORY(rl,"Real Life"); Comment this to make sure it doesn't land into the documentation*/
/* globals */
static grasProcessData_t *_grasProcessData;
/* Prototypes of internal functions */
static int grasConversionRequired(const DataDescriptor *description, size_t howMany);
-static gras_error_t
+static xbt_error_t
_gras_rawsock_exchange(gras_rawsock_t *sd, int sender, unsigned int timeout,
unsigned int expSize, unsigned int msgSize);
-gras_error_t gras_process_init() {
+xbt_error_t gras_process_init() {
if (!(_grasProcessData=(grasProcessData_t *)malloc(sizeof(grasProcessData_t)))) {
fprintf(stderr,"gras_process_init: cannot malloc %d bytes\n",sizeof(grasProcessData_t));
return malloc_error;
_grasProcessData->userdata = NULL;
return no_error;
}
-gras_error_t gras_process_finalize() {
+xbt_error_t gras_process_finalize() {
fprintf(stderr,"FIXME: %s not implemented (=> leaking on exit :)\n",__FUNCTION__);
return no_error;
}
/* **************************************************************************
* Openning/Maintaining/Closing connexions
* **************************************************************************/
-gras_error_t
+xbt_error_t
gras_sock_client_open(const char *host, short port,
/* OUT */ gras_sock_t **sock) {
}
-gras_error_t
+xbt_error_t
gras_sock_server_open(unsigned short startingPort, unsigned short endingPort,
/* OUT */ gras_sock_t **sock) {
return no_error;
}
-gras_error_t gras_sock_close(gras_sock_t *sock) {
+xbt_error_t gras_sock_close(gras_sock_t *sock) {
if (sock) {
DROP_SOCKET(&(sock->sock));
if (sock->peer_addr) free(sock->peer_addr);
return recvResult;
}
-gras_error_t grasDataSend(gras_sock_t *sd,
+xbt_error_t grasDataSend(gras_sock_t *sd,
const void *data,
const DataDescriptor *description,
size_t description_length,
return no_error;
}
-gras_error_t
+xbt_error_t
grasMsgRecv(gras_msg_t **msg,
double timeOut) {
int dummyldap;
* Send a message to the network
*/
-gras_error_t
+xbt_error_t
gras_msg_send(gras_sock_t *sd,
gras_msg_t *msg,
- e_gras_free_directive_t freeDirective) {
+ e_xbt_free_directive_t freeDirective) {
- gras_error_t errcode;
+ xbt_error_t errcode;
int i;
/* arg validity checks */
- gras_assert0(msg,"Trying to send NULL message");
- gras_assert0(sd, "Trying to send over a NULL socket");
+ xbt_assert0(msg,"Trying to send NULL message");
+ xbt_assert0(sd, "Trying to send over a NULL socket");
fprintf(stderr,"Header to send=ver:'%s' msg:%d size:%d seqCount:%d\n",
msg->header,
headerDescriptor,headerDescriptorCount,1))) {
fprintf(stderr,"gras_msg_send: Error '%s' while sending header of message %s to %s:%d\n",
- gras_error_name(errcode),msg->entry->name,gras_sock_get_peer_name(sd),gras_sock_get_peer_port(sd));
+ xbt_error_name(errcode),msg->entry->name,gras_sock_get_peer_name(sd),gras_sock_get_peer_port(sd));
return errcode;
}
msg->dataCount,countDescriptor,countDescriptorCount,
msg->entry->seqCount))) {
fprintf(stderr,"gras_msg_send: Error '%s' while sending sequence counts of message %s to %s\n",
- gras_error_name(errcode),msg->entry->name,gras_sock_get_peer_name(sd));
+ xbt_error_name(errcode),msg->entry->name,gras_sock_get_peer_name(sd));
return errcode;
}
(const DataDescriptor*)msg->entry->dd[i],msg->entry->ddCount[i],
msg->dataCount[i]))) {
fprintf(stderr,"gras_msg_send: Error '%s' while sending sequence %d of message %s to %s\n",
- gras_error_name(errcode),i,msg->entry->name,gras_sock_get_peer_name(sd));
+ xbt_error_name(errcode),i,msg->entry->name,gras_sock_get_peer_name(sd));
return errcode;
}
}
/* **************************************************************************
* Creating/Using raw sockets
* **************************************************************************/
-gras_error_t gras_rawsock_server_open(unsigned short startingPort,
+xbt_error_t gras_rawsock_server_open(unsigned short startingPort,
unsigned short endingPort,
unsigned int bufSize, gras_rawsock_t **sock) {
struct sockaddr_in sockaddr;
return;
}
-gras_error_t gras_rawsock_client_open(const char *host, short port,
+xbt_error_t gras_rawsock_client_open(const char *host, short port,
unsigned int bufSize, gras_rawsock_t **sock) {
int i,addrCount;
IPAddress addresses[10];
return no_error;
}
-gras_error_t gras_rawsock_close(gras_rawsock_t *sd) {
+xbt_error_t gras_rawsock_close(gras_rawsock_t *sd) {
if (sd) {
CloseSocket(&(sd->sock), 0);
free(sd);
}
/* FIXME: RL ignores the provided timeout and compute an appropriate one */
-static gras_error_t
+static xbt_error_t
_gras_rawsock_exchange(gras_rawsock_t *sd, int sender, unsigned int timeout,
unsigned int expSize, unsigned int msgSize){
char *expData;
return no_error;
}
-gras_error_t
+xbt_error_t
gras_rawsock_recv(gras_rawsock_t *sd, unsigned int expSize, unsigned int msgSize,
unsigned int timeout) {
return _gras_rawsock_exchange(sd,0,timeout,expSize,msgSize);
}
-gras_error_t
+xbt_error_t
gras_rawsock_send(gras_rawsock_t *sd, unsigned int expSize, unsigned int msgSize){
return _gras_rawsock_exchange(sd,1,0,expSize,msgSize);
}