src/vfer_datagram.h

Go to the documentation of this file.
00001 /*
00002  * Copyright 2005, 2006, Internet2
00003  * Legal conditions are in file LICENSE
00004  * (MD5 = c434f2e53b8089d8b4d0172c7ce07360).
00005  */
00006 /**
00007  *
00008  * @file   vfer_datagram.h
00009  * @author Ivan Beschastnikh
00010  * @brief  Header file for use by datagram.c defines datagrams and datagrams list.
00011  *
00012  * -     02/18/06        ivan            created
00013  */
00014 
00015 #ifndef VFER_DATAGRAM_H
00016 #define VFER_DATAGRAM_H
00017 
00018 /* 
00019  * includes 
00020  */
00021 
00022 #include <sys/uio.h>
00023 #include <stdio.h>
00024 #include <netinet/in.h>
00025 #include <arpa/inet.h>
00026 
00027 /* 
00028  * data types
00029  */
00030 
00031 /* 
00032    longest combination of header and data iovecs for protocol: 
00033    [optional cc_ack header]->[data_header]->[data]
00034 */
00035 #define MAX_VECS        3
00036 
00037 /**
00038  * @brief Frame stats structure used by the context_t structure for functional reliability
00039  */
00040 typedef struct frame_stats {
00041   uint32_t vec_acks;
00042   uint32_t first_frag_time;
00043   uint32_t last_frag_time;
00044   uint32_t frags_complete;
00045   uint32_t frags_incomplete;
00046 } frame_stats;
00047 
00048 /**
00049  * @brief Interval structure to track which intervals have not received any data yet (missing data intervals)
00050  */
00051 typedef struct interval {
00052         uint32_t start;         /* start of interval */
00053         uint32_t end;           /* end of interval */
00054         struct interval* prev;  /* previous list element */
00055         struct interval* next;  /* next list element */
00056 } interval_t;
00057 
00058 /**
00059  * @brief Interval structure to track which intervals have not received any data yet (missing data intervals)
00060  */
00061 typedef struct intervals {
00062         struct interval* head;  /* previous list element */
00063         uint32_t count;         /* number of intervals in the list */
00064 } intervals_t;
00065 
00066 /**
00067  * @brief Frame structure holding fragments, their indicators, and other info
00068  */
00069 typedef struct frame {
00070         void* data;
00071         int len;                 /* total length of frame in bytes (must be <= num_frags * frag_size) */
00072         uint32_t frame_num;      /* frame number/identifier */
00073         intervals_t missing_data; /* interval list of missing data */
00074         char done;               /* a 0 indicates that the frame is not done and 1 indicates that the frame is done and awaits to be moved into the recvd_frames list */
00075         int urgency;             /* urgency of this frame */
00076         frame_stats stats;
00077 } frame;
00078 
00079 /**
00080  * @brief Frame link in a frames linked list
00081  */
00082 typedef struct frame_link {
00083         struct frame frame;
00084         struct frame_link* next;
00085 } frame_link;
00086 
00087 /**
00088  * @brief Frames linked list such as recvd frames, or send frames
00089  */
00090 typedef struct frame_list {
00091         int num;
00092         uint32_t length;        /* total size of bytes enqueued in this frame list */
00093         uint16_t last_frame_num;
00094         uint16_t first_frame_num;
00095         struct frame_link* first;
00096         struct frame_link* last;
00097 } frame_list;
00098 
00099 /* 
00100  * function prototypes
00101  */
00102 
00103 inline int              Datagram_Enqueue        (frame_list* frames, const void* buffer, int len, int frame_num);
00104 inline int              Datagram_Dequeue        (frame_list* frames, void* buffer, int len);
00105 inline void             Datagram_Remove         (frame_list* list, frame_link* prev, frame_link* remove);
00106 inline void             Datagram_Insert         (frame_list* list, frame_link* prev, frame_link* insert);
00107 inline frame_link*      Datagram_Insert_Phantom (frame_list* list, frame_link* prev, int frame_num);
00108 void                    Datagrams_Print         (frame_list* list);
00109 inline void             Datagrams_Clear         (frame_list* list);
00110 
00111 #endif /* VFER_DATAGRAM_H */

Generated on Tue Aug 8 16:07:19 2006 for VFER by  doxygen 1.4.7