1 |
pcg |
1.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
29 |
|
|
*/ |
30 |
|
|
#ifndef _D_UTIL_H |
31 |
|
|
#define _D_UTIL_H |
32 |
|
|
|
33 |
|
|
#include <linux/ip.h> |
34 |
|
|
#include <linux/udp.h> |
35 |
|
|
#include "rohc.h" |
36 |
|
|
|
37 |
|
|
#define OLD_REF_VALUE 0 |
38 |
|
|
#define LAST_REF_VALUE 1 |
39 |
|
|
|
40 |
|
|
// IP-id struct |
41 |
|
|
struct sd_ip_id_decode |
42 |
|
|
{ |
43 |
|
|
int id_ref; |
44 |
|
|
int sn_ref; |
45 |
|
|
}; |
46 |
|
|
|
47 |
|
|
// Least Significant Bits decoding |
48 |
|
|
struct sd_lsb_decode |
49 |
|
|
{ |
50 |
|
|
int v_ref_d; |
51 |
|
|
int old_v_ref_d; |
52 |
|
|
int p; |
53 |
|
|
}; |
54 |
|
|
// initiate the ip-id struct |
55 |
|
|
// in: the ip-id struct, the reference for ip-id, the sequenze number |
56 |
|
|
void d_ip_id_init(struct sd_ip_id_decode * s,int id_ref, int sn_ref); |
57 |
|
|
|
58 |
|
|
// Decode the ip-id offset in packet m and return the ip_id |
59 |
|
|
// Do not forget to update the id_ref and sn_ref after a crc-success |
60 |
|
|
// in: the ip-id struct, the packet m containing the ip-id offset, the |
61 |
|
|
// length of the offset and the sequence number of packet m. |
62 |
|
|
// out:ip_id |
63 |
|
|
int d_ip_id_decode(struct sd_ip_id_decode * s, int m, int length, int sn); |
64 |
|
|
|
65 |
|
|
// update the reference values for the ip-id and the sequence number |
66 |
|
|
void d_ip_id_update(struct sd_ip_id_decode * s, int id_ref, int sn_ref); |
67 |
|
|
|
68 |
|
|
// update the reference value |
69 |
|
|
void d_lsb_update(struct sd_lsb_decode * s, int v_ref_d); |
70 |
|
|
|
71 |
|
|
// copy the value in v_ref_d to old_v_ref_d |
72 |
|
|
void d_lsb_sync_ref(struct sd_lsb_decode * s); |
73 |
|
|
|
74 |
|
|
// get the old value of v_ref_d |
75 |
|
|
int d_get_lsb_old_ref(struct sd_lsb_decode * s); |
76 |
|
|
|
77 |
|
|
// Decode a LSB-value, do not forget to update the v_ref_d after a CRC-success |
78 |
|
|
// in: the struct were the old received value is present |
79 |
|
|
// the LSB-value to decode and the length of it in bits |
80 |
|
|
// |
81 |
|
|
// out:the decoded value |
82 |
|
|
int d_lsb_decode(struct sd_lsb_decode * s, int m,int length); |
83 |
|
|
|
84 |
|
|
// Initiate the lsb struct |
85 |
|
|
// in: the value of v_ref_d and type of p value |
86 |
|
|
void d_lsb_init(struct sd_lsb_decode * s,int v_ref_d, int p); |
87 |
|
|
|
88 |
|
|
// get the reference value |
89 |
|
|
int d_get_lsb_ref(struct sd_lsb_decode * s); |
90 |
|
|
|
91 |
|
|
// Decide if the field is a padding field |
92 |
|
|
// Return: 1 = padding |
93 |
|
|
// 0 = else |
94 |
|
|
int d_is_paddning(const unsigned char *); |
95 |
|
|
|
96 |
|
|
// Decide if the field is a feedback field |
97 |
|
|
// Return: 1 = feedback header |
98 |
|
|
// 0 = else |
99 |
|
|
int d_is_feedback(const unsigned char *); |
100 |
|
|
|
101 |
|
|
// Decide if the field is a segment field |
102 |
|
|
// Return: 1 = segment |
103 |
|
|
// 0 = else |
104 |
|
|
int d_is_segment(const unsigned char *); |
105 |
|
|
|
106 |
|
|
// Return the size of the feedback |
107 |
|
|
// In: Bytes of a feedback header |
108 |
|
|
// Out: Size |
109 |
|
|
int d_feedback_size(const unsigned char *); |
110 |
|
|
|
111 |
|
|
// Decide how many bytes the feedback header is |
112 |
|
|
// In: Bytes of a feedback header |
113 |
|
|
// Out: the size in bytes (1-2) |
114 |
|
|
int d_feedback_headersize(const unsigned char *); |
115 |
|
|
|
116 |
|
|
// Check if a byte is a add-cid value |
117 |
|
|
// It is also possible to use d_decode_add_cid instead. |
118 |
|
|
// In: Bytes |
119 |
|
|
// Out: 1 = Add-cid value |
120 |
|
|
// 0 = else |
121 |
|
|
int d_is_add_cid(const unsigned char *); |
122 |
|
|
|
123 |
|
|
// Decode the add-cid value |
124 |
|
|
// In: Bytes |
125 |
|
|
// Out: 1-15, cid value |
126 |
|
|
// 0, no cid value |
127 |
|
|
int d_decode_add_cid(const unsigned char *); |
128 |
|
|
|
129 |
|
|
// Decide if a byte is a ir-field |
130 |
|
|
// In: Bytes |
131 |
|
|
// Out: 1 = IR, 0 = else |
132 |
|
|
int d_is_ir(const unsigned char *); |
133 |
|
|
|
134 |
|
|
// Decide if a byte is a irdyn-field |
135 |
|
|
// In: Bytes |
136 |
|
|
// Out: 1 = IR-Dyn, 0 = else |
137 |
|
|
int d_is_irdyn(const unsigned char *); |
138 |
|
|
|
139 |
|
|
// Decide the size of the self-decsribing variable-length value |
140 |
|
|
// In: Bytes |
141 |
|
|
// Out: 1-4 |
142 |
|
|
int d_sdvalue_size(const unsigned char *); |
143 |
|
|
|
144 |
|
|
// Decode a self-describing variable-length value |
145 |
|
|
// In: Bytes |
146 |
|
|
// Out: The self-describing variable-length value |
147 |
|
|
int d_sdvalue_decode(const unsigned char *); |
148 |
|
|
|
149 |
|
|
// Decode the static part of a ipv4 rohc packet and store it in a ip-structure |
150 |
|
|
// Return the number of used bytes |
151 |
|
|
int d_decode_static_ip4(const unsigned char *, struct iphdr * dest); |
152 |
|
|
|
153 |
|
|
// Decode the static part in a udp rohc packet and store it in a udp-structure |
154 |
|
|
// Return the number of used bytes |
155 |
|
|
int d_decode_static_udp(const unsigned char *, struct udphdr * dest); |
156 |
|
|
|
157 |
|
|
// Decode the dynamic part in a ipv4 rohc packet and store it in a ip-structure |
158 |
|
|
// Return the number of used bytes |
159 |
|
|
int d_decode_dynamic_ip4(const unsigned char *, struct iphdr * dest, int * rnd, int * nbo); |
160 |
|
|
|
161 |
|
|
// Decode the dynamic part in a udp rohc packet and store it in a udp-structure |
162 |
|
|
// Return the number of used bytes |
163 |
|
|
int d_decode_dynamic_udp(const unsigned char *, struct udphdr * dest); |
164 |
|
|
|
165 |
|
|
// Decode the dynamic part in a udp-lite rohc packet and store it in a udp-structure |
166 |
|
|
// Return the number of used bytes |
167 |
|
|
int d_decode_dynamic_udp_lite(const unsigned char *data, struct udphdr * dest); |
168 |
|
|
|
169 |
|
|
#endif |
170 |
|
|
|
171 |
|
|
|
172 |
|
|
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
|
178 |
|
|
|
179 |
|
|
|