ROHC compression/decompression library
comp_list.h
Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 2 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * This program is distributed in the hope that it will be useful,
00008  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00009  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010  * GNU General Public License for more details.
00011  *
00012  * You should have received a copy of the GNU General Public License
00013  * along with this program; if not, write to the Free Software
00014  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00015  */
00016 
00017 /**
00018  * @file comp_list.h
00019  * @brief Define list compression with its function
00020  * @author Emmanuelle Pechereau <epechereau@toulouse.viveris.com>
00021  */
00022 
00023 #ifndef COMP_LIST_H
00024 #define COMP_LIST_H
00025 
00026 #include <netinet/ip6.h>
00027 
00028 
00029 /// Header version
00030 typedef enum
00031 {
00032         /// Hop by hop header
00033         HBH = 0,
00034         /// Destination header
00035         DEST = 60,
00036         /// Routing header
00037         RTHDR = 43,
00038         /// AH header
00039         AH = 51,
00040 #if 0 /* CSRC lists not supported yet */
00041         /// CSRC
00042         CSRC = 10,
00043 #endif
00044 } ext_header_version;
00045 
00046 
00047 /**
00048  * @brief A list item
00049  */
00050 struct rohc_list_item
00051 {
00052         /// item type
00053         ext_header_version type;
00054         /// size of the data in bytes
00055         size_t length;
00056         /// item data
00057         unsigned char *data;
00058 };
00059 
00060 
00061 /**
00062  * @brief Define a generic element in a compression list
00063  */
00064 struct list_elt
00065 {
00066         /// element
00067         struct rohc_list_item *item;
00068         /// index
00069         int index_table;
00070         /// next element of the list
00071         struct list_elt *next_elt;
00072         /// previous element
00073         struct list_elt *prev_elt;
00074 };
00075 
00076 
00077 /**
00078  * @brief Define a list for compression
00079  */
00080 struct c_list
00081 {
00082         ///generation identifier
00083         int gen_id;
00084         /// first element of the list
00085         struct list_elt *first_elt;
00086 };
00087 
00088 
00089 /**
00090  * @brief Define a compression translation table element
00091  */
00092 struct c_translation
00093 {
00094         /// flag which indicates the mapping between an item with its index
00095         /// 1 if the mapping is established, 0 if not
00096         int known;
00097         /// item
00098         struct rohc_list_item *item;
00099         /// counter
00100         int counter;
00101 };
00102 
00103 
00104 /**
00105  * @brief Define a decompression translation table element
00106  */
00107 struct d_translation
00108 {
00109         /// flag which indicates the mapping between an item with its index
00110         /// 1 if the mapping is established, 0 if not
00111         int known;
00112         /// item
00113         struct rohc_list_item *item;
00114 };
00115 
00116 
00117 /**
00118  * Functions prototypes
00119  */
00120 
00121 int create_list(struct c_list *list);
00122 int add_elt(struct c_list *list, struct rohc_list_item *item, int index);
00123 int push_back(struct c_list *list, struct rohc_list_item *item, int index);
00124 void delete_elt(struct c_list *list, struct rohc_list_item *item);
00125 struct list_elt * get_elt(struct c_list *list, int index);
00126 int elt_index(struct c_list *list, struct rohc_list_item *item);
00127 int type_is_present(struct c_list *list, struct rohc_list_item *item);
00128 void destroy_list(struct c_list *list);
00129 int insert_elt(struct c_list *list, struct rohc_list_item *item, int index, int index_table);
00130 size_t size_list(const struct c_list *const list);
00131 void empty_list(struct c_list *list);
00132 
00133 #endif
00134