xref: /netbsd-src/external/bsd/tcpdump/dist/print-http.c (revision 0e2e28bced52bda3788c857106bde6c44d2df3b8)
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 
14 #include <sys/cdefs.h>
15 #ifndef lint
16 __RCSID("$NetBSD: print-http.c,v 1.4 2023/08/17 20:19:40 christos Exp $");
17 #endif
18 
19 /* \summary: Hypertext Transfer Protocol (HTTP) printer */
20 
21 #ifdef HAVE_CONFIG_H
22 #include <config.h>
23 #endif
24 
25 #include "netdissect-stdinc.h"
26 
27 #include "netdissect.h"
28 
29 /*
30  * Includes WebDAV requests.
31  */
32 static const char *httpcmds[] = {
33 	"GET",
34 	"PUT",
35 	"COPY",
36 	"HEAD",
37 	"LOCK",
38 	"MOVE",
39 	"POLL",
40 	"POST",
41 	"BCOPY",
42 	"BMOVE",
43 	"MKCOL",
44 	"TRACE",
45 	"LABEL",
46 	"MERGE",
47 	"DELETE",
48 	"SEARCH",
49 	"UNLOCK",
50 	"REPORT",
51 	"UPDATE",
52 	"NOTIFY",
53 	"BDELETE",
54 	"CONNECT",
55 	"OPTIONS",
56 	"CHECKIN",
57 	"PROPFIND",
58 	"CHECKOUT",
59 	"CCM_POST",
60 	"SUBSCRIBE",
61 	"PROPPATCH",
62 	"BPROPFIND",
63 	"BPROPPATCH",
64 	"UNCHECKOUT",
65 	"MKACTIVITY",
66 	"MKWORKSPACE",
67 	"UNSUBSCRIBE",
68 	"RPC_CONNECT",
69 	"VERSION-CONTROL",
70 	"BASELINE-CONTROL",
71 	NULL
72 };
73 
74 void
75 http_print(netdissect_options *ndo, const u_char *pptr, u_int len)
76 {
77 	ndo->ndo_protocol = "http";
78 	txtproto_print(ndo, pptr, len, httpcmds, RESP_CODE_SECOND_TOKEN);
79 }
80