mirror of
https://github.com/solemnwarning/ipxwrapper
synced 2024-12-30 16:45:37 +01:00
Add options for DOSBox encapsulation to ipxconfig.
Been sitting on this for a while, the code to actually support interacting with a DOSBox IPX server isn't done yet.
This commit is contained in:
parent
9f8cbdfb55
commit
5c65628fca
88
src/common.c
88
src/common.c
@ -1,5 +1,5 @@
|
|||||||
/* IPXWrapper - Common functions
|
/* IPXWrapper - Common functions
|
||||||
* Copyright (C) 2011 Daniel Collins <solemnwarning@solemnwarning.net>
|
* Copyright (C) 2011-2021 Daniel Collins <solemnwarning@solemnwarning.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU General Public License version 2 as published by
|
* under the terms of the GNU General Public License version 2 as published by
|
||||||
@ -224,6 +224,92 @@ bool reg_set_addr48(HKEY key, const char *name, addr48_t value)
|
|||||||
return reg_set_bin(key, name, buf, sizeof(buf));
|
return reg_set_bin(key, name, buf, sizeof(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Read a string value from the registry.
|
||||||
|
*
|
||||||
|
* Returns the value or default_value in a newly allocated buffer. The caller
|
||||||
|
* is responsible for freeing it.
|
||||||
|
*/
|
||||||
|
char *reg_get_string(HKEY key, const char *name, const char *default_value)
|
||||||
|
{
|
||||||
|
if(key != NULL)
|
||||||
|
{
|
||||||
|
DWORD value_type;
|
||||||
|
DWORD value_size = 0;
|
||||||
|
|
||||||
|
LSTATUS reg_err = RegQueryValueEx(key, name, NULL, &value_type, NULL, &value_size);
|
||||||
|
if(reg_err == ERROR_SUCCESS || reg_err == ERROR_MORE_DATA)
|
||||||
|
{
|
||||||
|
if(value_type == REG_SZ)
|
||||||
|
{
|
||||||
|
size_t buffer_size = value_size + 1; /* Extra space for nul terminator. */
|
||||||
|
char *buffer = malloc(buffer_size);
|
||||||
|
|
||||||
|
if(buffer != NULL)
|
||||||
|
{
|
||||||
|
reg_err = RegQueryValueEx(key, name, NULL, &value_type, (BYTE*)(buffer), &value_size);
|
||||||
|
if(reg_err == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
if(value_type == REG_SZ)
|
||||||
|
{
|
||||||
|
buffer[value_size] = '\0';
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
log_printf(LOG_ERROR, "Expected REG_SZ value, got type %u", (unsigned)(value_type));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(reg_err != ERROR_FILE_NOT_FOUND)
|
||||||
|
{
|
||||||
|
log_printf(LOG_ERROR, "Error reading registry: %s", w32_error(reg_err));
|
||||||
|
}
|
||||||
|
|
||||||
|
free(buffer);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
log_printf(LOG_ERROR, "Memory alloation failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
log_printf(LOG_ERROR, "Expected REG_SZ value, got type %u", (unsigned)(value_type));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(reg_err != ERROR_FILE_NOT_FOUND)
|
||||||
|
{
|
||||||
|
log_printf(LOG_ERROR, "Error reading registry: %s", w32_error(reg_err));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
char *default_copy = strdup(default_value);
|
||||||
|
if(default_copy == NULL)
|
||||||
|
{
|
||||||
|
log_printf(LOG_ERROR, "Memory alloation failed");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
return default_copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Store a string value in the registry.
|
||||||
|
* Returns true on success, false on failure.
|
||||||
|
*/
|
||||||
|
bool reg_set_string(HKEY key, const char *name, const char *value)
|
||||||
|
{
|
||||||
|
if(key != NULL)
|
||||||
|
{
|
||||||
|
int err = RegSetValueEx(key, name, 0, REG_SZ, (BYTE*)(value), strlen(value));
|
||||||
|
|
||||||
|
if(err == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
log_printf(LOG_ERROR, "Error writing registry value: %s", w32_error(err));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void load_dll(unsigned int dllnum) {
|
void load_dll(unsigned int dllnum) {
|
||||||
char path[512];
|
char path[512];
|
||||||
const char *dll;
|
const char *dll;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* IPXWrapper - Common header
|
/* IPXWrapper - Common header
|
||||||
* Copyright (C) 2011 Daniel Collins <solemnwarning@solemnwarning.net>
|
* Copyright (C) 2011-2021 Daniel Collins <solemnwarning@solemnwarning.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU General Public License version 2 as published by
|
* under the terms of the GNU General Public License version 2 as published by
|
||||||
@ -59,6 +59,9 @@ bool reg_set_addr32(HKEY key, const char *name, addr32_t value);
|
|||||||
addr48_t reg_get_addr48(HKEY key, const char *name, addr48_t default_value);
|
addr48_t reg_get_addr48(HKEY key, const char *name, addr48_t default_value);
|
||||||
bool reg_set_addr48(HKEY key, const char *name, addr48_t value);
|
bool reg_set_addr48(HKEY key, const char *name, addr48_t value);
|
||||||
|
|
||||||
|
char *reg_get_string(HKEY key, const char *name, const char *default_value);
|
||||||
|
bool reg_set_string(HKEY key, const char *name, const char *value);
|
||||||
|
|
||||||
void load_dll(unsigned int dllnum);
|
void load_dll(unsigned int dllnum);
|
||||||
void unload_dlls(void);
|
void unload_dlls(void);
|
||||||
void __stdcall *find_sym(unsigned int dllnum, const char *symbol);
|
void __stdcall *find_sym(unsigned int dllnum, const char *symbol);
|
||||||
|
19
src/config.c
19
src/config.c
@ -1,5 +1,5 @@
|
|||||||
/* ipxwrapper - Configuration header
|
/* ipxwrapper - Configuration header
|
||||||
* Copyright (C) 2011-2013 Daniel Collins <solemnwarning@solemnwarning.net>
|
* Copyright (C) 2011-2021 Daniel Collins <solemnwarning@solemnwarning.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU General Public License version 2 as published by
|
* under the terms of the GNU General Public License version 2 as published by
|
||||||
@ -30,10 +30,13 @@ main_config_t get_main_config(void)
|
|||||||
config.udp_port = DEFAULT_PORT;
|
config.udp_port = DEFAULT_PORT;
|
||||||
config.w95_bug = true;
|
config.w95_bug = true;
|
||||||
config.fw_except = false;
|
config.fw_except = false;
|
||||||
config.use_pcap = false;
|
config.encap_type = ENCAP_TYPE_IPXWRAPPER;
|
||||||
config.frame_type = FRAME_TYPE_ETH_II;
|
config.frame_type = FRAME_TYPE_ETH_II;
|
||||||
config.log_level = LOG_INFO;
|
config.log_level = LOG_INFO;
|
||||||
|
|
||||||
|
config.dosbox_server_addr = NULL;
|
||||||
|
config.dosbox_server_port = 213;
|
||||||
|
|
||||||
HKEY reg = reg_open_main(false);
|
HKEY reg = reg_open_main(false);
|
||||||
|
|
||||||
/* Load pre-0.4.x "global" config structure and values. */
|
/* Load pre-0.4.x "global" config structure and values. */
|
||||||
@ -53,10 +56,13 @@ main_config_t get_main_config(void)
|
|||||||
config.udp_port = reg_get_dword(reg, "port", config.udp_port);
|
config.udp_port = reg_get_dword(reg, "port", config.udp_port);
|
||||||
config.w95_bug = reg_get_dword(reg, "w95_bug", config.w95_bug);
|
config.w95_bug = reg_get_dword(reg, "w95_bug", config.w95_bug);
|
||||||
config.fw_except = reg_get_dword(reg, "fw_except", config.fw_except);
|
config.fw_except = reg_get_dword(reg, "fw_except", config.fw_except);
|
||||||
config.use_pcap = reg_get_dword(reg, "use_pcap", config.use_pcap);
|
config.encap_type = reg_get_dword(reg, "use_pcap", config.encap_type);
|
||||||
config.frame_type = reg_get_dword(reg, "frame_type", config.frame_type);
|
config.frame_type = reg_get_dword(reg, "frame_type", config.frame_type);
|
||||||
config.log_level = reg_get_dword(reg, "log_level", config.log_level);
|
config.log_level = reg_get_dword(reg, "log_level", config.log_level);
|
||||||
|
|
||||||
|
config.dosbox_server_addr = reg_get_string(reg, "dosbox_server_addr", "");
|
||||||
|
config.dosbox_server_port = reg_get_dword(reg, "dosbox_server_port", config.dosbox_server_port);
|
||||||
|
|
||||||
/* Check for valid frame_type */
|
/* Check for valid frame_type */
|
||||||
|
|
||||||
if( config.frame_type != FRAME_TYPE_ETH_II
|
if( config.frame_type != FRAME_TYPE_ETH_II
|
||||||
@ -82,9 +88,12 @@ bool set_main_config(const main_config_t *config)
|
|||||||
bool ok = reg_set_dword(reg, "port", config->udp_port)
|
bool ok = reg_set_dword(reg, "port", config->udp_port)
|
||||||
&& reg_set_dword(reg, "w95_bug", config->w95_bug)
|
&& reg_set_dword(reg, "w95_bug", config->w95_bug)
|
||||||
&& reg_set_dword(reg, "fw_except", config->fw_except)
|
&& reg_set_dword(reg, "fw_except", config->fw_except)
|
||||||
&& reg_set_dword(reg, "use_pcap", config->use_pcap)
|
&& reg_set_dword(reg, "use_pcap", config->encap_type)
|
||||||
&& reg_set_dword(reg, "frame_type", config->frame_type)
|
&& reg_set_dword(reg, "frame_type", config->frame_type)
|
||||||
&& reg_set_dword(reg, "log_level", config->log_level);
|
&& reg_set_dword(reg, "log_level", config->log_level)
|
||||||
|
|
||||||
|
&& reg_set_string(reg, "dosbox_server_addr", config->dosbox_server_addr)
|
||||||
|
&& reg_set_dword(reg, "dosbox_server_port", config->dosbox_server_port);
|
||||||
|
|
||||||
reg_close(reg);
|
reg_close(reg);
|
||||||
|
|
||||||
|
14
src/config.h
14
src/config.h
@ -1,5 +1,5 @@
|
|||||||
/* ipxwrapper - Configuration header
|
/* ipxwrapper - Configuration header
|
||||||
* Copyright (C) 2011-2013 Daniel Collins <solemnwarning@solemnwarning.net>
|
* Copyright (C) 2011-2021 Daniel Collins <solemnwarning@solemnwarning.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU General Public License version 2 as published by
|
* under the terms of the GNU General Public License version 2 as published by
|
||||||
@ -26,6 +26,13 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
enum main_config_encap_type
|
||||||
|
{
|
||||||
|
ENCAP_TYPE_IPXWRAPPER = 0,
|
||||||
|
ENCAP_TYPE_PCAP = 1,
|
||||||
|
ENCAP_TYPE_DOSBOX = 2,
|
||||||
|
};
|
||||||
|
|
||||||
enum main_config_frame_type
|
enum main_config_frame_type
|
||||||
{
|
{
|
||||||
FRAME_TYPE_ETH_II = 1,
|
FRAME_TYPE_ETH_II = 1,
|
||||||
@ -38,9 +45,12 @@ typedef struct main_config {
|
|||||||
|
|
||||||
bool w95_bug;
|
bool w95_bug;
|
||||||
bool fw_except;
|
bool fw_except;
|
||||||
bool use_pcap;
|
enum main_config_encap_type encap_type;
|
||||||
enum main_config_frame_type frame_type;
|
enum main_config_frame_type frame_type;
|
||||||
|
|
||||||
|
char *dosbox_server_addr;
|
||||||
|
uint16_t dosbox_server_port;
|
||||||
|
|
||||||
enum ipx_log_level log_level;
|
enum ipx_log_level log_level;
|
||||||
} main_config_t;
|
} main_config_t;
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
|||||||
/* ipxwrapper - Library functions
|
/* ipxwrapper - Library functions
|
||||||
* Copyright (C) 2008-2014 Daniel Collins <solemnwarning@solemnwarning.net>
|
* Copyright (C) 2008-2021 Daniel Collins <solemnwarning@solemnwarning.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU General Public License version 2 as published by
|
* under the terms of the GNU General Public License version 2 as published by
|
||||||
@ -81,7 +81,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|||||||
|
|
||||||
main_config = get_main_config();
|
main_config = get_main_config();
|
||||||
min_log_level = main_config.log_level;
|
min_log_level = main_config.log_level;
|
||||||
ipx_use_pcap = main_config.use_pcap;
|
ipx_use_pcap = main_config.encap_type == ENCAP_TYPE_PCAP;
|
||||||
|
|
||||||
if(main_config.fw_except)
|
if(main_config.fw_except)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user