diff --git a/src/lam/ctnetwork/Makefile.am b/src/lam/ctnetwork/Makefile.am index 14bd700e91..30a67ffc34 100644 --- a/src/lam/ctnetwork/Makefile.am +++ b/src/lam/ctnetwork/Makefile.am @@ -5,7 +5,7 @@ include $(top_srcdir)/config/Makefile.options -noinst_LTLIBRARY = libctnetwork.la +noinst_LTLIBRARIES = libctnetwork.la libctnetwork_la_SOURCES = \ ctchannel.c \ diff --git a/src/lam/ctnetwork/ctchannel.c b/src/lam/ctnetwork/ctchannel.c index 5031e76b26..6011124c9d 100644 --- a/src/lam/ctnetwork/ctchannel.c +++ b/src/lam/ctnetwork/ctchannel.c @@ -1,13 +1,10 @@ /* - * ctchannel.c - * LAM-MPI - * - * Created by Rob Aulwes on Tue Dec 23 2003. - * Copyright (c) 2003 __MyCompanyName__. All rights reserved. - * + * $HEADER$ */ -#include "runtime/ctnetwork/ctchannel.h" +#include + +#include "lam/ctnetwork/ctchannel.h" #define CHANNEL_CLS(chnl) ((lam_ctchannel_class_t *)(OBJECT(chnl)->obj_class)) @@ -107,7 +104,7 @@ void lam_tcpch_init(lam_tcp_chnl_t *channel) { SUPER_INIT(channel, lam_tcp_channel_cls.cls_parent); channel->tcp_sockfd = 0; - bzero(&(channel->tcp_addr), sizeof(channel->tcp_addr)); + memset(&(channel->tcp_addr), 0, sizeof(channel->tcp_addr)); channel->tcp_blocking = 0; } @@ -120,7 +117,7 @@ void lam_tcpch_destroy(lam_tcp_chnl_t *channel) uint32_t lam_tcpch_send(lam_tcp_chnl_t *channel, const uint8_t *data, uint32_t data_len, uint32_t *bytes_sent) { - uint32_t ret = CT_CHNL_OK; + uint32_t ret = CT_CHNL_ERR_OK; return ret; } @@ -128,7 +125,7 @@ uint32_t lam_tcpch_send(lam_tcp_chnl_t *channel, const uint8_t *data, uint32_t lam_tcpch_recv(lam_tcp_chnl_t *channel, const uint8_t *buffer, uint32_t buff_len, uint32_t *bytes_recvd) { - uint32_t ret = CT_CHNL_OK; + uint32_t ret = CT_CHNL_ERR_OK; return ret; } @@ -136,7 +133,7 @@ uint32_t lam_tcpch_recv(lam_tcp_chnl_t *channel, const uint8_t *buffer, uint32_t lam_tcpch_get_msg(lam_tcp_chnl_t *channel, lam_ctmsg_t **msg) { - uint32_t ret = CT_CHNL_OK; + uint32_t ret = CT_CHNL_ERR_OK; return ret; } @@ -145,7 +142,7 @@ uint32_t lam_tcpch_get_msg(lam_tcp_chnl_t *channel, lam_ctmsg_t **msg) uint32_t lam_tcpch_get_packed_msg(lam_tcp_chnl_t *channel, const uint8_t **buffer, uint32_t *bytes_recvd) { - uint32_t ret = CT_CHNL_OK; + uint32_t ret = CT_CHNL_ERR_OK; return ret; } @@ -153,7 +150,7 @@ uint32_t lam_tcpch_get_packed_msg(lam_tcp_chnl_t *channel, const uint8_t **buffe uint32_t lam_tcpch_send_msg(lam_tcp_chnl_t *channel, lam_ctmsg_t *msg) { - uint32_t ret = CT_CHNL_OK; + uint32_t ret = CT_CHNL_ERR_OK; return ret; } @@ -163,7 +160,7 @@ uint32_t lam_tcpch_send_packed_msg(lam_tcp_chnl_t *channel, const uint8_t *packed_msg, uint32_t msg_len) { - uint32_t ret = CT_CHNL_OK; + uint32_t ret = CT_CHNL_ERR_OK; return ret; } diff --git a/src/lam/ctnetwork/ctchannel.h b/src/lam/ctnetwork/ctchannel.h index 66aa31ab67..fc4a15af66 100644 --- a/src/lam/ctnetwork/ctchannel.h +++ b/src/lam/ctnetwork/ctchannel.h @@ -1,17 +1,16 @@ /* - * ctchannel.h - * LAM-MPI - * - * Created by Rob Aulwes on Tue Dec 23 2003. - * Copyright (c) 2003 __MyCompanyName__. All rights reserved. - * + * $HEADER$ */ -#ifndef CT_CHANNEL_H -#define CT_CHANNEL_H +#ifndef LAM_CT_CHANNEL_H +#define LAM_CT_CHANNEL_H + +#include +#include +#include #include "lam/lfc/object.h" -#include "runtime/ctnetwork/ctmessage.h" +#include "lam/ctnetwork/ctmessage.h" /* @@ -20,26 +19,26 @@ typedef enum { - CT_CHNL_OK = 0, - CT_CHNL_ERROR, /* general channel error. */ - CT_CHNL_MALLOC, /* unable to alloc mem. */ - CT_CHNL_CLOSED, /* channel is not open */ - CT_CHNL_CONN_LOST, /* lost connection */ - CT_CHNL_INVALID_MSG, /* unable to pack/unpack msg or msg is NULL */ - CT_CHNL_TIMED_OUT /* channel operation timed out. */ -} lam_ctchnl_status_t; + CT_CHNL_ERR_OK = 0, + CT_CHNL_ERR_GENERAL, /* general channel error. */ + CT_CHNL_ERR_MALLOC, /* unable to alloc mem. */ + CT_CHNL_ERR_CLOSED, /* channel is not open */ + CT_CHNL_ERR_CONN_LOST, /* lost connection */ + CT_CHNL_ERR_INVALID_MSG, /* unable to pack/unpack msg or msg is NULL */ + CT_CHNL_ERR_TIMED_OUT /* channel operation timed out. */ +} lam_ctchnl_error_t; /* * Channel connection status */ -enum +typedef enum { CT_CHNL_CLOSED = 0, CT_CHNL_CONNECTED, CT_CHNL_FAILED -} +} lam_ctchnl_status_t; /* * @@ -52,27 +51,50 @@ enum struct lam_ctchannel; +/* return: error code args: (channel, data, data length, bytes sent) */ +typedef uint32_t (*lam_cth_send_fn_t)(struct lam_ctchannel *, + const uint8_t *, uint32_t, uint32_t *); + +/* return: error code args: (channel, recv buffer, buffer length, bytes received) */ +typedef uint32_t (*lam_cth_recv_fn_t)(struct lam_ctchannel *, + const uint8_t *, uint32_t, uint32_t *); + +/* return: error code args: (channel, msg ptr) */ +typedef uint32_t (*lam_cth_get_msg_fn_t)(struct lam_ctchannel *, + lam_ctmsg_t **); + +/* return: error code args: (channel, recv buffer ptr, bytes received) */ +typedef uint32_t (*lam_cth_get_packed_msg_fn_t)(struct lam_ctchannel *, + const uint8_t **, uint32_t *); + +/* return: error code args: (channel, msg) */ +typedef uint32_t (*lam_cth_send_msg_fn_t)(struct lam_ctchannel *, + lam_ctmsg_t *); + +/* return: error code args: (channel, msg ptr, msg len) */ +typedef uint32_t (*lam_cth_send_packed_msg_fn_t)(struct lam_ctchannel *, + const uint8_t *, uint32_t); + typedef struct lam_ctchannel_class { - lam_class_info_t super; - /* return: error code args: (channel, data, data length, bytes sent) */ - uint32_t cth_send(struct lam_ctchannel *, const uint8_t *, uint32_t, uint32_t *); + lam_class_info_t super; + /* return: error code args: (channel, data, data length, bytes sent) */ + lam_cth_send_fn_t *send; - /* return: error code args: (channel, recv buffer, buffer length, bytes received) */ - uint32_t cth_recv(struct lam_ctchannel *, const uint8_t *, uint32_t, uint32_t *); + /* return: error code args: (channel, recv buffer, buffer length, bytes received) */ + lam_cth_recv_fn_t *recv; + + /* return: error code args: (channel, msg ptr) */ + lam_cth_get_msg_fn_t *get_msg; - /* return: error code args: (channel, msg ptr) */ - uint32_t cth_get_msg(struct lam_ctchannel *, lam_ctmsg_t **); + /* return: error code args: (channel, recv buffer ptr, bytes received) */ + lam_cth_get_packed_msg_fn_t *get_packed_msg; - /* return: error code args: (channel, recv buffer ptr, bytes received) */ - uint32_t cth_get_packed_msg(struct lam_ctchannel *, const uint8_t **, uint32_t *); - - /* return: error code args: (channel, msg) */ - uint32_t cth_send_msg(struct lam_ctchannel *, lam_ctmsg_t *); - - /* return: error code args: (channel, msg ptr, msg len) */ - uint32_t cth_send_packed_msg(struct lam_ctchannel *, const uint8_t *, uint32_t); + /* return: error code args: (channel, msg) */ + lam_cth_send_msg_fn_t *send_msg; + /* return: error code args: (channel, msg ptr, msg len) */ + lam_cth_send_packed_msg_fn_t *send_packed_msg; } lam_ctchannel_class_t; @@ -95,19 +117,30 @@ void lam_cth_init(lam_ctchannel_t *channel); * */ +int lam_cth_is_connected(lam_ctchannel_t *channel); inline int lam_cth_is_connected(lam_ctchannel_t *channel) { return (CT_CHNL_CONNECTED == channel->cth_status); } -inline uint32_t lam_cth_get_id(lam_ctchannel_t *channel) {return channel->cth_id;} +uint32_t lam_cth_get_id(lam_ctchannel_t *channel); +inline uint32_t lam_cth_get_id(lam_ctchannel_t *channel) +{ + return channel->cth_id; +} +void lam_cth_set_id(lam_ctchannel_t *channel, uint32_t cid); inline void lam_cth_set_id(lam_ctchannel_t *channel, uint32_t cid) { channel->cth_id = cid; } -inline uint32_t lam_cth_get_timeout(lam_ctchannel_t *channel) {return channel->cth_timeout_secs;} -inline void lam_cth_set_id(lam_ctchannel_t *channel, uint32_t timeout) +uint32_t lam_cth_get_timeout(lam_ctchannel_t *channel); +inline uint32_t lam_cth_get_timeout(lam_ctchannel_t *channel) +{ + return channel->cth_timeout_secs; +} +void lam_cth_set_timeout(lam_ctchannel_t *channel, uint32_t timeout); +inline void lam_cth_set_timeout(lam_ctchannel_t *channel, uint32_t timeout) { channel->cth_timeout_secs = timeout; } @@ -180,6 +213,4 @@ uint32_t lam_tcpch_send_packed_msg(lam_tcp_chnl_t *channel, uint32_t msg_len); -#endif /* CT_CHANNEL_H */ - - +#endif /* LAM_CT_CHANNEL_H */ diff --git a/src/lam/ctnetwork/ctclient.c b/src/lam/ctnetwork/ctclient.c index e929f0e7a2..a8bfa0dd12 100644 --- a/src/lam/ctnetwork/ctclient.c +++ b/src/lam/ctnetwork/ctclient.c @@ -1,10 +1,5 @@ /* - * ctclient.c - * LAM-MPI - * - * Created by Rob Aulwes on Sat Dec 27 2003. - * Copyright (c) 2003 __MyCompanyName__. All rights reserved. - * + * $HEADER$ */ #include "ctclient.h" diff --git a/src/lam/ctnetwork/ctclient.h b/src/lam/ctnetwork/ctclient.h index 6b728c2e1d..093ff6eaf5 100644 --- a/src/lam/ctnetwork/ctclient.h +++ b/src/lam/ctnetwork/ctclient.h @@ -2,8 +2,8 @@ * $HEADER$ */ -#ifndef CT_CLIENT_H -#define CT_CLIENT_H +#ifndef LAM_CT_CLIENT_H +#define LAM_CT_CLIENT_H -#endif /* CT_CLIENT_H */ +#endif /* LAM_CT_CLIENT_H */ diff --git a/src/lam/ctnetwork/ctcontroller.h b/src/lam/ctnetwork/ctcontroller.h index a5306e3e8f..bea894aa6f 100644 --- a/src/lam/ctnetwork/ctcontroller.h +++ b/src/lam/ctnetwork/ctcontroller.h @@ -2,11 +2,11 @@ * $HEADER$ */ -#ifndef CT_CONTROLLER_H -#define CT_CONTROLLER_H +#ifndef LAM_CT_CONTROLLER_H +#define LAM_CT_CONTROLLER_H #include "lam/lfc/object.h" -#include "runtime/ctnetwork/ctnode.h" +#include "lam/ctnetwork/ctnode.h" typedef void (*lam_ctmsg_recvd_fn)(struct lam_ctcontroller *, lam_ctmsg_t *, @@ -40,6 +40,4 @@ inline void lam_ctl_set_failed_callback(lam_ctctrl_t *ctrl, lam_ctnode_failed_fn } -#endif /* CT_CONTROLLER_H */ - - +#endif /* LAM_CT_CONTROLLER_H */ diff --git a/src/lam/ctnetwork/ctmessage.c b/src/lam/ctnetwork/ctmessage.c index 467bf780ec..dc3bf12e9e 100644 --- a/src/lam/ctnetwork/ctmessage.c +++ b/src/lam/ctnetwork/ctmessage.c @@ -2,7 +2,7 @@ * $HEADER$ */ -#include "runtime/ctnetwork/ctmessage.h" +#include "lam/ctnetwork/ctmessage.h" #include "lam/util/malloc.h" @@ -268,7 +268,3 @@ uint8_t *lam_pk_ctm_get_data(uint8_t *buffer, uint32_t *len) { } - - - - diff --git a/src/lam/ctnetwork/ctmessage.h b/src/lam/ctnetwork/ctmessage.h index 72800ce829..2bb486f22c 100644 --- a/src/lam/ctnetwork/ctmessage.h +++ b/src/lam/ctnetwork/ctmessage.h @@ -2,8 +2,8 @@ * $HEADER$ */ -#ifndef CT_MESSAGE_H -#define CT_MESSAGE_H +#ifndef LAM_CT_MESSAGE_H +#define LAM_CT_MESSAGE_H #include "lam/lfc/object.h" @@ -99,42 +99,69 @@ void lam_pk_ctc_set_info(uint8_t *buffer, uint8_t *info); * Accessor functions */ -inline uint16_t lam_ctc_get_is_user_msg(lam_ct_ctrl_t *ctrl) {return ctrl->ctc_is_user_msg;} -inline uint16_t lam_ctc_set_is_user_msg(lam_ct_ctrl_t *ctrl, uint16_t yn) +lam_bool_t lam_ctc_get_is_user_msg(lam_ct_ctrl_t *ctrl); +inline lam_bool_t lam_ctc_get_is_user_msg(lam_ct_ctrl_t *ctrl) +{ + return ctrl->ctc_is_user_msg; +} +void lam_ctc_set_is_user_msg(lam_ct_ctrl_t *ctrl, lam_bool_t yn); +inline void lam_ctc_set_is_user_msg(lam_ct_ctrl_t *ctrl, lam_bool_t yn) { ctrl->ctc_is_user_msg = yn; } -inline uint16_t lam_ctc_get_routing_type(lam_ct_ctrl_t *ctrl) {return ctrl->ctc_routing_type;} -inline uint16_t lam_ctc_set_routing_type(lam_ct_ctrl_t *ctrl, int rtype) +uint16_t lam_ctc_get_routing_type(lam_ct_ctrl_t *ctrl); +inline uint16_t lam_ctc_get_routing_type(lam_ct_ctrl_t *ctrl) +{ + return ctrl->ctc_routing_type; +} +void lam_ctc_set_routing_type(lam_ct_ctrl_t *ctrl, int rtype); +inline void lam_ctc_set_routing_type(lam_ct_ctrl_t *ctrl, int rtype) { ctrl->ctc_routing_type = rtype; } -inline uint32_t lam_ctc_get_sender(lam_ct_ctrl_t *ctrl) {return ctrl->ctc_sender;} +uint32_t lam_ctc_get_sender(lam_ct_ctrl_t *ctrl); +inline uint32_t lam_ctc_get_sender(lam_ct_ctrl_t *ctrl) +{ + return ctrl->ctc_sender; +} +void lam_ctc_set_sender(lam_ct_ctrl_t *ctrl, uint32_t sender); inline void lam_ctc_set_sender(lam_ct_ctrl_t *ctrl, uint32_t sender) { ctrl->ctc_sender = sender; } -inline uint32_t lam_ctc_get_dest(lam_ct_ctrl_t *ctrl) {return ctrl->ctc_dest;} +uint32_t lam_ctc_get_dest(lam_ct_ctrl_t *ctrl); +inline uint32_t lam_ctc_get_dest(lam_ct_ctrl_t *ctrl) +{ + return ctrl->ctc_dest; +} +void lam_ctc_set_dest(lam_ct_ctrl_t *ctrl, uint32_t dest); inline void lam_ctc_set_dest(lam_ct_ctrl_t *ctrl, uint32_t dest) { ctrl->ctc_dest = dest; } -inline uint32_t lam_ctc_get_forwarding(lam_ct_ctrl_t *ctrl) {return ctrl->ctc_forwarding;} +uint32_t lam_ctc_get_forwarding(lam_ct_ctrl_t *ctrl); +inline uint32_t lam_ctc_get_forwarding(lam_ct_ctrl_t *ctrl) +{ + return ctrl->ctc_forwarding; +} +void lam_ctc_set_forwarding(lam_ct_ctrl_t *ctrl, uint32_t node); inline void lam_ctc_set_forwarding(lam_ct_ctrl_t *ctrl, uint32_t node) { ctrl->ctc_forwarding = node; } +uint8_t *lam_ctc_get_info(lam_ct_ctrl_t *ctrl, uint32_t *len); inline uint8_t *lam_ctc_get_info(lam_ct_ctrl_t *ctrl, uint32_t *len) { *len = ctrl->ctc_info_len; return ctrl->ctc_info; } +void lam_ctc_set_info(lam_ct_ctrl_t *ctrl, uint32_t len, uint8_t *info); inline void lam_ctc_set_info(lam_ct_ctrl_t *ctrl, uint32_t len, uint8_t *info) { ctrl->ctc_info_len = len; @@ -186,13 +213,16 @@ uint8_t *lam_pk_ctm_get_data(uint8_t *buffer, uint32_t *len); * */ -inline lam_ct_ctrl_t *lam_ctm_get_control(lam_ctmsg_t *msg) {return msg->ctm_ctrl;} +lam_ct_ctrl_t *lam_ctm_get_control(lam_ctmsg_t *msg); +inline lam_ct_ctrl_t *lam_ctm_get_control(lam_ctmsg_t *msg) +{ + return msg->ctm_ctrl; +} +void lam_ctm_set_control(lam_ctmsg_t *msg, lam_ct_ctrl_t *ctrl); inline void lam_ctm_set_control(lam_ctmsg_t *msg, lam_ct_ctrl_t *ctrl) { msg->ctm_ctrl = ctrl; } -#endif /* CT_MESSAGE_H */ - - +#endif /* LAM_CT_MESSAGE_H */ diff --git a/src/lam/ctnetwork/ctnode.h b/src/lam/ctnetwork/ctnode.h index 41a355ecad..51b2791017 100644 --- a/src/lam/ctnetwork/ctnode.h +++ b/src/lam/ctnetwork/ctnode.h @@ -2,8 +2,8 @@ * $HEADER$ */ -#ifndef CT_NODE_H -#define CT_NODE_H +#ifndef LAM_CT_NODE_H +#define LAM_CT_NODE_H #include "lam/lfc/object.h" #include "lam/lfc/hash_table.h" @@ -151,5 +151,4 @@ typedef struct lam_hcube extern lam_class_info_t hcube_cls; -#endif /* CT_NODE_H */ - +#endif /* LAM_CT_NODE_H */ diff --git a/src/lam/ctnetwork/ctpeer.c b/src/lam/ctnetwork/ctpeer.c index 7b83521fb4..1002826b96 100644 --- a/src/lam/ctnetwork/ctpeer.c +++ b/src/lam/ctnetwork/ctpeer.c @@ -1,10 +1,5 @@ /* - * ctpeer.c - * LAM-MPI - * - * Created by Rob Aulwes on Sun Dec 21 2003. - * Copyright (c) 2003 __MyCompanyName__. All rights reserved. - * + * $HEADER$ */ #include "ctpeer.h" diff --git a/src/lam/ctnetwork/ctpeer.h b/src/lam/ctnetwork/ctpeer.h index 2fc00f7cb1..9269a9fe67 100644 --- a/src/lam/ctnetwork/ctpeer.h +++ b/src/lam/ctnetwork/ctpeer.h @@ -1,17 +1,10 @@ /* - * ctpeer.h - * LAM-MPI - * - * Created by Rob Aulwes on Sun Dec 21 2003. - * Copyright (c) 2003 __MyCompanyName__. All rights reserved. - * + * $HEADER$ */ -#ifndef CT_PEER_H -#define CT_PEER_H +#ifndef LAM_CT_PEER_H +#define LAM_CT_PEER_H #include "lam/lfc/object.h" -#endif /* CT_PEER_H */ - - +#endif /* LAM_CT_PEER_H */