00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef ROHC_COMMON_LIST_H
00027 #define ROHC_COMMON_LIST_H
00028
00029 #include "protocols/ipv6.h"
00030 #include "protocols/ip_numbers.h"
00031
00032 #include <stdlib.h>
00033
00034
00035
00036 #define ROHC_LIST_MAX_ITEM 16U
00037 #if ROHC_LIST_MAX_ITEM <= 7
00038 # error "translation table must be larger enough for indexes stored on 3 bits"
00039 #endif
00040
00041
00042
00043 typedef enum
00044 {
00045 HBH = ROHC_IPPROTO_HOPOPTS,
00046 RTHDR = ROHC_IPPROTO_ROUTING,
00047 AH = ROHC_IPPROTO_AH,
00048 DEST = ROHC_IPPROTO_DSTOPTS,
00049
00050 } ext_header_version;
00051
00052
00053
00054 #define ROHC_LIST_GEN_ID_MAX 0xffU
00055 #define ROHC_LIST_GEN_ID_ANON (ROHC_LIST_GEN_ID_MAX + 1)
00056 #define ROHC_LIST_GEN_ID_NONE (ROHC_LIST_GEN_ID_MAX + 2)
00057
00058
00059
00060
00061
00062 struct rohc_list
00063 {
00064
00065 unsigned int id;
00066
00067 #define ROHC_LIST_ITEMS_MAX 15U
00068
00069 struct rohc_list_item *items[ROHC_LIST_ITEMS_MAX];
00070
00071 size_t items_nr;
00072
00073 size_t counter;
00074 };
00075
00076
00077
00078
00079
00080 struct rohc_list_item
00081 {
00082
00083 ext_header_version type;
00084
00085
00086 bool known;
00087
00088 size_t counter;
00089
00090
00091
00092
00093
00094
00095
00096 #define ROHC_LIST_ITEM_DATA_MAX 2048U
00097
00098
00099 size_t length;
00100
00101 uint8_t data[ROHC_LIST_ITEM_DATA_MAX];
00102 };
00103
00104
00105
00106 typedef bool (*rohc_list_item_cmp) (const struct rohc_list_item *const item,
00107 const uint8_t ext_type,
00108 const uint8_t *const ext_data,
00109 const size_t ext_len)
00110 __attribute__((warn_unused_result, nonnull(1, 3)));
00111
00112
00113
00114
00115
00116
00117
00118 void rohc_list_reset(struct rohc_list *const list)
00119 __attribute__((nonnull(1)));
00120
00121 bool rohc_list_equal(const struct rohc_list *const list1,
00122 const struct rohc_list *const list2)
00123 __attribute__((warn_unused_result, nonnull(1, 2), pure));
00124
00125 bool rohc_list_supersede(const struct rohc_list *const large,
00126 const struct rohc_list *const small)
00127 __attribute__((warn_unused_result, nonnull(1, 2), pure));
00128
00129 void rohc_list_item_reset(struct rohc_list_item *const list_item)
00130 __attribute__((nonnull(1)));
00131
00132 int rohc_list_item_update_if_changed(rohc_list_item_cmp cmp_item,
00133 struct rohc_list_item *const list_item,
00134 const uint8_t item_type,
00135 const uint8_t *const item_data,
00136 const size_t item_len)
00137 __attribute__((warn_unused_result, nonnull(2, 4)));
00138
00139 #endif
00140