mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-03-05 10:58:14 +00:00
MINOR: connection: add a field to store an object type
This will soon be used to differenciate connections from applet contexts. Object type "connection" has also been added.
This commit is contained in:
parent
66337a0784
commit
51c2184755
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include <common/config.h>
|
#include <common/config.h>
|
||||||
#include <common/memory.h>
|
#include <common/memory.h>
|
||||||
|
#include <types/connection.h>
|
||||||
#include <types/listener.h>
|
#include <types/listener.h>
|
||||||
#include <types/obj_type.h>
|
#include <types/obj_type.h>
|
||||||
#include <types/proxy.h>
|
#include <types/proxy.h>
|
||||||
@ -44,6 +45,7 @@ static inline const char *obj_type_name(enum obj_type *t)
|
|||||||
case OBJ_TYPE_PROXY: return "PROXY";
|
case OBJ_TYPE_PROXY: return "PROXY";
|
||||||
case OBJ_TYPE_SERVER: return "SERVER";
|
case OBJ_TYPE_SERVER: return "SERVER";
|
||||||
case OBJ_TYPE_APPLET: return "APPLET";
|
case OBJ_TYPE_APPLET: return "APPLET";
|
||||||
|
case OBJ_TYPE_CONN: return "CONN";
|
||||||
default: return "NONE";
|
default: return "NONE";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -103,6 +105,18 @@ static inline struct si_applet *objt_applet(enum obj_type *t)
|
|||||||
return __objt_applet(t);
|
return __objt_applet(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline struct connection *__objt_conn(enum obj_type *t)
|
||||||
|
{
|
||||||
|
return container_of(t, struct connection, obj_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline struct connection *objt_conn(enum obj_type *t)
|
||||||
|
{
|
||||||
|
if (!t || *t != OBJ_TYPE_CONN)
|
||||||
|
return NULL;
|
||||||
|
return __objt_conn(t);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void *obj_base_ptr(enum obj_type *t)
|
static inline void *obj_base_ptr(enum obj_type *t)
|
||||||
{
|
{
|
||||||
switch (obj_type(t)) {
|
switch (obj_type(t)) {
|
||||||
@ -110,6 +124,7 @@ static inline void *obj_base_ptr(enum obj_type *t)
|
|||||||
case OBJ_TYPE_PROXY: return __objt_proxy(t);
|
case OBJ_TYPE_PROXY: return __objt_proxy(t);
|
||||||
case OBJ_TYPE_SERVER: return __objt_server(t);
|
case OBJ_TYPE_SERVER: return __objt_server(t);
|
||||||
case OBJ_TYPE_APPLET: return __objt_applet(t);
|
case OBJ_TYPE_APPLET: return __objt_applet(t);
|
||||||
|
case OBJ_TYPE_CONN: return __objt_conn(t);
|
||||||
default: return NULL;
|
default: return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,11 +230,12 @@ struct conn_src {
|
|||||||
/* This structure describes a connection with its methods and data.
|
/* This structure describes a connection with its methods and data.
|
||||||
* A connection may be performed to proxy or server via a local or remote
|
* A connection may be performed to proxy or server via a local or remote
|
||||||
* socket, and can also be made to an internal applet. It can support
|
* socket, and can also be made to an internal applet. It can support
|
||||||
* several transport schemes (applet, raw, ssl, ...). It can support several
|
* several transport schemes (raw, ssl, ...). It can support several
|
||||||
* connection control schemes, generally a protocol for socket-oriented
|
* connection control schemes, generally a protocol for socket-oriented
|
||||||
* connections, but other methods for applets.
|
* connections, but other methods for applets.
|
||||||
*/
|
*/
|
||||||
struct connection {
|
struct connection {
|
||||||
|
enum obj_type obj_type; /* differentiates connection from applet context */
|
||||||
const struct protocol *ctrl; /* operations at the socket layer */
|
const struct protocol *ctrl; /* operations at the socket layer */
|
||||||
const struct xprt_ops *xprt; /* operations at the transport layer */
|
const struct xprt_ops *xprt; /* operations at the transport layer */
|
||||||
const struct data_cb *data; /* data layer callbacks */
|
const struct data_cb *data; /* data layer callbacks */
|
||||||
|
@ -37,6 +37,7 @@ enum obj_type {
|
|||||||
OBJ_TYPE_PROXY, /* object is a struct proxy */
|
OBJ_TYPE_PROXY, /* object is a struct proxy */
|
||||||
OBJ_TYPE_SERVER, /* object is a struct server */
|
OBJ_TYPE_SERVER, /* object is a struct server */
|
||||||
OBJ_TYPE_APPLET, /* object is a struct si_applet */
|
OBJ_TYPE_APPLET, /* object is a struct si_applet */
|
||||||
|
OBJ_TYPE_CONN, /* object is a struct connection */
|
||||||
OBJ_TYPE_ENTRIES /* last one : number of entries */
|
OBJ_TYPE_ENTRIES /* last one : number of entries */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user