summaryrefslogtreecommitdiff
path: root/third-party/ofp-tcpdump.patch
blob: 56b35716c425f88fecfd613614e47b3a8c69820a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
--- tcpdump/interface.h	2007-06-13 18:03:20.000000000 -0700
+++ tcpdump/interface.h	2008-04-15 18:28:55.000000000 -0700
@@ -130,7 +130,8 @@
 
 extern const char *dnaddr_string(u_short);
 
-extern void error(const char *, ...)
+#define error(fmt, args...)   tcpdump_error(fmt, ## args)
+extern void tcpdump_error(const char *, ...)
     __attribute__((noreturn, format (printf, 1, 2)));
 extern void warning(const char *, ...) __attribute__ ((format (printf, 1, 2)));
 
@@ -163,6 +164,7 @@
 extern void hex_print_with_offset(const char *, const u_char *, u_int, u_int);
 extern void hex_print(const char *, const u_char *, u_int);
 extern void telnet_print(const u_char *, u_int);
+extern void openflow_print(const u_char *, u_int);
 extern int llc_print(const u_char *, u_int, u_int, const u_char *,
 	const u_char *, u_short *);
 extern int snap_print(const u_char *, u_int, u_int, u_int);
--- tcpdump/Makefile.in	2012-06-13 04:56:20.000000000 +1200
+++ tcpdump/Makefile.in	2012-08-29 21:36:37.000000000 +1200
@@ -43,7 +43,7 @@
 CC = @CC@
 PROG = tcpdump
 CCOPT = @V_CCOPT@
-INCLS = -I. @V_INCLS@
+INCLS = -I. @V_INCLS@ -I../../include
 DEFS = @DEFS@ @CPPFLAGS@ @V_DEFS@

 # Standard CFLAGS
@@ -51,10 +51,10 @@
 FULL_CFLAGS = $(CCOPT) $(DEFS) $(INCLS) $(CFLAGS)
 
 # Standard LDFLAGS
-LDFLAGS = @LDFLAGS@
+LDFLAGS = @LDFLAGS@ -L../../lib
 
 # Standard LIBS
-LIBS = @LIBS@
+LIBS = @LIBS@ -lopenvswitch -lssl -lrt -lm
 
 INSTALL = @INSTALL@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -93,7 +93,8 @@
 	print-symantec.c print-syslog.c print-tcp.c print-telnet.c print-tftp.c \
 	print-timed.c print-tipc.c print-token.c print-udld.c print-udp.c \
 	print-usb.c print-vjc.c print-vqp.c print-vrrp.c print-vtp.c \
-	print-wb.c print-zephyr.c signature.c setsignal.c tcpdump.c util.c
+	print-wb.c print-zephyr.c signature.c setsignal.c tcpdump.c util.c \
+	print-openflow.c
 
 LIBNETDISSECT_SRC=print-isakmp.c
 LIBNETDISSECT_OBJ=$(LIBNETDISSECT_SRC:.c=.o)
@@ -363,7 +364,7 @@ all: $(PROG)
 
 $(PROG): $(OBJ) 
 	@rm -f $@
-	$(CC) $(FULL_CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
+	libtool --mode=link $(CC) $(FULL_CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
 
 $(LIBNETDISSECT): $(LIBNETDISSECT_OBJ)
 	@rm -f $@
--- tcpdump/print-openflow.c	1969-12-31 16:00:00.000000000 -0800
+++ tcpdump/print-openflow.c	2009-05-11 15:38:41.000000000 -0700
@@ -0,0 +1,45 @@
+/* Copyright (C) 2007, 2008, 2009 Nicira, Inc.
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+
+    1. Redistributions of source code must retain the above copyright
+       notice, this list of conditions and the following disclaimer.
+    2. Redistributions in binary form must reproduce the above copyright
+       notice, this list of conditions and the following disclaimer in
+       the documentation and/or other materials provided with the
+       distribution.
+    3. The names of the authors may not be used to endorse or promote
+       products derived from this software without specific prior
+       written permission.
+
+   THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+
+#include "interface.h"
+#include "openflow/openflow.h"
+#include "openvswitch/ofp-print.h"
+
+void
+openflow_print(const u_char *sp, u_int length)
+{
+    const struct ofp_header *ofp = (struct ofp_header *)sp;
+
+    if (!TTEST2(*sp, ntohs(ofp->length)))
+            goto trunc;
+
+    ofp_print(stdout, sp, length, vflag);
+    return;
+
+trunc:
+    printf("[|openflow]");
+}
--- tcpdump/print-tcp.c	2006-09-19 12:07:57.000000000 -0700
+++ tcpdump/print-tcp.c	2009-05-11 15:38:25.000000000 -0700
@@ -56,6 +56,8 @@
 
 #include "nameser.h"
 
+#include "openflow/openflow.h"
+
 #ifdef HAVE_LIBCRYPTO
 #include <openssl/md5.h>
 #include <signature.h>
@@ -669,7 +672,9 @@
         }
         else if (length > 0 && (sport == LDP_PORT || dport == LDP_PORT)) {
                 ldp_print(bp, length);
-        }
+        } else if (sport == OFP_PORT || dport == OFP_PORT) {
+                   openflow_print(bp, length);
+        }
 
         return;
  bad: