REORG: listener: move the receiver part to a new file

We'll soon add flags for the receivers, better add them to the final
file, so it's time to move the definition to receiver-t.h. The struct
receiver and rx_settings were placed there.
This commit is contained in:
Willy Tarreau 2020-09-01 10:37:19 +02:00
parent 4dfabfed13
commit d45693d85c
2 changed files with 65 additions and 22 deletions

View File

@ -29,7 +29,8 @@
#include <haproxy/api-t.h>
#include <haproxy/obj_type-t.h>
#include <haproxy/thread.h>
#include <haproxy/receiver-t.h>
#include <haproxy/thread-t.h>
#ifdef USE_OPENSSL
#include <haproxy/openssl-compat.h>
@ -178,27 +179,7 @@ struct bind_conf {
char *arg; /* argument passed to "bind" for better error reporting */
char *file; /* file where the section appears */
int line; /* line where the section appears */
struct {
unsigned long bind_proc; /* bitmask of processes allowed to use these listeners */
unsigned long bind_thread; /* bitmask of threads allowed to use these listeners */
struct { /* UNIX socket permissions */
uid_t uid; /* -1 to leave unchanged */
gid_t gid; /* -1 to leave unchanged */
mode_t mode; /* 0 to leave unchanged */
} ux;
char *interface; /* interface name or NULL */
const struct netns_entry *netns; /* network namespace of the listener*/
} settings; /* all the settings needed for the listening socket */
};
/* This describes a receiver with all its characteristics (address, status, etc) */
struct receiver {
int fd; /* handle we receive from (fd only for now) */
unsigned int flags; /* receiver options (RX_F_*) */
struct protocol *proto; /* protocol this receiver belongs to */
struct list proto_list; /* list in the protocol header */
/* warning: this struct is huge, keep it at the bottom */
struct sockaddr_storage addr; /* the address the socket is bound to */
struct rx_settings settings; /* all the settings needed for the listening socket */
};
/* The listener will be directly referenced by the fdtab[] which holds its

View File

@ -0,0 +1,62 @@
/*
* include/haproxy/receiver-t.h
* This file defines the structures needed to manage receivers.
*
* Copyright (C) 2000-2020 Willy Tarreau - w@1wt.eu
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, version 2.1
* exclusively.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _HAPROXY_RECEIVER_T_H
#define _HAPROXY_RECEIVER_T_H
#include <sys/types.h>
#include <sys/socket.h>
#include <haproxy/api-t.h>
#include <haproxy/namespace-t.h>
#include <haproxy/thread.h>
/* All the settings that are used to configure a receiver */
struct rx_settings {
unsigned long bind_proc; /* bitmask of processes allowed to use these listeners */
unsigned long bind_thread; /* bitmask of threads allowed to use these listeners */
struct { /* UNIX socket permissions */
uid_t uid; /* -1 to leave unchanged */
gid_t gid; /* -1 to leave unchanged */
mode_t mode; /* 0 to leave unchanged */
} ux;
char *interface; /* interface name or NULL */
const struct netns_entry *netns; /* network namespace of the listener*/
};
/* This describes a receiver with all its characteristics (address, options, etc) */
struct receiver {
int fd; /* handle we receive from (fd only for now) */
unsigned int flags; /* receiver options (RX_F_*) */
struct protocol *proto; /* protocol this receiver belongs to */
struct list proto_list; /* list in the protocol header */
/* warning: this struct is huge, keep it at the bottom */
struct sockaddr_storage addr; /* the address the socket is bound to */
};
#endif /* _HAPROXY_RECEIVER_T_H */
/*
* Local variables:
* c-indent-level: 8
* c-basic-offset: 8
* End:
*/