xref: /openbsd-src/usr.sbin/tcpdump/print-pim.c (revision 91f110e064cd7c194e59e019b83bb7496c1c84d4)
1 /*	$OpenBSD: print-pim.c,v 1.5 2009/10/27 23:59:55 deraadt Exp $	*/
2 
3 /*
4  * Copyright (c) 1995, 1996
5  *	The Regents of the University of California.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that: (1) source code distributions
9  * retain the above copyright notice and this paragraph in its entirety, (2)
10  * distributions including binary code include the above copyright notice and
11  * this paragraph in its entirety in the documentation or other materials
12  * provided with the distribution, and (3) all advertising materials mentioning
13  * features or use of this software display the following acknowledgement:
14  * ``This product includes software developed by the University of California,
15  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
16  * the University nor the names of its contributors may be used to endorse
17  * or promote products derived from this software without specific prior
18  * written permission.
19  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
20  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22  */
23 
24 #include <sys/param.h>
25 #include <sys/time.h>
26 #include <sys/socket.h>
27 
28 #include <netinet/in.h>
29 #include <netinet/in_systm.h>
30 #include <netinet/ip.h>
31 #include <netinet/ip_var.h>
32 #include <netinet/udp.h>
33 #include <netinet/udp_var.h>
34 #include <netinet/tcp.h>
35 #include <netinet/tcpip.h>
36 
37 #include <stdio.h>
38 #include <stdlib.h>
39 #include <unistd.h>
40 
41 #include "interface.h"
42 #include "addrtoname.h"
43 
44 void
45 pim_print(register const u_char *bp, register u_int len)
46 {
47     register const u_char *ep;
48     register u_char type;
49 
50     ep = (const u_char *)snapend;
51     if (bp >= ep)
52 	return;
53 
54     type = bp[1];
55 
56     switch (type) {
57     case 0:
58 	(void)printf(" Query");
59 	break;
60 
61     case 1:
62 	(void)printf(" Register");
63 	break;
64 
65     case 2:
66 	(void)printf(" Register-Stop");
67 	break;
68 
69     case 3:
70 	(void)printf(" Join/Prune");
71 	break;
72 
73     case 4:
74 	(void)printf(" RP-reachable");
75 	break;
76 
77     case 5:
78 	(void)printf(" Assert");
79 	break;
80 
81     case 6:
82 	(void)printf(" Graft");
83 	break;
84 
85     case 7:
86 	(void)printf(" Graft-ACK");
87 	break;
88 
89     case 8:
90 	(void)printf(" Mode");
91 	break;
92 
93     default:
94 	(void)printf(" [type %d]", type);
95 	break;
96     }
97 }
98