typedef unsigned int fwp_endpoint_id_t;
+/**
+ * Default fwp endpoint attributes
+ */
static fwp_endpoint_attr_t fwp_epoint_attr_default ={
.reliability = FWP_EPOINT_BESTEFFORT,
.max_connections = 20,
};
/**
- * Structure of FWP endpoint.
+ * FWP endpoint structure
*/
struct fwp_endpoint{
- /** endpoint attributes */
+ /** Fwp endpoint attributes */
fwp_endpoint_attr_t attr;
- /** for send enpoint it contains destination address for
+ /** For send enpoint it contains destination address for
* receive endpoint it is filled with the msg source address
*/
- fwp_vres_d_t vresd;
struct fwp_sockaddr peer;
- /** source/destination port */
+ /** Dource/destination port */
unsigned int port;
- /** destination node */
+ /** Destination node */
int node;
/** Socket descriptor.
- * In case of rebliable epoint it is a listen socket.
- * */
+ * In case of rebliable epoint it is a listen tcp socket.
+ */
int sockd;
- fd_set fdset;
- fd_set testfds;
+ /** File descriptor array of peers connected
+ * to this fwp receive endpoint.*/
int *c_sockd;
+ /**
+ * Number of connections
+ */
unsigned int nr_connections;
+ /** client fdset */
+ fd_set fdset;
+ fd_set testfds;
/** specific operation options*/
int flags;
};
/**
* Allocates endpoint
*
- * \return On success returns endpoint structure.
+ * \return On success returns fwp endpoint structure.
* On error, NULL is returned.
*
*/
int fwp_send_endpoint_create(unsigned int node,
unsigned int port,
fwp_endpoint_attr_t *attr,
- fwp_endpoint_t **epoint)
+ fwp_endpoint_d_t *epointp)
{
struct sockaddr_in *addr;
fwp_endpoint_t *fwp_epoint;
}
#endif
- *epoint = fwp_epoint;
+ *epointd = fwp_epoint;
return 0;
err:
fwp_endpoint_destroy(fwp_epoint);
*/
int fwp_receive_endpoint_create(unsigned int port,
fwp_endpoint_attr_t *attr,
- fwp_endpoint_t **epoint)
+ fwp_endpoint_d_t *epointd)
{
struct sockaddr_in *addr;
fwp_endpoint_t *fwp_epoint;
addr = (struct sockaddr_in *) &(fwp_epoint->peer.addr);
addr->sin_family = AF_INET;
/* TODO: set listen interface, maybe through config struct*/
- addr->sin_addr.s_addr = INADDR_ANY;
+ addr->sin_addr.s_addr = FWP_ANY_NODE;
fwp_epoint->port = addr->sin_port = htons(port);
fwp_epoint->peer.addrlen = sizeof(struct sockaddr_in);
getsockname(fwp_epoint->sockd, (struct sockaddr*)&fwp_epoint->peer.addr,
&fwp_epoint->peer.addrlen);
- *epoint = fwp_epoint;
+ *epointd = fwp_epoint;
return 0;
err:
fwp_endpoint_destroy(fwp_epoint);
*
* \return On success returns 0. On error, -1 and errno is set appropriately.
*/
-int fwp_send_endpoint_bind(fwp_endpoint_t *epoint, fwp_vres_d_t vresd)
+int fwp_send_endpoint_bind(fwp_endpoint_d_t epointd, fwp_vres_d_t vresd)
{
int rv;
- fwp_endpoint_t *fwp_epoint = epoint;
+ fwp_endpoint_t *fwp_epoint = epointd;
#ifndef FWP_CONTNEGT
FWP_DEBUG("Empty bind\n");
* \return On success returns 0. On error, -1 is returned and errno is set appropriately.
*
*/
-int fwp_send_endpoint_unbind(fwp_endpoint_t *epoint)
+int fwp_send_endpoint_unbind(fwp_endpoint_d_t epointd)
{
int rv = 0;
- fwp_endpoint_t *fwp_epoint = epoint;
+ fwp_endpoint_t *fwp_epoint = epointd;
/* unlink epoint-vres mutually */
if ((rv = fwp_vres_unbind(fwp_epoint->vresd)) < 0)
return 0;
}
+/**
+ * Accepts (TCP) client connection to receive endpoint
+ *
+ * \param[in] epointd Pointer to fwp endpoint
+ * \return
+ * On success, it returns zero.
+ *
+ */
static int fwp_receive_endpoint_accept(fwp_endpoint_t *fwp_epoint)
{
int csockd;
while ((fwp_epoint->c_sockd[i])&& (i < fwp_epoint->nr_connections))
i++;
fwp_epoint->c_sockd[i] = csockd;
- FWP_DEBUG("Index = %d\n", i);
fwp_epoint->nr_connections++;
- FWP_DEBUG("before\n");
FD_SET(csockd, &fwp_epoint->fdset);
- FWP_DEBUG("SET fdset\n");
return 0;
}
* On error, -1 is returned and errno is set appropriately.
*
*/
-ssize_t fwp_recv(fwp_endpoint_t *endpoint,
+ssize_t fwp_recv(fwp_endpoint_d_t epointd,
void *buffer, const size_t buffer_size,
unsigned int *from, int flags)
{
- fwp_sockaddr_t *peer = &endpoint->peer;
+ fwp_endpoint_t *fwp_epoint = epointd;
+ fwp_sockaddr_t *peer = &fwp_epoint->peer;
ssize_t len;
fd_set fdset;
- fwp_endpoint_t *fwp_epoint = endpoint;
/* if (!fwp_endpoint_is_valid(epointd)) {
errno = EINVAL;
* On error, -1 is returned and errno is set appropriately.
*
*/
-int fwp_send(fwp_endpoint_t *fwp_epoint,const void *msg, const size_t size, int flags)
+int fwp_send(fwp_endpoint_d_t *epointd,const void *msg, const size_t size,
+ int flags)
{
+ fwp_endpoint_t *fwp_epoint = epointd;
struct fwp_msgb *msgb;
- /*fwp_endpoint_t *fwp_epoint;*/
/* if (!fwp_endpoint_is_valid(epointd)){
errno = EINVAL;
*/
typedef
struct fwp_endpoint_attr {
+ /** Specifies whether fwp enpoint is reliable (TCP) or not (UDP)*/
unsigned int reliability;
+ /** Specifies max number of allowed connections */
unsigned int max_connections;
/* queueing policy*/
} fwp_endpoint_attr_t;
unsigned int *port, fwp_endpoint_attr_t *attr);
int fwp_send_endpoint_create(unsigned int node, unsigned int port,
fwp_endpoint_attr_t *attr,
- fwp_endpoint_t **epoint);
+ fwp_endpoint_d_t *epointd);
int fwp_receive_endpoint_create(/*unsigned int node,*/ unsigned int port,
fwp_endpoint_attr_t *attr,
- fwp_endpoint_t **epoint);
+ fwp_endpoint_d_t *epointd);
int fwp_endpoint_destroy(fwp_endpoint_d_t epointd);
int fwp_send_endpoint_bind(fwp_endpoint_d_t epointd, fwp_vres_d_t vresd);
int fwp_send_endpoint_unbind(fwp_endpoint_d_t epointd);
-ssize_t fwp_recv(fwp_endpoint_t *endpoint,
+ssize_t fwp_recv(fwp_endpoint_d_t epointd,
void *buffer, const size_t buffer_size,
unsigned int *from, int flags);
-int fwp_send(fwp_endpoint_t *fwp_epoint, const void *msg, const size_t size, int flags);
-
+int fwp_send(fwp_endpoint_d_t epointd, const void *msg, const size_t size,
+ int flags);
int fwp_endpoint_attr_init(fwp_endpoint_attr_t *attr);
static inline int fwp_endpoint_attr_setreliability(fwp_endpoint_attr_t *attr,