mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2024-11-22 09:29:52 +03:00
Cedar: Add ProtoOptionString() in PROTO_IMPL, to generate default option values
The WireGuard implementation will have two options that should not have a fixed default value, because they represent two keys (one is preshared, the other is private). Instead of handling these two options differently in ProtoNewContainer(), this commit adds a new function to PROTO_IMPL: ProtoOptionString(). ProtoOptionString() takes the option's name as argument and returns a heap-allocated string that will be used as value. The function returns NULL when the option doesn't need a randomized value.
This commit is contained in:
parent
d8aa470192
commit
decfcecc97
@ -291,7 +291,7 @@ PROTO_CONTAINER *ProtoContainerNew(const PROTO_IMPL *impl)
|
|||||||
option->Bool = impl_option->Bool;
|
option->Bool = impl_option->Bool;
|
||||||
break;
|
break;
|
||||||
case PROTO_OPTION_STRING:
|
case PROTO_OPTION_STRING:
|
||||||
option->String = CopyStr(impl_option->String);
|
option->String = impl_option->String != NULL ? CopyStr(impl_option->String) : impl->OptionStringValue(option->Name);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Debug("ProtoContainerNew(): unhandled option type %u!\n", impl_option->Type);
|
Debug("ProtoContainerNew(): unhandled option type %u!\n", impl_option->Type);
|
||||||
|
@ -46,6 +46,7 @@ typedef struct PROTO_IMPL
|
|||||||
{
|
{
|
||||||
const char *(*Name)();
|
const char *(*Name)();
|
||||||
const PROTO_OPTION *(*Options)();
|
const PROTO_OPTION *(*Options)();
|
||||||
|
char *(*OptionStringValue)(const char *name);
|
||||||
bool (*Init)(void **param, const LIST *options, CEDAR *cedar, INTERRUPT_MANAGER *im, SOCK_EVENT *se, const char *cipher, const char *hostname);
|
bool (*Init)(void **param, const LIST *options, CEDAR *cedar, INTERRUPT_MANAGER *im, SOCK_EVENT *se, const char *cipher, const char *hostname);
|
||||||
void (*Free)(void *param);
|
void (*Free)(void *param);
|
||||||
bool (*IsPacketForMe)(const PROTO_MODE mode, const void *data, const UINT size);
|
bool (*IsPacketForMe)(const PROTO_MODE mode, const void *data, const UINT size);
|
||||||
|
@ -20,6 +20,7 @@ const PROTO_IMPL *OvsGetProtoImpl()
|
|||||||
{
|
{
|
||||||
OvsName,
|
OvsName,
|
||||||
OvsOptions,
|
OvsOptions,
|
||||||
|
NULL,
|
||||||
OvsInit,
|
OvsInit,
|
||||||
OvsFree,
|
OvsFree,
|
||||||
OvsIsPacketForMe,
|
OvsIsPacketForMe,
|
||||||
|
@ -13,6 +13,7 @@ const PROTO_IMPL *SstpGetProtoImpl()
|
|||||||
{
|
{
|
||||||
SstpName,
|
SstpName,
|
||||||
SstpOptions,
|
SstpOptions,
|
||||||
|
NULL,
|
||||||
SstpInit,
|
SstpInit,
|
||||||
SstpFree,
|
SstpFree,
|
||||||
NULL,
|
NULL,
|
||||||
|
Loading…
Reference in New Issue
Block a user