}
/* prepares a connection with the appropriate app_cb, ctrl and data layers. The
- * data state and context are set to 0.
+ * data state and context are set to 0, and the connection's owner is set.
*/
static inline void conn_prepare(struct connection *conn, const struct app_cb *app,
- const struct protocol *ctrl, const struct data_ops *data)
+ const struct protocol *ctrl, const struct data_ops *data,
+ void *owner)
{
conn->app_cb = app;
conn->ctrl = ctrl;
conn->data = data;
+ conn->owner = owner;
conn->data_st = 0;
conn->data_ctx = NULL;
}
static inline void si_prepare_conn(struct stream_interface *si, const struct protocol *ctrl, const struct data_ops *ops)
{
si->ops = &si_conn_ops;
- conn_prepare(&si->conn, &si_conn_cb, ctrl, ops);
+ conn_prepare(&si->conn, &si_conn_cb, ctrl, ops, si);
}
static inline void si_prepare_embedded(struct stream_interface *si)
{
si->ops = &si_embedded_ops;
- conn_prepare(&si->conn, NULL, NULL, NULL);
+ conn_prepare(&si->conn, NULL, NULL, NULL, si);
}
static inline void si_prepare_task(struct stream_interface *si)
{
si->ops = &si_task_ops;
- conn_prepare(&si->conn, NULL, NULL, NULL);
+ conn_prepare(&si->conn, NULL, NULL, NULL, si);
}
/* Sends a shutr to the connection using the data layer */
const struct data_ops *data; /* operations at the data layer */
const struct protocol *ctrl; /* operations at the socket layer */
const struct app_cb *app_cb; /* application layer callbacks */
+ void *owner; /* pointer to upper layer's entity (eg: stream interface) */
union { /* definitions which depend on connection type */
struct { /*** information used by socket-based connections ***/
int fd; /* file descriptor for a stream driver when known */
struct target target; /* the target to connect to (server, proxy, applet, ...) */
struct {
struct sockaddr_storage from; /* client address, or address to spoof when connecting to the server */
- struct sockaddr_storage to; /* address reached by the client if SN_FRT_ADDR_SET is set, or address to connect to */
+ struct sockaddr_storage to; /* address reached by the client, or address to connect to */
} addr; /* addresses of the remote side, client for producer and server for consumer */
};