Future DCO code will require accessing the `multi` member of the
context object.
For this reason a pointer to the context has to be stored in the
DCO context along with the rest.
At this point, rather than making the call to ovpn_dco_init()
longer with more and more parameters, pass the struct context
only and let the implementation extract the needed fields.
Change-Id: I673a17f8c5dec66cc6c28c1ed44780a7a63927d7
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <
20250723133918.19431-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg32293.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
/**
* Initialize the DCO context
*
- * @param mode the instance operating mode (P2P or multi-peer)
- * @param dco the context to initialize
- * @param dev_node device node, used on Windows to specify certain DCO adapter
+ * @param c the main instance context
* @return true on success, false otherwise
*/
-bool ovpn_dco_init(int mode, dco_context_t *dco, const char *dev_node);
+bool ovpn_dco_init(struct context *c);
/**
* Open/create a DCO interface
}
static inline bool
-ovpn_dco_init(int mode, dco_context_t *dco, const char *dev_node)
+ovpn_dco_init(struct context *c)
{
return true;
}
}
bool
-ovpn_dco_init(int mode, dco_context_t *dco, const char *dev_node)
+ovpn_dco_init(struct context *c)
{
- if (open_fd(dco) < 0)
+ if (open_fd(&c->c1.tuntap->dco) < 0)
{
msg(M_ERR, "Failed to open socket");
return false;
}
bool
-ovpn_dco_init(int mode, dco_context_t *dco, const char *dev_node)
+ovpn_dco_init(struct context *c)
{
- switch (mode)
+ dco_context_t *dco = &c->c1.tuntap->dco;
+
+ switch (c->mode)
{
case CM_TOP:
dco->ifmode = OVPN_MODE_MP;
ASSERT(false);
}
+ /* store pointer to context as it may be required by message
+ * parsing routines
+ */
+ dco->c = c;
ovpn_dco_init_netlink(dco);
return true;
}
struct nl_cb *nl_cb;
int status;
+ struct context *c;
+
enum ovpn_mode ifmode;
int ovpn_dco_id;
* state. The server socket should be initialized later by dco_mp_start_vpn().
*/
bool
-ovpn_dco_init(int mode, dco_context_t *dco, const char *dev_node)
+ovpn_dco_init(struct context *c)
{
- switch (mode)
+ dco_context_t *dco = &c->c1.tuntap->dco;
+
+ switch (c->mode)
{
case MODE_POINT_TO_POINT:
dco->ifmode = DCO_MODE_P2P;
break;
case MODE_SERVER:
- ovpn_dco_init_mp(dco, dev_node);
+ ovpn_dco_init_mp(dco, c->options.dev_node);
break;
default:
if (dco_enabled(&c->options))
{
- ovpn_dco_init(c->mode, &c->c1.tuntap->dco, c->options.dev_node);
+ ovpn_dco_init(c);
}
/* open the tun device */