]> The Tcpdump Group git mirrors - tcpdump/blob - print-sip.c
NDOize safeputs() and safeputchar()
[tcpdump] / print-sip.c
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 #ifdef HAVE_CONFIG_H
17 #include "config.h"
18 #endif
19
20 #include <tcpdump-stdinc.h>
21
22 #include <stdio.h>
23 #include <stdlib.h>
24
25 #include "interface.h"
26 #include "extract.h"
27
28 void
29 sip_print(register const u_char *pptr, register u_int len)
30 {
31 u_int idx;
32
33 printf("SIP, length: %u%s", len, vflag ? "\n\t" : "");
34
35 /* in non-verbose mode just lets print the protocol and length */
36 if (vflag < 1)
37 return;
38
39 for (idx = 0; idx < len; idx++) {
40 TCHECK2(*(pptr+idx), 2);
41 if (EXTRACT_16BITS(pptr+idx) != 0x0d0a) { /* linefeed ? */
42 safeputchar(gndo, *(pptr + idx));
43 } else {
44 printf("\n\t");
45 idx+=1;
46 }
47 }
48
49 /* do we want to see an additionally hexdump ? */
50 if (vflag> 1)
51 print_unknown_data(gndo,pptr,"\n\t",len);
52
53 return;
54
55 trunc:
56 printf("[|sip]");
57 }