]> rtime.felk.cvut.cz Git - frescor/fwp.git/commitdiff
WIP:reliable endpoints
authorMartin Molnar <molnar@sum.(none)>
Mon, 5 May 2008 16:05:15 +0000 (18:05 +0200)
committerMartin Molnar <molnar@sum.(none)>
Mon, 5 May 2008 16:05:15 +0000 (18:05 +0200)
fwp/lib/fwp_endpoint.c
fwp/lib/fwp_types.h
fwp/lib/fwp_vres.c

index 267b1a3c9d447173e4029f0aa545aa5b2ad5ad9f..c4f29d76b7df76ff4f2dddd8c1766c51924b0bf1 100644 (file)
@@ -98,7 +98,8 @@ static inline void fwp_endpoint_free(fwp_endpoint_t *epoint)
  * On error, negative error code is returned. 
  *
  */
-int fwp_send_endpoint_create(unsigned int node, unsigned int port, 
+
+int fwp_send_endpoint_create(unsigned int node, unsigned int port, int flags, 
                                fwp_endpoint_d_t *epointdp)
 {      
        struct sockaddr_in *addr;
@@ -117,13 +118,27 @@ int fwp_send_endpoint_create(unsigned int node, unsigned int port,
        addr->sin_family = AF_INET;
        addr->sin_addr.s_addr = node;
        addr->sin_port = htons(port);
+       
+       if (flags && FWP_RELIABLE) {
+               if ((sockd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
+                       perror("Unable to open socket");
+                       return (-errno);
+               }
+       }else{
+               if ((sockd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
+                       perror("Unable to open socket");
+                       return (-errno);
+               }
+               
+
+
+       }
 
        FWP_DEBUG("Send endpoint created.\n"); 
        *epointdp = epoint;
        return 0;               
 }
 
-       
 /**
  * Creates receive endpoint
  *
index 3425ddd8fdb46532aaebcc840527bfd2b3fb1b01..511d23a809ed835a78ed2fce1d9413118c4c1831 100644 (file)
@@ -4,4 +4,9 @@
 //struct fwp_vres;
 //typedef struct fwp_vres* fwp_vres_d_t;
 
+/* Flags values */
+#define FWP_RELIABLE   1
+#define FWP_BEST_EFFORT 2
+
+
 #endif /* _FWP_TYPES */
index 884bf1b4be661aa6e0f6dc2c3e4b72a24c0ac3c6..8d1c721283afa19fc7588e78dd61891ddf798fa8 100644 (file)
@@ -21,6 +21,7 @@ struct fwp_vres{
        /* consideration: move tx_queue to endpoint */
        /**< queue for messages to send */
        struct fwp_msgq                 tx_queue;   
+       int                             flags;
        /**< endpoint bounded to this vres */
        fwp_endpoint_d_t                epointd;   
        pthread_t                       tx_thread; /**< tx_thread id*/
@@ -156,7 +157,6 @@ int fwp_vres_create(fwp_vres_params_t *params, fwp_vres_d_t *vresdp)
 
        vres = fwp_vres_alloc();
        if (!vres) {
-               FWP_DEBUG("OK");
                return -ENOMEM;
        }
        /* copy vres paramters into vres structure */
@@ -291,6 +291,7 @@ int _fwp_vres_send(fwp_vres_d_t vresd, struct fwp_msgb* msgb)
 {
        fwp_vres_t *vres = vresd;
 
+       /* test flags to check whether to send reliably*/
        if (vres->status != FWP_VRES_INACTIVE) {
                return fwp_msgq_enqueue(&vres->tx_queue, msgb);
        } else