1 |
/* |
2 |
ROHC Project 2003 at Lulea University of Technology, Sweden. |
3 |
Authors: Andreas Vernersson <andver-8@student.luth.se> |
4 |
Daniel Pettersson <danpet-7@student.luth.se> |
5 |
Erik Soderstrom <soderstrom@yahoo.com> |
6 |
Fredrik Lindstrom <frelin-9@student.luth.se> |
7 |
Johan Stenmark <johste-8@student.luth.se> |
8 |
Martin Juhlin <juhlin@users.sourceforge.net> |
9 |
Mikael Larsson <larmik-9@student.luth.se> |
10 |
Robert Maxe <robmax-1@student.luth.se> |
11 |
|
12 |
Copyright (C) 2003 Andreas Vernersson, Daniel Pettersson, |
13 |
Erik Soderström, Fredrik Lindström, Johan Stenmark, |
14 |
Martin Juhlin, Mikael Larsson, Robert Maxe. |
15 |
|
16 |
This program is free software; you can redistribute it and/or modify |
17 |
it under the terms of the GNU General Public License as published by |
18 |
the Free Software Foundation; either version 2 of the License, or |
19 |
(at your option) any later version. |
20 |
|
21 |
This program is distributed in the hope that it will be useful, |
22 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
24 |
GNU General Public License for more details. |
25 |
|
26 |
You should have received a copy of the GNU General Public License |
27 |
along with this program; if not, write to the Free Software |
28 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
29 |
*/ |
30 |
#ifndef _D_UTIL_H |
31 |
#define _D_UTIL_H |
32 |
|
33 |
#include "rohc.h" |
34 |
|
35 |
#define OLD_REF_VALUE 0 |
36 |
#define LAST_REF_VALUE 1 |
37 |
|
38 |
// IP-id struct |
39 |
struct sd_ip_id_decode |
40 |
{ |
41 |
int id_ref; |
42 |
int sn_ref; |
43 |
}; |
44 |
|
45 |
// Least Significant Bits decoding |
46 |
struct sd_lsb_decode |
47 |
{ |
48 |
int v_ref_d; |
49 |
int old_v_ref_d; |
50 |
int p; |
51 |
}; |
52 |
// initiate the ip-id struct |
53 |
// in: the ip-id struct, the reference for ip-id, the sequenze number |
54 |
void d_ip_id_init(struct sd_ip_id_decode * s,int id_ref, int sn_ref); |
55 |
|
56 |
// Decode the ip-id offset in packet m and return the ip_id |
57 |
// Do not forget to update the id_ref and sn_ref after a crc-success |
58 |
// in: the ip-id struct, the packet m containing the ip-id offset, the |
59 |
// length of the offset and the sequence number of packet m. |
60 |
// out:ip_id |
61 |
int d_ip_id_decode(struct sd_ip_id_decode * s, int m, int length, int sn); |
62 |
|
63 |
// update the reference values for the ip-id and the sequence number |
64 |
void d_ip_id_update(struct sd_ip_id_decode * s, int id_ref, int sn_ref); |
65 |
|
66 |
// update the reference value |
67 |
void d_lsb_update(struct sd_lsb_decode * s, int v_ref_d); |
68 |
|
69 |
// copy the value in v_ref_d to old_v_ref_d |
70 |
void d_lsb_sync_ref(struct sd_lsb_decode * s); |
71 |
|
72 |
// get the old value of v_ref_d |
73 |
int d_get_lsb_old_ref(struct sd_lsb_decode * s); |
74 |
|
75 |
// Decode a LSB-value, do not forget to update the v_ref_d after a CRC-success |
76 |
// in: the struct were the old received value is present |
77 |
// the LSB-value to decode and the length of it in bits |
78 |
// |
79 |
// out:the decoded value |
80 |
int d_lsb_decode(struct sd_lsb_decode * s, int m,int length); |
81 |
|
82 |
// Initiate the lsb struct |
83 |
// in: the value of v_ref_d and type of p value |
84 |
void d_lsb_init(struct sd_lsb_decode * s,int v_ref_d, int p); |
85 |
|
86 |
// get the reference value |
87 |
int d_get_lsb_ref(struct sd_lsb_decode * s); |
88 |
|
89 |
// Decide if the field is a padding field |
90 |
// Return: 1 = padding |
91 |
// 0 = else |
92 |
int d_is_paddning(const unsigned char *); |
93 |
|
94 |
// Decide if the field is a feedback field |
95 |
// Return: 1 = feedback header |
96 |
// 0 = else |
97 |
int d_is_feedback(const unsigned char *); |
98 |
|
99 |
// Decide if the field is a segment field |
100 |
// Return: 1 = segment |
101 |
// 0 = else |
102 |
int d_is_segment(const unsigned char *); |
103 |
|
104 |
// Return the size of the feedback |
105 |
// In: Bytes of a feedback header |
106 |
// Out: Size |
107 |
int d_feedback_size(const unsigned char *); |
108 |
|
109 |
// Decide how many bytes the feedback header is |
110 |
// In: Bytes of a feedback header |
111 |
// Out: the size in bytes (1-2) |
112 |
int d_feedback_headersize(const unsigned char *); |
113 |
|
114 |
// Check if a byte is a add-cid value |
115 |
// It is also possible to use d_decode_add_cid instead. |
116 |
// In: Bytes |
117 |
// Out: 1 = Add-cid value |
118 |
// 0 = else |
119 |
int d_is_add_cid(const unsigned char *); |
120 |
|
121 |
// Decode the add-cid value |
122 |
// In: Bytes |
123 |
// Out: 1-15, cid value |
124 |
// 0, no cid value |
125 |
int d_decode_add_cid(const unsigned char *); |
126 |
|
127 |
// Decide if a byte is a ir-field |
128 |
// In: Bytes |
129 |
// Out: 1 = IR, 0 = else |
130 |
int d_is_ir(const unsigned char *); |
131 |
|
132 |
// Decide if a byte is a irdyn-field |
133 |
// In: Bytes |
134 |
// Out: 1 = IR-Dyn, 0 = else |
135 |
int d_is_irdyn(const unsigned char *); |
136 |
|
137 |
// Decide the size of the self-decsribing variable-length value |
138 |
// In: Bytes |
139 |
// Out: 1-4 |
140 |
int d_sdvalue_size(const unsigned char *); |
141 |
|
142 |
// Decode a self-describing variable-length value |
143 |
// In: Bytes |
144 |
// Out: The self-describing variable-length value |
145 |
int d_sdvalue_decode(const unsigned char *); |
146 |
|
147 |
// Decode the static part of a ipv4 rohc packet and store it in a ip-structure |
148 |
// Return the number of used bytes |
149 |
int d_decode_static_ip4(const unsigned char *, struct iphdr * dest); |
150 |
|
151 |
// Decode the static part in a udp rohc packet and store it in a udp-structure |
152 |
// Return the number of used bytes |
153 |
int d_decode_static_udp(const unsigned char *, struct udphdr * dest); |
154 |
|
155 |
// Decode the dynamic part in a ipv4 rohc packet and store it in a ip-structure |
156 |
// Return the number of used bytes |
157 |
int d_decode_dynamic_ip4(const unsigned char *, struct iphdr * dest, int * rnd, int * nbo); |
158 |
|
159 |
// Decode the dynamic part in a udp rohc packet and store it in a udp-structure |
160 |
// Return the number of used bytes |
161 |
int d_decode_dynamic_udp(const unsigned char *, struct udphdr * dest); |
162 |
|
163 |
// Decode the dynamic part in a udp-lite rohc packet and store it in a udp-structure |
164 |
// Return the number of used bytes |
165 |
int d_decode_dynamic_udp_lite(const unsigned char *data, struct udphdr * dest); |
166 |
|
167 |
#endif |
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 |
|