xref: /netbsd/external/bsd/tcpdump/dist/print-sip.c (revision 6550d01e)
1 /*
2  * Redistribution and use in source and binary forms, with or without
3  * modification, are permitted provided that: (1) source code
4  * distributions retain the above copyright notice and this paragraph
5  * in its entirety, and (2) distributions including binary code include
6  * the above copyright notice and this paragraph in its entirety in
7  * the documentation or other materials provided with the distribution.
8  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
9  * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
10  * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
11  * FOR A PARTICULAR PURPOSE.
12  *
13  * Original code by Hannes Gredler (hannes@juniper.net)
14  */
15 
16 #include <sys/cdefs.h>
17 #ifndef lint
18 #if 0
19 static const char rcsid[] _U_ =
20     "@(#) Header: /tcpdump/master/tcpdump/print-sip.c,v 1.1 2004-07-27 17:04:20 hannes Exp";
21 #else
22 __RCSID("$NetBSD: print-sip.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
23 #endif
24 #endif
25 
26 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif
29 
30 #include <tcpdump-stdinc.h>
31 
32 #include <stdio.h>
33 #include <stdlib.h>
34 
35 #include "interface.h"
36 #include "extract.h"
37 
38 #include "udp.h"
39 
40 void
41 sip_print(register const u_char *pptr, register u_int len)
42 {
43     u_int idx;
44 
45     printf("SIP, length: %u%s", len, vflag ? "\n\t" : "");
46 
47     /* in non-verbose mode just lets print the protocol and length */
48     if (vflag < 1)
49         return;
50 
51     for (idx = 0; idx < len; idx++) {
52         TCHECK2(*(pptr+idx), 2);
53         if (EXTRACT_16BITS(pptr+idx) != 0x0d0a) { /* linefeed ? */
54             safeputchar(*(pptr+idx));
55         } else {
56             printf("\n\t");
57             idx+=1;
58         }
59     }
60 
61     /* do we want to see an additionally hexdump ? */
62     if (vflag> 1)
63         print_unknown_data(pptr,"\n\t",len);
64 
65     return;
66 
67 trunc:
68     printf("[|sip]");
69 }
70