]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: connection: using internal struct to hold source and dest port.
authorDavid Carlier <devnexen@gmail.com>
Mon, 4 Jul 2016 21:51:33 +0000 (22:51 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 5 Jul 2016 12:43:05 +0000 (14:43 +0200)
Originally, tcphdr's source and dest from Linux were used to get the
source and port which led to a build issue on BSD oses.
To avoid side problems related to network then we just use an internal
struct as we need only those two fields.

include/types/connection.h
src/connection.c

index 292ca2bd640ec51c74cfea1a2a53b51f6567c9e9..2d10704c11a7f0ce39f2d9cf8a7d7e4875b517b2 100644 (file)
@@ -34,7 +34,6 @@
 
 #include <netinet/ip.h>
 #include <netinet/ip6.h>
-#include <netinet/tcp.h>
 
 /* referenced below */
 struct connection;
@@ -232,6 +231,11 @@ struct data_cb {
        int  (*init)(struct connection *conn);  /* data-layer initialization */
 };
 
+struct my_tcphdr {
+       u_int16_t source;
+       u_int16_t dest;
+};
+
 /* a connection source profile defines all the parameters needed to properly
  * bind an outgoing connection for a server or proxy.
  */
index 358c9bcb1f98de54eded815afb115569cf0d75d3..7a9f3913ca74589a8a5f2d0a1c4e135652ce01d1 100644 (file)
@@ -713,7 +713,7 @@ int conn_recv_netscaler_cip(struct connection *conn, int flag)
 
        if (ip_v == 4) {
                struct ip *hdr_ip4;
-               struct tcphdr *hdr_tcp;
+               struct my_tcphdr *hdr_tcp;
 
                hdr_ip4 = (struct ip *)line;
 
@@ -731,7 +731,7 @@ int conn_recv_netscaler_cip(struct connection *conn, int flag)
                        goto missing;
                }
 
-               hdr_tcp = (struct tcphdr *)(line + (hdr_ip4->ip_hl * 4));
+               hdr_tcp = (struct my_tcphdr *)(line + (hdr_ip4->ip_hl * 4));
 
                /* update the session's addresses and mark them set */
                ((struct sockaddr_in *)&conn->addr.from)->sin_family = AF_INET;
@@ -746,7 +746,7 @@ int conn_recv_netscaler_cip(struct connection *conn, int flag)
        }
        else if (ip_v == 6) {
                struct ip6_hdr *hdr_ip6;
-               struct tcphdr *hdr_tcp;
+               struct my_tcphdr *hdr_tcp;
 
                hdr_ip6 = (struct ip6_hdr *)line;
 
@@ -764,7 +764,7 @@ int conn_recv_netscaler_cip(struct connection *conn, int flag)
                        goto missing;
                }
 
-               hdr_tcp = (struct tcphdr *)(line + sizeof(struct ip6_hdr));
+               hdr_tcp = (struct my_tcphdr *)(line + sizeof(struct ip6_hdr));
 
                /* update the session's addresses and mark them set */
                ((struct sockaddr_in6 *)&conn->addr.from)->sin6_family = AF_INET6;