1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-09-19 18:20:40 +03:00

Cedar: improve constness of PROTO_IMPL functions, move Name() at the top

This commit is contained in:
Davide Beatrici 2020-07-17 02:55:47 +02:00
parent b57a4b051b
commit cd850c07ae
5 changed files with 21 additions and 22 deletions

View File

@ -24,9 +24,9 @@ typedef struct PROTO
typedef struct PROTO_IMPL typedef struct PROTO_IMPL
{ {
const char *(*Name)();
bool (*Init)(void **param, CEDAR *cedar, INTERRUPT_MANAGER *im, SOCK_EVENT *se, const char *cipher, const char *hostname); bool (*Init)(void **param, CEDAR *cedar, INTERRUPT_MANAGER *im, SOCK_EVENT *se, const char *cipher, const char *hostname);
void (*Free)(void *param); void (*Free)(void *param);
char *(*Name)();
bool (*IsPacketForMe)(const PROTO_MODE mode, const UCHAR *data, const UINT size); bool (*IsPacketForMe)(const PROTO_MODE mode, const UCHAR *data, const UINT size);
bool (*ProcessData)(void *param, TCP_RAW_DATA *in, FIFO *out); bool (*ProcessData)(void *param, TCP_RAW_DATA *in, FIFO *out);
bool (*ProcessDatagrams)(void *param, LIST *in, LIST *out); bool (*ProcessDatagrams)(void *param, LIST *in, LIST *out);

View File

@ -14,13 +14,13 @@ static UCHAR ping_signature[] =
0x07, 0xed, 0x2d, 0x0a, 0x98, 0x1f, 0xc7, 0x48 0x07, 0xed, 0x2d, 0x0a, 0x98, 0x1f, 0xc7, 0x48
}; };
PROTO_IMPL *OvsGetProtoImpl() const PROTO_IMPL *OvsGetProtoImpl()
{ {
static PROTO_IMPL impl = static const PROTO_IMPL impl =
{ {
OvsName,
OvsInit, OvsInit,
OvsFree, OvsFree,
OvsName,
OvsIsPacketForMe, OvsIsPacketForMe,
OvsProcessData, OvsProcessData,
OvsProcessDatagrams OvsProcessDatagrams
@ -29,6 +29,11 @@ PROTO_IMPL *OvsGetProtoImpl()
return &impl; return &impl;
} }
const char *OvsName()
{
return "OpenVPN";
}
bool OvsInit(void **param, CEDAR *cedar, INTERRUPT_MANAGER *im, SOCK_EVENT *se, const char *cipher, const char *hostname) bool OvsInit(void **param, CEDAR *cedar, INTERRUPT_MANAGER *im, SOCK_EVENT *se, const char *cipher, const char *hostname)
{ {
if (param == NULL || cedar == NULL || im == NULL || se == NULL) if (param == NULL || cedar == NULL || im == NULL || se == NULL)
@ -48,12 +53,6 @@ void OvsFree(void *param)
FreeOpenVpnServer(param); FreeOpenVpnServer(param);
} }
// Return the protocol name
char *OvsName()
{
return "OpenVPN";
}
// Check whether it's an OpenVPN packet // Check whether it's an OpenVPN packet
bool OvsIsPacketForMe(const PROTO_MODE mode, const UCHAR *data, const UINT size) bool OvsIsPacketForMe(const PROTO_MODE mode, const UCHAR *data, const UINT size)
{ {

View File

@ -208,10 +208,10 @@ struct OPENVPN_SERVER
#define OVPN_DEF_CLIENT_OPTION_STRING "dev-type tun,link-mtu 1500,tun-mtu 1500,cipher AES-128-CBC,auth SHA1,keysize 128,key-method 2,tls-client" #define OVPN_DEF_CLIENT_OPTION_STRING "dev-type tun,link-mtu 1500,tun-mtu 1500,cipher AES-128-CBC,auth SHA1,keysize 128,key-method 2,tls-client"
//// Function prototype //// Function prototype
PROTO_IMPL *OvsGetProtoImpl(); const PROTO_IMPL *OvsGetProtoImpl();
const char *OvsName();
bool OvsInit(void **param, CEDAR *cedar, INTERRUPT_MANAGER *im, SOCK_EVENT *se, const char *cipher, const char *hostname); bool OvsInit(void **param, CEDAR *cedar, INTERRUPT_MANAGER *im, SOCK_EVENT *se, const char *cipher, const char *hostname);
void OvsFree(void *param); void OvsFree(void *param);
char *OvsName();
bool OvsIsPacketForMe(const PROTO_MODE mode, const UCHAR *data, const UINT size); bool OvsIsPacketForMe(const PROTO_MODE mode, const UCHAR *data, const UINT size);
bool OvsProcessData(void *param, TCP_RAW_DATA *in, FIFO *out); bool OvsProcessData(void *param, TCP_RAW_DATA *in, FIFO *out);
bool OvsProcessDatagrams(void *param, LIST *in, LIST *out); bool OvsProcessDatagrams(void *param, LIST *in, LIST *out);

View File

@ -16,13 +16,13 @@ bool GetNoSstp()
return g_no_sstp; return g_no_sstp;
} }
PROTO_IMPL *SstpGetProtoImpl() const PROTO_IMPL *SstpGetProtoImpl()
{ {
static PROTO_IMPL impl = static const PROTO_IMPL impl =
{ {
SstpName,
SstpInit, SstpInit,
SstpFree, SstpFree,
SstpName,
NULL, NULL,
SstpProcessData, SstpProcessData,
NULL NULL
@ -31,6 +31,11 @@ PROTO_IMPL *SstpGetProtoImpl()
return &impl; return &impl;
} }
const char *SstpName()
{
return "SSTP";
}
bool SstpInit(void **param, struct CEDAR *cedar, INTERRUPT_MANAGER *im, SOCK_EVENT *se, const char *cipher, const char *hostname) bool SstpInit(void **param, struct CEDAR *cedar, INTERRUPT_MANAGER *im, SOCK_EVENT *se, const char *cipher, const char *hostname)
{ {
if (param == NULL || cedar == NULL || im == NULL || se == NULL) if (param == NULL || cedar == NULL || im == NULL || se == NULL)
@ -50,11 +55,6 @@ void SstpFree(void *param)
FreeSstpServer(param); FreeSstpServer(param);
} }
char *SstpName()
{
return "SSTP";
}
bool SstpProcessData(void *param, TCP_RAW_DATA *in, FIFO *out) bool SstpProcessData(void *param, TCP_RAW_DATA *in, FIFO *out)
{ {
FIFO *recv_fifo; FIFO *recv_fifo;

View File

@ -122,10 +122,10 @@ struct SSTP_SERVER
//// Function prototype //// Function prototype
PROTO_IMPL *SstpGetProtoImpl(); const PROTO_IMPL *SstpGetProtoImpl();
const char *SstpName();
bool SstpInit(void **param, struct CEDAR *cedar, INTERRUPT_MANAGER *im, SOCK_EVENT *se, const char *cipher, const char *hostname); bool SstpInit(void **param, struct CEDAR *cedar, INTERRUPT_MANAGER *im, SOCK_EVENT *se, const char *cipher, const char *hostname);
void SstpFree(void *param); void SstpFree(void *param);
char *SstpName();
bool SstpProcessData(void *param, TCP_RAW_DATA *in, FIFO *out); bool SstpProcessData(void *param, TCP_RAW_DATA *in, FIFO *out);
SSTP_SERVER *NewSstpServer(CEDAR *cedar, INTERRUPT_MANAGER *im, SOCK_EVENT *se, const char *cipher, const char *hostname); SSTP_SERVER *NewSstpServer(CEDAR *cedar, INTERRUPT_MANAGER *im, SOCK_EVENT *se, const char *cipher, const char *hostname);