Willy Tarreau | e6b9894 | 2007-10-29 01:09:36 +0100 | [diff] [blame] | 1 | /* |
Willy Tarreau | b1d6774 | 2010-03-29 19:36:59 +0200 | [diff] [blame] | 2 | * include/proto/proto_tcp.h |
| 3 | * This file contains TCP socket protocol definitions. |
| 4 | * |
| 5 | * Copyright (C) 2000-2010 Willy Tarreau - w@1wt.eu |
| 6 | * |
| 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | * License as published by the Free Software Foundation, version 2.1 |
| 10 | * exclusively. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public |
| 18 | * License along with this library; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
Willy Tarreau | e6b9894 | 2007-10-29 01:09:36 +0100 | [diff] [blame] | 21 | |
| 22 | #ifndef _PROTO_PROTO_TCP_H |
| 23 | #define _PROTO_PROTO_TCP_H |
| 24 | |
| 25 | #include <common/config.h> |
Willy Tarreau | b686644 | 2008-07-14 23:54:42 +0200 | [diff] [blame] | 26 | #include <types/proto_tcp.h> |
Willy Tarreau | e6b9894 | 2007-10-29 01:09:36 +0100 | [diff] [blame] | 27 | #include <types/task.h> |
Willy Tarreau | 9ba2dcc | 2010-06-14 21:04:55 +0200 | [diff] [blame] | 28 | #include <proto/stick_table.h> |
Willy Tarreau | e6b9894 | 2007-10-29 01:09:36 +0100 | [diff] [blame] | 29 | |
David du Colombier | 6f5ccb1 | 2011-03-10 22:26:24 +0100 | [diff] [blame] | 30 | int tcp_bind_socket(int fd, int flags, struct sockaddr_storage *local, struct sockaddr_storage *remote); |
Willy Tarreau | e6b9894 | 2007-10-29 01:09:36 +0100 | [diff] [blame] | 31 | void tcpv4_add_listener(struct listener *listener); |
| 32 | void tcpv6_add_listener(struct listener *listener); |
Willy Tarreau | 14f8e86 | 2012-08-30 22:23:13 +0200 | [diff] [blame] | 33 | int tcp_connect_server(struct connection *conn, int data); |
Willy Tarreau | 239d718 | 2012-07-23 18:53:03 +0200 | [diff] [blame] | 34 | int tcp_connect_probe(struct connection *conn); |
Willy Tarreau | 59b9479 | 2012-05-11 16:16:40 +0200 | [diff] [blame] | 35 | int tcp_get_src(int fd, struct sockaddr *sa, socklen_t salen, int dir); |
| 36 | int tcp_get_dst(int fd, struct sockaddr *sa, socklen_t salen, int dir); |
Willy Tarreau | 7421efb | 2012-07-02 15:11:27 +0200 | [diff] [blame] | 37 | int tcp_inspect_request(struct session *s, struct channel *req, int an_bit); |
| 38 | int tcp_inspect_response(struct session *s, struct channel *rep, int an_bit); |
Willy Tarreau | a5c0ab2 | 2010-05-31 10:30:33 +0200 | [diff] [blame] | 39 | int tcp_exec_req_rules(struct session *s); |
Willy Tarreau | 32a6f2e | 2012-04-25 10:13:36 +0200 | [diff] [blame] | 40 | int smp_fetch_rdp_cookie(struct proxy *px, struct session *l4, void *l7, unsigned int opt, const struct arg *args, struct sample *smp); |
Willy Tarreau | e6b9894 | 2007-10-29 01:09:36 +0100 | [diff] [blame] | 41 | |
Willy Tarreau | 64ee491 | 2012-08-30 22:59:48 +0200 | [diff] [blame] | 42 | /* Converts the INET/INET6 source address to a stick_table key usable for table |
Willy Tarreau | 9ba2dcc | 2010-06-14 21:04:55 +0200 | [diff] [blame] | 43 | * lookups. Returns either NULL if the source cannot be converted (eg: not |
| 44 | * IPv4) or a pointer to the converted result in static_table_key in the |
| 45 | * appropriate format (IP). |
| 46 | */ |
Willy Tarreau | 64ee491 | 2012-08-30 22:59:48 +0200 | [diff] [blame] | 47 | static inline struct stktable_key *addr_to_stktable_key(struct sockaddr_storage *addr) |
Willy Tarreau | 9ba2dcc | 2010-06-14 21:04:55 +0200 | [diff] [blame] | 48 | { |
Willy Tarreau | 64ee491 | 2012-08-30 22:59:48 +0200 | [diff] [blame] | 49 | switch (addr->ss_family) { |
David du Colombier | 4f92d32 | 2011-03-24 11:09:31 +0100 | [diff] [blame] | 50 | case AF_INET: |
Willy Tarreau | 0711541 | 2012-10-29 21:56:59 +0100 | [diff] [blame] | 51 | static_table_key->key = (void *)&((struct sockaddr_in *)addr)->sin_addr; |
Willy Tarreau | c9f6011 | 2011-04-07 10:44:39 +0200 | [diff] [blame] | 52 | break; |
David du Colombier | 4f92d32 | 2011-03-24 11:09:31 +0100 | [diff] [blame] | 53 | case AF_INET6: |
Willy Tarreau | 0711541 | 2012-10-29 21:56:59 +0100 | [diff] [blame] | 54 | static_table_key->key = (void *)&((struct sockaddr_in6 *)addr)->sin6_addr; |
Willy Tarreau | c9f6011 | 2011-04-07 10:44:39 +0200 | [diff] [blame] | 55 | break; |
Willy Tarreau | c3a08a1 | 2012-08-30 22:52:28 +0200 | [diff] [blame] | 56 | default: |
| 57 | return NULL; |
David du Colombier | 4f92d32 | 2011-03-24 11:09:31 +0100 | [diff] [blame] | 58 | } |
Willy Tarreau | 0711541 | 2012-10-29 21:56:59 +0100 | [diff] [blame] | 59 | return static_table_key; |
Willy Tarreau | 9ba2dcc | 2010-06-14 21:04:55 +0200 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | |
Willy Tarreau | e6b9894 | 2007-10-29 01:09:36 +0100 | [diff] [blame] | 63 | #endif /* _PROTO_PROTO_TCP_H */ |
| 64 | |
| 65 | /* |
| 66 | * Local variables: |
| 67 | * c-indent-level: 8 |
| 68 | * c-basic-offset: 8 |
| 69 | * End: |
| 70 | */ |