Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: crypto/include/rdbx.h

Issue 2344973002: Update libsrtp to version 2.0 (Closed)
Patch Set: Add '.' back to include_dirs Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « crypto/include/rdb.h ('k') | crypto/include/stat.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * rdbx.h 2 * rdbx.h
3 * 3 *
4 * replay database with extended packet indices, using a rollover counter 4 * replay database with extended packet indices, using a rollover counter
5 * 5 *
6 * David A. McGrew 6 * David A. McGrew
7 * Cisco Systems, Inc. 7 * Cisco Systems, Inc.
8 * 8 *
9 */ 9 */
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 * OF THE POSSIBILITY OF SUCH DAMAGE. 43 * OF THE POSSIBILITY OF SUCH DAMAGE.
44 * 44 *
45 */ 45 */
46 46
47 #ifndef RDBX_H 47 #ifndef RDBX_H
48 #define RDBX_H 48 #define RDBX_H
49 49
50 #include "datatypes.h" 50 #include "datatypes.h"
51 #include "err.h" 51 #include "err.h"
52 52
53 /** 53 #ifdef __cplusplus
54 * Compatibility shim for v1->v2 transition. 54 extern "C" {
55 */ 55 #endif
56 56
57 #define srtp_rdbx_get_packet_index rdbx_get_packet_index 57 /* #define ROC_TEST */
58
59 /* #define ROC_TEST */
60 58
61 #ifndef ROC_TEST 59 #ifndef ROC_TEST
62 60
63 typedef uint16_t sequence_number_t; /* 16 bit sequence number */ 61 typedef uint16_t srtp_sequence_number_t; /* 16 bit sequence number */
64 typedef uint32_t rollover_counter_t; /* 32 bit rollover counter */ 62 typedef uint32_t srtp_rollover_counter_t; /* 32 bit rollover counter */
65 63
66 #else /* use small seq_num and roc datatypes for testing purposes */ 64 #else /* use small seq_num and roc datatypes for testing purposes */
67 65
68 typedef unsigned char sequence_number_t; /* 8 bit sequence number */ 66 typedef unsigned char srtp_sequence_number_t; /* 8 bit sequence number */
69 typedef uint16_t rollover_counter_t; /* 16 bit rollover counter */ 67 typedef uint16_t srtp_rollover_counter_t; /* 16 bit rollover counter */
70 68
71 #endif 69 #endif
72 70
73 #define seq_num_median (1 << (8*sizeof(sequence_number_t) - 1)) 71 #define seq_num_median (1 << (8 * sizeof(srtp_sequence_number_t) - 1))
74 #define seq_num_max (1 << (8*sizeof(sequence_number_t))) 72 #define seq_num_max (1 << (8 * sizeof(srtp_sequence_number_t)))
75 73
76 /* 74 /*
77 * An xtd_seq_num_t is a 64-bit unsigned integer used as an 'extended' 75 * An rtp_xtd_seq_num_t is a 64-bit unsigned integer used as an 'extended'
78 * sequence number. 76 * sequence number.
79 */ 77 */
80 78 typedef uint64_t srtp_xtd_seq_num_t;
81 typedef uint64_t xtd_seq_num_t;
82 79
83 80
84 /* 81 /*
85 * An rdbx_t is a replay database with extended range; it uses an 82 * An srtp_rdbx_t is a replay database with extended range; it uses an
86 * xtd_seq_num_t and a bitmask of recently received indices. 83 * xtd_seq_num_t and a bitmask of recently received indices.
87 */ 84 */
88
89 typedef struct { 85 typedef struct {
90 xtd_seq_num_t index; 86 srtp_xtd_seq_num_t index;
91 bitvector_t bitmask; 87 bitvector_t bitmask;
92 } rdbx_t; 88 } srtp_rdbx_t;
93 89
94 90
95 /* 91 /*
96 * rdbx_init(rdbx_ptr, ws) 92 * srtp_rdbx_init(rdbx_ptr, ws)
97 * 93 *
98 * initializes the rdbx pointed to by its argument with the window size ws, 94 * initializes the rdbx pointed to by its argument with the window size ws,
99 * setting the rollover counter and sequence number to zero 95 * setting the rollover counter and sequence number to zero
100 */ 96 */
101 97 srtp_err_status_t srtp_rdbx_init(srtp_rdbx_t *rdbx, unsigned long ws);
102 err_status_t
103 rdbx_init(rdbx_t *rdbx, unsigned long ws);
104 98
105 99
106 /* 100 /*
107 * rdbx_dealloc(rdbx_ptr) 101 * srtp_rdbx_dealloc(rdbx_ptr)
108 * 102 *
109 * frees memory associated with the rdbx 103 * frees memory associated with the rdbx
110 */ 104 */
111 105 srtp_err_status_t srtp_rdbx_dealloc(srtp_rdbx_t *rdbx);
112 err_status_t
113 rdbx_dealloc(rdbx_t *rdbx);
114 106
115 107
116 /* 108 /*
117 * rdbx_estimate_index(rdbx, guess, s) 109 * srtp_rdbx_estimate_index(rdbx, guess, s)
118 * 110 *
119 * given an rdbx and a sequence number s (from a newly arrived packet), 111 * given an rdbx and a sequence number s (from a newly arrived packet),
120 * sets the contents of *guess to contain the best guess of the packet 112 * sets the contents of *guess to contain the best guess of the packet
121 * index to which s corresponds, and returns the difference between 113 * index to which s corresponds, and returns the difference between
122 * *guess and the locally stored synch info 114 * *guess and the locally stored synch info
123 */ 115 */
124 116 int srtp_rdbx_estimate_index(const srtp_rdbx_t *rdbx, srtp_xtd_seq_num_t *guess, srtp_sequence_number_t s);
125 int
126 rdbx_estimate_index(const rdbx_t *rdbx,
127 » » xtd_seq_num_t *guess,
128 » » sequence_number_t s);
129 117
130 /* 118 /*
131 * rdbx_check(rdbx, delta); 119 * srtp_rdbx_check(rdbx, delta);
132 * 120 *
133 * rdbx_check(&r, delta) checks to see if the xtd_seq_num_t 121 * srtp_rdbx_check(&r, delta) checks to see if the xtd_seq_num_t
134 * which is at rdbx->window_start + delta is in the rdb 122 * which is at rdbx->window_start + delta is in the rdb
135 * 123 *
136 */ 124 */
137 125 srtp_err_status_t srtp_rdbx_check(const srtp_rdbx_t *rdbx, int difference);
138 err_status_t
139 rdbx_check(const rdbx_t *rdbx, int difference);
140 126
141 /* 127 /*
142 * replay_add_index(rdbx, delta) 128 * srtp_replay_add_index(rdbx, delta)
143 * 129 *
144 * adds the xtd_seq_num_t at rdbx->window_start + delta to replay_db 130 * adds the srtp_xtd_seq_num_t at rdbx->window_start + delta to replay_db
145 * (and does *not* check if that xtd_seq_num_t appears in db) 131 * (and does *not* check if that xtd_seq_num_t appears in db)
146 * 132 *
147 * this function should be called *only* after replay_check has 133 * this function should be called *only* after replay_check has
148 * indicated that the index does not appear in the rdbx, and a mutex 134 * indicated that the index does not appear in the rdbx, and a mutex
149 * should protect the rdbx between these calls if necessary. 135 * should protect the rdbx between these calls if necessary.
150 */ 136 */
151 137 srtp_err_status_t srtp_rdbx_add_index(srtp_rdbx_t *rdbx, int delta);
152 err_status_t
153 rdbx_add_index(rdbx_t *rdbx, int delta);
154 138
155 139
156 /* 140 /*
157 * rdbx_set_roc(rdbx, roc) initalizes the rdbx_t at the location rdbx 141 * srtp_rdbx_set_roc(rdbx, roc) initalizes the srtp_rdbx_t at the location rdbx
158 * to have the rollover counter value roc. If that value is less than 142 * to have the rollover counter value roc. If that value is less than
159 * the current rollover counter value, then the function returns 143 * the current rollover counter value, then the function returns
160 * err_status_replay_old; otherwise, err_status_ok is returned. 144 * srtp_err_status_replay_old; otherwise, srtp_err_status_ok is returned.
161 * 145 *
162 */ 146 */
163 147 srtp_err_status_t srtp_rdbx_set_roc(srtp_rdbx_t *rdbx, uint32_t roc);
164 err_status_t
165 rdbx_set_roc(rdbx_t *rdbx, uint32_t roc);
166 148
167 /* 149 /*
168 * rdbx_get_roc(rdbx) returns the value of the rollover counter for 150 * srtp_rdbx_get_roc(rdbx) returns the value of the rollover counter for
169 * the rdbx_t pointed to by rdbx 151 * the srtp_rdbx_t pointed to by rdbx
170 * 152 *
171 */ 153 */
172 154 srtp_xtd_seq_num_t srtp_rdbx_get_packet_index(const srtp_rdbx_t *rdbx);
173 xtd_seq_num_t
174 rdbx_get_packet_index(const rdbx_t *rdbx);
175 155
176 /* 156 /*
177 * xtd_seq_num_t functions - these are *internal* functions of rdbx, and 157 * srtp_xtd_seq_num_t functions - these are *internal* functions of rdbx, and
178 * shouldn't be used to manipulate rdbx internal values. use the rdbx 158 * shouldn't be used to manipulate rdbx internal values. use the rdbx
179 * api instead! 159 * api instead!
180 */ 160 */
181 161
182 /* 162 /*
183 * rdbx_get_ws(rdbx_ptr) 163 * srtp_rdbx_get_ws(rdbx_ptr)
184 * 164 *
185 * gets the window size which was used to initialize the rdbx 165 * gets the window size which was used to initialize the rdbx
186 */ 166 */
187 167 unsigned long srtp_rdbx_get_window_size(const srtp_rdbx_t *rdbx);
188 unsigned long
189 rdbx_get_window_size(const rdbx_t *rdbx);
190 168
191 169
192 /* index_init(&pi) initializes a packet index pi (sets it to zero) */ 170 /* index_init(&pi) initializes a packet index pi (sets it to zero) */
193 171 void srtp_index_init(srtp_xtd_seq_num_t *pi);
194 void
195 index_init(xtd_seq_num_t *pi);
196 172
197 /* index_advance(&pi, s) advances a xtd_seq_num_t forward by s */ 173 /* index_advance(&pi, s) advances a xtd_seq_num_t forward by s */
198 174 void srtp_index_advance(srtp_xtd_seq_num_t *pi, srtp_sequence_number_t s);
199 void
200 index_advance(xtd_seq_num_t *pi, sequence_number_t s);
201 175
202 176
203 /* 177 /*
204 * index_guess(local, guess, s) 178 * srtp_index_guess(local, guess, s)
205 * 179 *
206 * given a xtd_seq_num_t local (which represents the highest 180 * given a srtp_xtd_seq_num_t local (which represents the highest
207 * known-to-be-good index) and a sequence number s (from a newly 181 * known-to-be-good index) and a sequence number s (from a newly
208 * arrived packet), sets the contents of *guess to contain the best 182 * arrived packet), sets the contents of *guess to contain the best
209 * guess of the packet index to which s corresponds, and returns the 183 * guess of the packet index to which s corresponds, and returns the
210 * difference between *guess and *local 184 * difference between *guess and *local
211 */ 185 */
212 186 int srtp_index_guess(const srtp_xtd_seq_num_t *local, srtp_xtd_seq_num_t *guess, srtp_sequence_number_t s);
213 int
214 index_guess(const xtd_seq_num_t *local,
215 » » xtd_seq_num_t *guess,
216 » » sequence_number_t s);
217 187
218 188
189 #ifdef __cplusplus
190 }
191 #endif
192
219 #endif /* RDBX_H */ 193 #endif /* RDBX_H */
220
221
222
223
224
225
226
227
228
OLDNEW
« no previous file with comments | « crypto/include/rdb.h ('k') | crypto/include/stat.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698