/** Fwp endpoint attributes */
fwp_endpoint_attr_t attr;
/* Vres this fwp endpoint is bound to */
- fwp_vres_d_t vresd;
+ fwp_vres_t *vres;
/** For send enpoint it contains destination address for
* receive endpoint it is filled with the msg source address
*/
/**
* Destroy endpoint
*
- * \param[in] epointd Endpoint descriptor
+ * \param[in] epd Endpoint descriptor
* \return On success 0 is returned.
* On error, negative error value is returned and errno is set appropriately.
*/
-int fwp_endpoint_destroy(fwp_endpoint_d_t epointd)
+int fwp_endpoint_destroy(fwp_endpoint_t *ep)
{
- if (epointd->sockd > 0)
- close(epointd->sockd);
+ if (ep->sockd > 0)
+ close(ep->sockd);
- fwp_endpoint_free(epointd);
+ fwp_endpoint_free(ep);
return 0;
}
/**
* Get endpoint parameters
*
- * \param[in] epointd Endpoint descriptor
+ * \param[in] ep Endpoint descriptor
* \param[out] node Node identifier
* \param[out] port Port
* \param[out] attr Endpoint`s attributes
* \return On success 0 is returned.
* On error, negative error value is returned.
*/
-int fwp_endpoint_get_params(fwp_endpoint_d_t epointd, unsigned int *node,
+int fwp_endpoint_get_params(fwp_endpoint_t *ep, unsigned int *node,
unsigned int *port, fwp_endpoint_attr_t *attr)
{
- fwp_endpoint_t *epoint = epointd;
-
- if (node) *node = epoint->node;
- if (port) *port = epoint->port;
- if (attr) *attr = epoint->attr;
+ if (node) *node = ep->node;
+ if (port) *port = ep->port;
+ if (attr) *attr = ep->attr;
return 0;
}
* \param[in] node IP address of destination node
* \param[in] port UDP port
* \param[in] attr Endpoint attributes
- * \param[out] epointdp Pointer to the descriptor of newly created endpoint
+ * \param[out] epp Pointer to the descriptor of newly created endpoint
*
* \return Zero on success, -1 on error and sets errno appropriately.
*
int fwp_send_endpoint_create(unsigned int node,
unsigned int port,
fwp_endpoint_attr_t *attr,
- fwp_endpoint_d_t *epointd)
+ fwp_endpoint_t **epoint)
{
struct sockaddr_in *addr;
fwp_endpoint_t *fwp_epoint;
fwp_send_endpoint_bind(fwp_epoint, fwp_epoint->vresd);
#endif
- *epointd = fwp_epoint;
+ *epoint = fwp_epoint;
return fwp_epoint->sockd;
err:
fwp_endpoint_destroy(fwp_epoint);
*/
int fwp_receive_endpoint_create(unsigned int port,
fwp_endpoint_attr_t *attr,
- fwp_endpoint_d_t *epointd)
+ fwp_endpoint_t **epp)
{
struct sockaddr_in *addr;
fwp_endpoint_t *fwp_epoint;
addr = (struct sockaddr_in*) fwp_epoint->peer.addr;
fwp_epoint->port = ntohs(addr->sin_port);
FWP_DEBUG("Recv port= %d\n",ntohs(addr->sin_port));
- *epointd = fwp_epoint;
+ *epp = fwp_epoint;
return 0;
err:
fwp_endpoint_destroy(fwp_epoint);
/**
* Binds send endpoint to vres
*
- * \param[in] vres_id identifier of vres
- * \param[in] epoint_id send endpoint identifier
+ * \param[in] vres identifier of vres
+ * \param[in] ep send endpoint identifier
*
* \return On success returns 0. On error, -1 and errno is set appropriately.
*/
-int fwp_send_endpoint_bind(fwp_endpoint_d_t epointd, fwp_vres_d_t vresd)
+int fwp_send_endpoint_bind(fwp_endpoint_t *ep, fwp_vres_t *vres)
{
int rv = 0;
#ifndef FWP_WITHOUT_CONTNEGT
- fwp_endpoint_t *fwp_epoint = epointd;
- fwp_epoint->vresd = vresd;
- rv = fwp_vres_bind(vresd, fwp_epoint->sockd);
+ ep->vres = vres;
+ rv = fwp_vres_bind(vres, ep->sockd);
#endif
/* if send endpoint is already bound
if (epoint->type == FWP_EPOINT_BOUND) {
* \return On success returns 0. On error, -1 is returned and errno is set appropriately.
*
*/
-int fwp_send_endpoint_unbind(fwp_endpoint_d_t epointd)
+int fwp_send_endpoint_unbind(fwp_endpoint_t *ep)
{
int rv = 0;
- fwp_endpoint_t *fwp_epoint = epointd;
/* unlink epoint-vres mutually */
- if ((rv = fwp_vres_unbind(fwp_epoint->vresd)) < 0)
+ if ((rv = fwp_vres_unbind(ep->vres)) < 0)
return rv;
return 0;
* On error, -1 is returned and errno is set appropriately.
*
*/
-int fwp_recv_conn(fwp_endpoint_d_t epointd, void *buffer,
+int fwp_recv_conn(fwp_endpoint_t *ep, void *buffer,
size_t buffer_size)
{
- fwp_endpoint_t *fwp_epoint = epointd;
- fwp_sockaddr_t *peer = &fwp_epoint->peer;
- fd_set fdset = fwp_epoint->fdset;
+ fwp_sockaddr_t *peer = &ep->peer;
+ fd_set fdset = ep->fdset;
ssize_t len;
int i;
FWP_DEBUG("Checking for tcp data\n");
- for (i = 0; i < fwp_epoint->nr_connections; i++) {
- if (!FD_ISSET(fwp_epoint->c_sockd[i], &fdset)) {
+ for (i = 0; i < ep->nr_connections; i++) {
+ if (!FD_ISSET(ep->c_sockd[i], &fdset)) {
continue;
}
FWP_DEBUG("Prepare to receive tcp data\n");
peer->addrlen = sizeof(struct sockaddr_in);
- len = _fwp_recvfrom(fwp_epoint->c_sockd[i], buffer,
+ len = _fwp_recvfrom(ep->c_sockd[i], buffer,
buffer_size,0, peer);
if (len < 0) /* Error */
/* tcp connection closed */
FWP_DEBUG("Connection closed\n");
- FD_CLR(fwp_epoint->c_sockd[i], &fwp_epoint->fdset);
- memcpy(fwp_epoint->c_sockd+i, fwp_epoint->c_sockd+i+1,
- sizeof(int)*(fwp_epoint->nr_connections -i-1));
- fwp_epoint->nr_connections--;
+ FD_CLR(ep->c_sockd[i], &ep->fdset);
+ memcpy(ep->c_sockd+i, ep->c_sockd+i+1,
+ sizeof(int)*(ep->nr_connections -i-1));
+ ep->nr_connections--;
return 0;
}
return 0;
* On error, -1 is returned and errno is set appropriately.
*
*/
-ssize_t fwp_recv(fwp_endpoint_d_t epointd,
+ssize_t fwp_recv(fwp_endpoint_t *ep,
void *buffer, const size_t buffer_size,
unsigned int *from, int flags)
{
- fwp_endpoint_t *fwp_epoint = epointd;
- fwp_sockaddr_t *peer = &fwp_epoint->peer;
- struct sockaddr_in *addr = (struct sockaddr_in*) fwp_epoint->peer.addr;
+ fwp_sockaddr_t *peer = &ep->peer;
+ struct sockaddr_in *addr = (struct sockaddr_in*) ep->peer.addr;
ssize_t len;
fd_set fdset;
return -1;
}*/
- if (fwp_epoint->attr.reliability == FWP_EPOINT_BESTEFFORT) {
- len = _fwp_recvfrom(fwp_epoint->sockd, buffer,
+ if (ep->attr.reliability == FWP_EPOINT_BESTEFFORT) {
+ len = _fwp_recvfrom(ep->sockd, buffer,
buffer_size, 0, peer);
*from = addr->sin_addr.s_addr;
while (1){
/* FWP_EPOINT_RELIABLE */
- fdset = fwp_epoint->fdset;
+ fdset = ep->fdset;
if (select(FD_SETSIZE, &fdset, (fd_set *)0,
(fd_set *)0, NULL) < 0) {
return -1;
}
- if (FD_ISSET(fwp_epoint->sockd, &fdset)) { /* is it listen socket? */
- fwp_receive_endpoint_accept(fwp_epoint);
+ if (FD_ISSET(ep->sockd, &fdset)) { /* is it listen socket? */
+ fwp_receive_endpoint_accept(ep);
continue;
}
/* Check client TCP sockets */
- len = fwp_recv_conn(fwp_epoint, buffer, buffer_size);
+ len = fwp_recv_conn(ep, buffer, buffer_size);
if (len) {
*from = addr->sin_addr.s_addr;
return len;
* On error, -1 is returned and errno is set appropriately.
*
*/
-int fwp_send(fwp_endpoint_d_t epointd,const void *msg, const size_t size)
+int fwp_send(fwp_endpoint_t *ep,const void *msg, const size_t size)
{
- fwp_endpoint_t *fwp_epoint = epointd;
struct fwp_msgb *msgb;
/* if (!fwp_endpoint_is_valid(epointd)){
return -1;
}
- /*msgb->peer = &fwp_epoint->peer;*/
+ /*msgb->peer = &ep->peer;*/
/*msgb->data = msg;*/
/*msgb->flags = epoint->flags;*/
/*}*/
/* TODO: test whether _fwp_vres_send is successful */
- return fwp_vres_send(fwp_epoint->vresd, msgb);
+ return fwp_vres_send(ep->vres, msgb);
}