aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Engelhardt <jengelh@computergmbh.de>2008-01-31 07:43:53 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-31 22:28:01 -0500
commit1f807d6eb3f1e99fe6ff9ce3e12f1fbbc0a2f5c5 (patch)
treed280af4a071c727c60de1d46ab1ae0e00c3d8d2a
parent02502f6224ba7735182a83e2a6b4cd5e69278d6d (diff)
[NETFILTER]: nf_conntrack_h323: clean up code a bit
-total: 81 errors, 3 warnings, 876 lines checked +total: 44 errors, 3 warnings, 876 lines checked There is still work to be done, but that's for another patch. Signed-off-by: Jan Engelhardt <jengelh@computergmbh.de> Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/netfilter/nf_conntrack_h323_asn1.c128
1 files changed, 64 insertions, 64 deletions
diff --git a/net/netfilter/nf_conntrack_h323_asn1.c b/net/netfilter/nf_conntrack_h323_asn1.c
index f73e13041b5a..ef02262e60b0 100644
--- a/net/netfilter/nf_conntrack_h323_asn1.c
+++ b/net/netfilter/nf_conntrack_h323_asn1.c
@@ -96,7 +96,7 @@ typedef struct {
96 unsigned char *beg; 96 unsigned char *beg;
97 unsigned char *end; 97 unsigned char *end;
98 unsigned char *cur; 98 unsigned char *cur;
99 unsigned bit; 99 unsigned int bit;
100} bitstr_t; 100} bitstr_t;
101 101
102/* Tool Functions */ 102/* Tool Functions */
@@ -104,28 +104,28 @@ typedef struct {
104#define INC_BITS(bs,b) if(((bs)->bit+=(b))>7){(bs)->cur+=(bs)->bit>>3;(bs)->bit&=7;} 104#define INC_BITS(bs,b) if(((bs)->bit+=(b))>7){(bs)->cur+=(bs)->bit>>3;(bs)->bit&=7;}
105#define BYTE_ALIGN(bs) if((bs)->bit){(bs)->cur++;(bs)->bit=0;} 105#define BYTE_ALIGN(bs) if((bs)->bit){(bs)->cur++;(bs)->bit=0;}
106#define CHECK_BOUND(bs,n) if((bs)->cur+(n)>(bs)->end)return(H323_ERROR_BOUND) 106#define CHECK_BOUND(bs,n) if((bs)->cur+(n)>(bs)->end)return(H323_ERROR_BOUND)
107static unsigned get_len(bitstr_t * bs); 107static unsigned int get_len(bitstr_t *bs);
108static unsigned get_bit(bitstr_t * bs); 108static unsigned int get_bit(bitstr_t *bs);
109static unsigned get_bits(bitstr_t * bs, unsigned b); 109static unsigned int get_bits(bitstr_t *bs, unsigned int b);
110static unsigned get_bitmap(bitstr_t * bs, unsigned b); 110static unsigned int get_bitmap(bitstr_t *bs, unsigned int b);
111static unsigned get_uint(bitstr_t * bs, int b); 111static unsigned int get_uint(bitstr_t *bs, int b);
112 112
113/* Decoder Functions */ 113/* Decoder Functions */
114static int decode_nul(bitstr_t * bs, field_t * f, char *base, int level); 114static int decode_nul(bitstr_t *bs, field_t *f, char *base, int level);
115static int decode_bool(bitstr_t * bs, field_t * f, char *base, int level); 115static int decode_bool(bitstr_t *bs, field_t *f, char *base, int level);
116static int decode_oid(bitstr_t * bs, field_t * f, char *base, int level); 116static int decode_oid(bitstr_t *bs, field_t *f, char *base, int level);
117static int decode_int(bitstr_t * bs, field_t * f, char *base, int level); 117static int decode_int(bitstr_t *bs, field_t *f, char *base, int level);
118static int decode_enum(bitstr_t * bs, field_t * f, char *base, int level); 118static int decode_enum(bitstr_t *bs, field_t *f, char *base, int level);
119static int decode_bitstr(bitstr_t * bs, field_t * f, char *base, int level); 119static int decode_bitstr(bitstr_t *bs, field_t *f, char *base, int level);
120static int decode_numstr(bitstr_t * bs, field_t * f, char *base, int level); 120static int decode_numstr(bitstr_t *bs, field_t *f, char *base, int level);
121static int decode_octstr(bitstr_t * bs, field_t * f, char *base, int level); 121static int decode_octstr(bitstr_t *bs, field_t *f, char *base, int level);
122static int decode_bmpstr(bitstr_t * bs, field_t * f, char *base, int level); 122static int decode_bmpstr(bitstr_t *bs, field_t *f, char *base, int level);
123static int decode_seq(bitstr_t * bs, field_t * f, char *base, int level); 123static int decode_seq(bitstr_t *bs, field_t *f, char *base, int level);
124static int decode_seqof(bitstr_t * bs, field_t * f, char *base, int level); 124static int decode_seqof(bitstr_t *bs, field_t *f, char *base, int level);
125static int decode_choice(bitstr_t * bs, field_t * f, char *base, int level); 125static int decode_choice(bitstr_t *bs, field_t *f, char *base, int level);
126 126
127/* Decoder Functions Vector */ 127/* Decoder Functions Vector */
128typedef int (*decoder_t) (bitstr_t *, field_t *, char *, int); 128typedef int (*decoder_t)(bitstr_t *, field_t *, char *, int);
129static const decoder_t Decoders[] = { 129static const decoder_t Decoders[] = {
130 decode_nul, 130 decode_nul,
131 decode_bool, 131 decode_bool,
@@ -150,9 +150,9 @@ static const decoder_t Decoders[] = {
150 * Functions 150 * Functions
151 ****************************************************************************/ 151 ****************************************************************************/
152/* Assume bs is aligned && v < 16384 */ 152/* Assume bs is aligned && v < 16384 */
153static unsigned get_len(bitstr_t * bs) 153static unsigned int get_len(bitstr_t *bs)
154{ 154{
155 unsigned v; 155 unsigned int v;
156 156
157 v = *bs->cur++; 157 v = *bs->cur++;
158 158
@@ -166,9 +166,9 @@ static unsigned get_len(bitstr_t * bs)
166} 166}
167 167
168/****************************************************************************/ 168/****************************************************************************/
169static unsigned get_bit(bitstr_t * bs) 169static unsigned int get_bit(bitstr_t *bs)
170{ 170{
171 unsigned b = (*bs->cur) & (0x80 >> bs->bit); 171 unsigned int b = (*bs->cur) & (0x80 >> bs->bit);
172 172
173 INC_BIT(bs); 173 INC_BIT(bs);
174 174
@@ -177,9 +177,9 @@ static unsigned get_bit(bitstr_t * bs)
177 177
178/****************************************************************************/ 178/****************************************************************************/
179/* Assume b <= 8 */ 179/* Assume b <= 8 */
180static unsigned get_bits(bitstr_t * bs, unsigned b) 180static unsigned int get_bits(bitstr_t *bs, unsigned int b)
181{ 181{
182 unsigned v, l; 182 unsigned int v, l;
183 183
184 v = (*bs->cur) & (0xffU >> bs->bit); 184 v = (*bs->cur) & (0xffU >> bs->bit);
185 l = b + bs->bit; 185 l = b + bs->bit;
@@ -203,9 +203,9 @@ static unsigned get_bits(bitstr_t * bs, unsigned b)
203 203
204/****************************************************************************/ 204/****************************************************************************/
205/* Assume b <= 32 */ 205/* Assume b <= 32 */
206static unsigned get_bitmap(bitstr_t * bs, unsigned b) 206static unsigned int get_bitmap(bitstr_t *bs, unsigned int b)
207{ 207{
208 unsigned v, l, shift, bytes; 208 unsigned int v, l, shift, bytes;
209 209
210 if (!b) 210 if (!b)
211 return 0; 211 return 0;
@@ -213,18 +213,18 @@ static unsigned get_bitmap(bitstr_t * bs, unsigned b)
213 l = bs->bit + b; 213 l = bs->bit + b;
214 214
215 if (l < 8) { 215 if (l < 8) {
216 v = (unsigned) (*bs->cur) << (bs->bit + 24); 216 v = (unsigned int)(*bs->cur) << (bs->bit + 24);
217 bs->bit = l; 217 bs->bit = l;
218 } else if (l == 8) { 218 } else if (l == 8) {
219 v = (unsigned) (*bs->cur++) << (bs->bit + 24); 219 v = (unsigned int)(*bs->cur++) << (bs->bit + 24);
220 bs->bit = 0; 220 bs->bit = 0;
221 } else { 221 } else {
222 for (bytes = l >> 3, shift = 24, v = 0; bytes; 222 for (bytes = l >> 3, shift = 24, v = 0; bytes;
223 bytes--, shift -= 8) 223 bytes--, shift -= 8)
224 v |= (unsigned) (*bs->cur++) << shift; 224 v |= (unsigned int)(*bs->cur++) << shift;
225 225
226 if (l < 32) { 226 if (l < 32) {
227 v |= (unsigned) (*bs->cur) << shift; 227 v |= (unsigned int)(*bs->cur) << shift;
228 v <<= bs->bit; 228 v <<= bs->bit;
229 } else if (l > 32) { 229 } else if (l > 32) {
230 v <<= bs->bit; 230 v <<= bs->bit;
@@ -242,9 +242,9 @@ static unsigned get_bitmap(bitstr_t * bs, unsigned b)
242/**************************************************************************** 242/****************************************************************************
243 * Assume bs is aligned and sizeof(unsigned int) == 4 243 * Assume bs is aligned and sizeof(unsigned int) == 4
244 ****************************************************************************/ 244 ****************************************************************************/
245static unsigned get_uint(bitstr_t * bs, int b) 245static unsigned int get_uint(bitstr_t *bs, int b)
246{ 246{
247 unsigned v = 0; 247 unsigned int v = 0;
248 248
249 switch (b) { 249 switch (b) {
250 case 4: 250 case 4:
@@ -264,7 +264,7 @@ static unsigned get_uint(bitstr_t * bs, int b)
264} 264}
265 265
266/****************************************************************************/ 266/****************************************************************************/
267static int decode_nul(bitstr_t * bs, field_t * f, char *base, int level) 267static int decode_nul(bitstr_t *bs, field_t *f, char *base, int level)
268{ 268{
269 PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name); 269 PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name);
270 270
@@ -272,7 +272,7 @@ static int decode_nul(bitstr_t * bs, field_t * f, char *base, int level)
272} 272}
273 273
274/****************************************************************************/ 274/****************************************************************************/
275static int decode_bool(bitstr_t * bs, field_t * f, char *base, int level) 275static int decode_bool(bitstr_t *bs, field_t *f, char *base, int level)
276{ 276{
277 PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name); 277 PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name);
278 278
@@ -283,7 +283,7 @@ static int decode_bool(bitstr_t * bs, field_t * f, char *base, int level)
283} 283}
284 284
285/****************************************************************************/ 285/****************************************************************************/
286static int decode_oid(bitstr_t * bs, field_t * f, char *base, int level) 286static int decode_oid(bitstr_t *bs, field_t *f, char *base, int level)
287{ 287{
288 int len; 288 int len;
289 289
@@ -299,9 +299,9 @@ static int decode_oid(bitstr_t * bs, field_t * f, char *base, int level)
299} 299}
300 300
301/****************************************************************************/ 301/****************************************************************************/
302static int decode_int(bitstr_t * bs, field_t * f, char *base, int level) 302static int decode_int(bitstr_t *bs, field_t *f, char *base, int level)
303{ 303{
304 unsigned len; 304 unsigned int len;
305 305
306 PRINT("%*.s%s", level * TAB_SIZE, " ", f->name); 306 PRINT("%*.s%s", level * TAB_SIZE, " ", f->name);
307 307
@@ -318,9 +318,9 @@ static int decode_int(bitstr_t * bs, field_t * f, char *base, int level)
318 len = get_bits(bs, 2) + 1; 318 len = get_bits(bs, 2) + 1;
319 BYTE_ALIGN(bs); 319 BYTE_ALIGN(bs);
320 if (base && (f->attr & DECODE)) { /* timeToLive */ 320 if (base && (f->attr & DECODE)) { /* timeToLive */
321 unsigned v = get_uint(bs, len) + f->lb; 321 unsigned int v = get_uint(bs, len) + f->lb;
322 PRINT(" = %u", v); 322 PRINT(" = %u", v);
323 *((unsigned *) (base + f->offset)) = v; 323 *((unsigned int *)(base + f->offset)) = v;
324 } 324 }
325 bs->cur += len; 325 bs->cur += len;
326 break; 326 break;
@@ -342,7 +342,7 @@ static int decode_int(bitstr_t * bs, field_t * f, char *base, int level)
342} 342}
343 343
344/****************************************************************************/ 344/****************************************************************************/
345static int decode_enum(bitstr_t * bs, field_t * f, char *base, int level) 345static int decode_enum(bitstr_t *bs, field_t *f, char *base, int level)
346{ 346{
347 PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name); 347 PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name);
348 348
@@ -357,9 +357,9 @@ static int decode_enum(bitstr_t * bs, field_t * f, char *base, int level)
357} 357}
358 358
359/****************************************************************************/ 359/****************************************************************************/
360static int decode_bitstr(bitstr_t * bs, field_t * f, char *base, int level) 360static int decode_bitstr(bitstr_t *bs, field_t *f, char *base, int level)
361{ 361{
362 unsigned len; 362 unsigned int len;
363 363
364 PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name); 364 PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name);
365 365
@@ -390,9 +390,9 @@ static int decode_bitstr(bitstr_t * bs, field_t * f, char *base, int level)
390} 390}
391 391
392/****************************************************************************/ 392/****************************************************************************/
393static int decode_numstr(bitstr_t * bs, field_t * f, char *base, int level) 393static int decode_numstr(bitstr_t *bs, field_t *f, char *base, int level)
394{ 394{
395 unsigned len; 395 unsigned int len;
396 396
397 PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name); 397 PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name);
398 398
@@ -407,9 +407,9 @@ static int decode_numstr(bitstr_t * bs, field_t * f, char *base, int level)
407} 407}
408 408
409/****************************************************************************/ 409/****************************************************************************/
410static int decode_octstr(bitstr_t * bs, field_t * f, char *base, int level) 410static int decode_octstr(bitstr_t *bs, field_t *f, char *base, int level)
411{ 411{
412 unsigned len; 412 unsigned int len;
413 413
414 PRINT("%*.s%s", level * TAB_SIZE, " ", f->name); 414 PRINT("%*.s%s", level * TAB_SIZE, " ", f->name);
415 415
@@ -424,7 +424,7 @@ static int decode_octstr(bitstr_t * bs, field_t * f, char *base, int level)
424 bs->cur[0], bs->cur[1], 424 bs->cur[0], bs->cur[1],
425 bs->cur[2], bs->cur[3], 425 bs->cur[2], bs->cur[3],
426 bs->cur[4] * 256 + bs->cur[5])); 426 bs->cur[4] * 256 + bs->cur[5]));
427 *((unsigned *) (base + f->offset)) = 427 *((unsigned int *)(base + f->offset)) =
428 bs->cur - bs->buf; 428 bs->cur - bs->buf;
429 } 429 }
430 } 430 }
@@ -455,9 +455,9 @@ static int decode_octstr(bitstr_t * bs, field_t * f, char *base, int level)
455} 455}
456 456
457/****************************************************************************/ 457/****************************************************************************/
458static int decode_bmpstr(bitstr_t * bs, field_t * f, char *base, int level) 458static int decode_bmpstr(bitstr_t *bs, field_t *f, char *base, int level)
459{ 459{
460 unsigned len; 460 unsigned int len;
461 461
462 PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name); 462 PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name);
463 463
@@ -480,9 +480,9 @@ static int decode_bmpstr(bitstr_t * bs, field_t * f, char *base, int level)
480} 480}
481 481
482/****************************************************************************/ 482/****************************************************************************/
483static int decode_seq(bitstr_t * bs, field_t * f, char *base, int level) 483static int decode_seq(bitstr_t *bs, field_t *f, char *base, int level)
484{ 484{
485 unsigned ext, bmp, i, opt, len = 0, bmp2, bmp2_len; 485 unsigned int ext, bmp, i, opt, len = 0, bmp2, bmp2_len;
486 int err; 486 int err;
487 field_t *son; 487 field_t *son;
488 unsigned char *beg = NULL; 488 unsigned char *beg = NULL;
@@ -498,7 +498,7 @@ static int decode_seq(bitstr_t * bs, field_t * f, char *base, int level)
498 /* Get fields bitmap */ 498 /* Get fields bitmap */
499 bmp = get_bitmap(bs, f->sz); 499 bmp = get_bitmap(bs, f->sz);
500 if (base) 500 if (base)
501 *(unsigned *) base = bmp; 501 *(unsigned int *)base = bmp;
502 502
503 /* Decode the root components */ 503 /* Decode the root components */
504 for (i = opt = 0, son = f->fields; i < f->lb; i++, son++) { 504 for (i = opt = 0, son = f->fields; i < f->lb; i++, son++) {
@@ -550,7 +550,7 @@ static int decode_seq(bitstr_t * bs, field_t * f, char *base, int level)
550 bmp2 = get_bitmap(bs, bmp2_len); 550 bmp2 = get_bitmap(bs, bmp2_len);
551 bmp |= bmp2 >> f->sz; 551 bmp |= bmp2 >> f->sz;
552 if (base) 552 if (base)
553 *(unsigned *) base = bmp; 553 *(unsigned int *)base = bmp;
554 BYTE_ALIGN(bs); 554 BYTE_ALIGN(bs);
555 555
556 /* Decode the extension components */ 556 /* Decode the extension components */
@@ -596,9 +596,9 @@ static int decode_seq(bitstr_t * bs, field_t * f, char *base, int level)
596} 596}
597 597
598/****************************************************************************/ 598/****************************************************************************/
599static int decode_seqof(bitstr_t * bs, field_t * f, char *base, int level) 599static int decode_seqof(bitstr_t *bs, field_t *f, char *base, int level)
600{ 600{
601 unsigned count, effective_count = 0, i, len = 0; 601 unsigned int count, effective_count = 0, i, len = 0;
602 int err; 602 int err;
603 field_t *son; 603 field_t *son;
604 unsigned char *beg = NULL; 604 unsigned char *beg = NULL;
@@ -636,8 +636,8 @@ static int decode_seqof(bitstr_t * bs, field_t * f, char *base, int level)
636 /* Write Count */ 636 /* Write Count */
637 if (base) { 637 if (base) {
638 effective_count = count > f->ub ? f->ub : count; 638 effective_count = count > f->ub ? f->ub : count;
639 *(unsigned *) base = effective_count; 639 *(unsigned int *)base = effective_count;
640 base += sizeof(unsigned); 640 base += sizeof(unsigned int);
641 } 641 }
642 642
643 /* Decode nested field */ 643 /* Decode nested field */
@@ -685,9 +685,9 @@ static int decode_seqof(bitstr_t * bs, field_t * f, char *base, int level)
685 685
686 686
687/****************************************************************************/ 687/****************************************************************************/
688static int decode_choice(bitstr_t * bs, field_t * f, char *base, int level) 688static int decode_choice(bitstr_t *bs, field_t *f, char *base, int level)
689{ 689{
690 unsigned type, ext, len = 0; 690 unsigned int type, ext, len = 0;
691 int err; 691 int err;
692 field_t *son; 692 field_t *son;
693 unsigned char *beg = NULL; 693 unsigned char *beg = NULL;
@@ -710,7 +710,7 @@ static int decode_choice(bitstr_t * bs, field_t * f, char *base, int level)
710 710
711 /* Write Type */ 711 /* Write Type */
712 if (base) 712 if (base)
713 *(unsigned *) base = type; 713 *(unsigned int *)base = type;
714 714
715 /* Check Range */ 715 /* Check Range */
716 if (type >= f->ub) { /* Newer version? */ 716 if (type >= f->ub) { /* Newer version? */
@@ -754,7 +754,7 @@ static int decode_choice(bitstr_t * bs, field_t * f, char *base, int level)
754} 754}
755 755
756/****************************************************************************/ 756/****************************************************************************/
757int DecodeRasMessage(unsigned char *buf, size_t sz, RasMessage * ras) 757int DecodeRasMessage(unsigned char *buf, size_t sz, RasMessage *ras)
758{ 758{
759 static field_t ras_message = { 759 static field_t ras_message = {
760 FNAME("RasMessage") CHOICE, 5, 24, 32, DECODE | EXT, 760 FNAME("RasMessage") CHOICE, 5, 24, 32, DECODE | EXT,
@@ -771,7 +771,7 @@ int DecodeRasMessage(unsigned char *buf, size_t sz, RasMessage * ras)
771 771
772/****************************************************************************/ 772/****************************************************************************/
773static int DecodeH323_UserInformation(unsigned char *buf, unsigned char *beg, 773static int DecodeH323_UserInformation(unsigned char *buf, unsigned char *beg,
774 size_t sz, H323_UserInformation * uuie) 774 size_t sz, H323_UserInformation *uuie)
775{ 775{
776 static field_t h323_userinformation = { 776 static field_t h323_userinformation = {
777 FNAME("H323-UserInformation") SEQ, 1, 2, 2, DECODE | EXT, 777 FNAME("H323-UserInformation") SEQ, 1, 2, 2, DECODE | EXT,
@@ -807,7 +807,7 @@ int DecodeMultimediaSystemControlMessage(unsigned char *buf, size_t sz,
807} 807}
808 808
809/****************************************************************************/ 809/****************************************************************************/
810int DecodeQ931(unsigned char *buf, size_t sz, Q931 * q931) 810int DecodeQ931(unsigned char *buf, size_t sz, Q931 *q931)
811{ 811{
812 unsigned char *p = buf; 812 unsigned char *p = buf;
813 int len; 813 int len;