xref: /openbsd-src/usr.sbin/tcpdump/print-pim.c (revision 6f05df2d9be0954bec42d51d943d77bd250fb664)
1 /*	$OpenBSD: print-pim.c,v 1.6 2014/08/14 12:44:44 mpi 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/ip.h>
30 #include <netinet/ip_var.h>
31 #include <netinet/udp.h>
32 #include <netinet/udp_var.h>
33 #include <netinet/tcp.h>
34 
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <unistd.h>
38 
39 #include "interface.h"
40 #include "addrtoname.h"
41 
42 void
43 pim_print(register const u_char *bp, register u_int len)
44 {
45     register const u_char *ep;
46     register u_char type;
47 
48     ep = (const u_char *)snapend;
49     if (bp >= ep)
50 	return;
51 
52     type = bp[1];
53 
54     switch (type) {
55     case 0:
56 	(void)printf(" Query");
57 	break;
58 
59     case 1:
60 	(void)printf(" Register");
61 	break;
62 
63     case 2:
64 	(void)printf(" Register-Stop");
65 	break;
66 
67     case 3:
68 	(void)printf(" Join/Prune");
69 	break;
70 
71     case 4:
72 	(void)printf(" RP-reachable");
73 	break;
74 
75     case 5:
76 	(void)printf(" Assert");
77 	break;
78 
79     case 6:
80 	(void)printf(" Graft");
81 	break;
82 
83     case 7:
84 	(void)printf(" Graft-ACK");
85 	break;
86 
87     case 8:
88 	(void)printf(" Mode");
89 	break;
90 
91     default:
92 	(void)printf(" [type %d]", type);
93 	break;
94     }
95 }
96