Import from old repository commit 61ef2b42a9c4ba8e1600f15bb0236765edc2ad45.
[sliver-openvswitch.git] / third-party / ofp-tcpdump.patch
1 --- tcpdump/interface.h 2007-06-13 18:03:20.000000000 -0700
2 +++ tcpdump/interface.h 2008-04-15 18:28:55.000000000 -0700
3 @@ -148,7 +148,8 @@
4  
5  extern const char *dnaddr_string(u_short);
6  
7 -extern void error(const char *, ...)
8 +#define error(fmt, args...)   tcpdump_error(fmt, ## args)
9 +extern void tcpdump_error(const char *, ...)
10      __attribute__((noreturn, format (printf, 1, 2)));
11  extern void warning(const char *, ...) __attribute__ ((format (printf, 1, 2)));
12  
13 @@ -176,6 +177,7 @@
14  extern void hex_print_with_offset(const char *, const u_char *, u_int, u_int);
15  extern void hex_print(const char *, const u_char *, u_int);
16  extern void telnet_print(const u_char *, u_int);
17 +extern void openflow_print(const u_char *, u_int);
18  extern int ether_encap_print(u_short, const u_char *, u_int, u_int, u_short *);
19  extern int llc_print(const u_char *, u_int, u_int, const u_char *,
20         const u_char *, u_short *);
21 --- tcpdump/Makefile.in 2007-09-25 18:59:52.000000000 -0700
22 +++ tcpdump/Makefile.in 2009-05-11 15:59:28.000000000 -0700
23 @@ -49,10 +49,10 @@
24  CFLAGS = $(CCOPT) $(DEFS) $(INCLS)
25  
26  # Standard LDFLAGS
27 -LDFLAGS = @LDFLAGS@
28 +LDFLAGS = @LDFLAGS@ -L../../lib
29  
30  # Standard LIBS
31 -LIBS = @LIBS@
32 +LIBS = @LIBS@ -lopenvswitch
33  
34  INSTALL = @INSTALL@
35  INSTALL_PROGRAM = @INSTALL_PROGRAM@
36 @@ -87,7 +87,8 @@
37         print-slow.c print-snmp.c print-stp.c print-sunatm.c print-sunrpc.c \
38         print-symantec.c print-syslog.c print-tcp.c print-telnet.c print-tftp.c \
39         print-timed.c print-token.c print-udp.c print-vjc.c print-vrrp.c \
40 -       print-wb.c print-zephyr.c setsignal.c tcpdump.c util.c
41 +       print-wb.c print-zephyr.c setsignal.c tcpdump.c util.c \
42 +       print-openflow.c
43  
44  LOCALSRC = @LOCALSRC@
45  GENSRC = version.c
46 --- tcpdump/print-openflow.c    1969-12-31 16:00:00.000000000 -0800
47 +++ tcpdump/print-openflow.c    2009-05-11 15:38:41.000000000 -0700
48 @@ -0,0 +1,40 @@
49 +/* Copyright (C) 2007, 2008, 2009 Nicira Networks.
50 + *
51 + * Permission to use, copy, modify, and/or distribute this software for any
52 + * purpose with or without fee is hereby granted, provided that the above
53 + * copyright notice and this permission notice appear in all copies.
54 + *
55 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
56 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
57 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
58 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
59 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
60 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
61 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
62 + */
63 + *
64 +
65 +#ifdef HAVE_CONFIG_H
66 +#include "config.h"
67 +#endif
68 +
69 +#include <stdlib.h>
70 +
71 +#include "interface.h"
72 +#include "../../include/openflow/openflow.h"
73 +#include "../../lib/ofp-print.h"
74 +
75 +void
76 +openflow_print(const u_char *sp, u_int length)
77 +{
78 +    const struct ofp_header *ofp = (struct ofp_header *)sp;
79 +
80 +    if (!TTEST2(*sp, ntohs(ofp->length)))
81 +            goto trunc;
82 +
83 +    ofp_print(stdout, sp, length, vflag);
84 +    return;
85 +
86 +trunc:
87 +    printf("[|openflow]");
88 +}
89 --- tcpdump/print-tcp.c 2006-09-19 12:07:57.000000000 -0700
90 +++ tcpdump/print-tcp.c 2009-05-11 15:38:25.000000000 -0700
91 @@ -52,6 +52,8 @@
92  
93  #include "nameser.h"
94  
95 +#include "../../include/openflow/openflow.h"
96 +
97  #ifdef HAVE_LIBCRYPTO
98  #include <openssl/md5.h>
99  
100 @@ -680,7 +682,8 @@
101                 }
102                  else if (length > 0 && (sport == LDP_PORT || dport == LDP_PORT)) {
103                          ldp_print(bp, length);
104 -               }
105 +               } else if (sport == OFP_TCP_PORT || dport == OFP_TCP_PORT)
106 +                       openflow_print(bp, length);
107         }
108         return;
109  bad: