From: mquinson Date: Mon, 1 Mar 2004 21:00:43 +0000 (+0000) Subject: Transport becomes a real module X-Git-Tag: v3.3~5301 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/afb6a920a5fb4da71b20d3653e67ff9c48f45dcb Transport becomes a real module git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@45 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/gras/Transport/transport.c b/src/gras/Transport/transport.c new file mode 100644 index 0000000000..3aa7a2eaef --- /dev/null +++ b/src/gras/Transport/transport.c @@ -0,0 +1,34 @@ +/* $Id$ */ + +/* bloc_transport - send/receive a bunch of bytes */ + +/* Authors: Martin Quinson */ +/* Copyright (C) 2004 Martin Quinson. */ + +/* 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. */ + +#include "gras_private.h" +#include "transport.h" + +GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(transport,GRAS); + + +gras_error_t +gras_trp_init(void){ + RAISE_UNIMPLEMENTED; +} + +void +gras_trp_exit(void){ + + ERROR1("%s not implemented",__FUNCTION__); + abort(); +} + +gras_error_t +gras_trp_plugin_get_by_name(const char *name, + gras_trp_plugin_t **dst){ + + RAISE_UNIMPLEMENTED; +} diff --git a/src/gras/Transport/transport_private.h b/src/gras/Transport/transport_private.h new file mode 100644 index 0000000000..bef632eb3b --- /dev/null +++ b/src/gras/Transport/transport_private.h @@ -0,0 +1,115 @@ +/* $Id$ */ + +/* trp (transport) - send/receive a bunch of bytes */ + +/* This file implements the public interface of this module, exported to the*/ +/* other modules of GRAS, but not to the end user. */ + +/* Authors: Martin Quinson */ +/* Copyright (C) 2004 Martin Quinson. */ + +/* 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. */ + +#ifndef GRAS_TRP_PRIVATE_H +#define GRAS_TRP_PRIVATE_H + +#include "gras_private.h" +/* A low-level socket type (each plugin implements it the way it prefers */ +//typedef void gras_trp_sock_t; + +/* A plugin type */ +struct gras_trp_plugin_ { + const char *name; + + gras_error_t (*init)(void); + void (*exit)(gras_trp_plugin_t *); + + gras_error_t (*socket_client_open)(const char *host, + unsigned short port, + int raw, + unsigned int bufSize, + /* OUT */ gras_trp_sock_t **dst); + gras_error_t (*socket_server_open)(unsigned short port, + int raw, + unsigned int bufSize, + /* OUT */ gras_trp_sock_t **dst); + void (*socket_close)(gras_trp_sock_t **sd); + + gras_error_t (*select)(double timeOut, + gras_trp_sock_t **sd); + + gras_error_t (*bloc_send)(gras_trp_sock_t *sd, + void *data, + size_t size, + double timeOut); + gras_error_t (*bloc_recv)(gras_trp_sock_t *sd, + void *data, + size_t size, + double timeOut); + gras_error_t (*flush)(gras_trp_sock_t *sd); + + void *specific; +}; + +/********************************************************************** + * Internal stuff to the module. Other modules shouldn't fool with it * + **********************************************************************/ + +/* TCP driver */ +gras_error_t gras_trp_tcp_init(void); +void gras_trp_tcp_exit(gras_trp_plugin_t *plugin); +gras_error_t gras_trp_tcp_socket_client(const char *host, + unsigned short port, + int raw, + unsigned int bufSize, + /* OUT */ gras_trp_sock_t **dst); +gras_error_t gras_trp_tcp_socket_server(unsigned short port, + int raw, + unsigned int bufSize, + /* OUT */ gras_trp_sock_t **dst); +void gras_trp_tcp_socket_close(gras_trp_sock_t **sd); +gras_error_t gras_trp_tcp_select(double timeOut, + gras_trp_sock_t **sd); + +gras_error_t gras_trp_tcp_bloc_send(gras_trp_sock_t *sd, + void *data, + size_t size, + double timeOut); + +gras_error_t gras_trp_tcp_bloc_recv(gras_trp_sock_t *sd, + void *data, + size_t size, + double timeOut); +gras_error_t gras_trp_tcp_flush(gras_trp_sock_t *sd); + +/* SG driver */ +gras_error_t gras_trp_sg_init(void); +void gras_trp_sg_exit(gras_trp_plugin_t *plugin); +gras_error_t gras_trp_sg_socket_client(const char *host, + unsigned short port, + int raw, + unsigned int bufSize, + /* OUT */ gras_trp_sock_t **dst); +gras_error_t gras_trp_sg_socket_server(unsigned short port, + int raw, + unsigned int bufSize, + /* OUT */ gras_trp_sock_t **dst); +void gras_trp_sg_socket_close(gras_trp_sock_t **sd); +gras_error_t gras_trp_sg_select(double timeOut, + gras_trp_sock_t **sd); + +gras_error_t gras_trp_sg_bloc_send(gras_trp_sock_t *sd, + void *data, + size_t size, + double timeOut); + +gras_error_t gras_trp_sg_bloc_recv(gras_trp_sock_t *sd, + void *data, + size_t size, + double timeOut); +gras_error_t gras_trp_sg_flush(gras_trp_sock_t *sd); + + + +#endif /* GRAS_TRP_PRIVATE_H */ diff --git a/src/gras/Transport/transport_sg.c b/src/gras/Transport/transport_sg.c new file mode 100644 index 0000000000..828ddfdeb2 --- /dev/null +++ b/src/gras/Transport/transport_sg.c @@ -0,0 +1,79 @@ +/* $Id$ */ + +/* file trp (transport) - send/receive a bunch of bytes in SG realm */ + +/* Authors: Martin Quinson */ +/* Copyright (C) 2004 Martin Quinson. */ + +/* 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. */ + +#include "gras_private.h" +#include "transport_private.h" + +GRAS_LOG_EXTERNAL_CATEGORY(transport); +GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(trp_sg,transport); + +typedef struct { + int dummy; +} gras_trp_sg_specific_t; + +gras_error_t +gras_trp_sg_init(void) { + + gras_trp_sg_specific_t *specific = malloc(sizeof(gras_trp_sg_specific_t)); + if (!specific) + RAISE_MALLOC; + + return no_error; +} + +void +gras_trp_sg_exit(gras_trp_plugin_t *plugin) { + gras_trp_sg_specific_t *specific = (gras_trp_sg_specific_t*)plugin->specific; + free(specific); +} + +gras_error_t gras_trp_sg_socket_client(const char *host, + unsigned short port, + int raw, + unsigned int bufSize, + /* OUT */ gras_trp_sock_t **dst){ + RAISE_UNIMPLEMENTED; +} + +gras_error_t gras_trp_sg_socket_server(unsigned short port, + int raw, + unsigned int bufSize, + /* OUT */ gras_trp_sock_t **dst){ + RAISE_UNIMPLEMENTED; +} + +void gras_trp_sg_socket_close(gras_trp_sock_t **sd){ + ERROR1("%s not implemented",__FUNCTION__); + abort(); +} + +gras_error_t gras_trp_sg_select(double timeOut, + gras_trp_sock_t **sd){ + RAISE_UNIMPLEMENTED; +} + +gras_error_t gras_trp_sg_bloc_send(gras_trp_sock_t *sd, + void *data, + size_t size, + double timeOut){ + RAISE_UNIMPLEMENTED; +} + +gras_error_t gras_trp_sg_bloc_recv(gras_trp_sock_t *sd, + void *data, + size_t size, + double timeOut){ + RAISE_UNIMPLEMENTED; +} + +gras_error_t gras_trp_sg_flush(gras_trp_sock_t *sd){ + RAISE_UNIMPLEMENTED; +} + diff --git a/src/gras/Transport/transport_tcp.c b/src/gras/Transport/transport_tcp.c new file mode 100644 index 0000000000..967e907413 --- /dev/null +++ b/src/gras/Transport/transport_tcp.c @@ -0,0 +1,78 @@ +/* $Id$ */ + +/* tcp trp (transport) - send/receive a bunch of bytes from a tcp socket */ + +/* Authors: Martin Quinson */ +/* Copyright (C) 2004 Martin Quinson. */ + +/* 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. */ + +#include "gras_private.h" +#include "transport_private.h" + +GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(trp_tcp,transport); + +typedef struct { + int dummy; +} gras_trp_tcp_specific_t; + +gras_error_t +gras_trp_tcp_init(void) { + + gras_trp_tcp_specific_t *specific = malloc(sizeof(gras_trp_tcp_specific_t)); + if (!specific) + RAISE_MALLOC; + + return no_error; +} + +void +gras_trp_tcp_exit(gras_trp_plugin_t *plugin) { + gras_trp_tcp_specific_t *specific = (gras_trp_tcp_specific_t*)plugin->specific; + free(specific); +} + +gras_error_t gras_trp_tcp_socket_client(const char *host, + unsigned short port, + int raw, + unsigned int bufSize, + /* OUT */ gras_trp_sock_t **dst){ + RAISE_UNIMPLEMENTED; +} + +gras_error_t gras_trp_tcp_socket_server(unsigned short port, + int raw, + unsigned int bufSize, + /* OUT */ gras_trp_sock_t **dst){ + RAISE_UNIMPLEMENTED; +} + +void gras_trp_tcp_socket_close(gras_trp_sock_t **sd){ + ERROR1("%s not implemented",__FUNCTION__); + abort(); +} + +gras_error_t gras_trp_tcp_select(double timeOut, + gras_trp_sock_t **sd){ + RAISE_UNIMPLEMENTED; +} + +gras_error_t gras_trp_tcp_bloc_send(gras_trp_sock_t *sd, + void *data, + size_t size, + double timeOut){ + RAISE_UNIMPLEMENTED; +} + +gras_error_t gras_trp_tcp_bloc_recv(gras_trp_sock_t *sd, + void *data, + size_t size, + double timeOut){ + RAISE_UNIMPLEMENTED; +} + +gras_error_t gras_trp_tcp_flush(gras_trp_sock_t *sd){ + RAISE_UNIMPLEMENTED; +} +