Revision: 45611
http://sourceforge.net/p/vice-emu/code/45611
Author: gpz
Date: 2025-03-31 01:04:31 +0000 (Mon, 31 Mar 2025)
Log Message:
-----------
add missing commandline- and gui options. implement some kind of fake 'dhcp'
Modified Paths:
--------------
trunk/vice/doc/vice.texi
trunk/vice/src/arch/gtk3/widgets/settings_userport.c
trunk/vice/src/arch/sdl/menu_wic64.c
trunk/vice/src/userport/userport_wic64.c
Modified: trunk/vice/doc/vice.texi
===================================================================
--- trunk/vice/doc/vice.texi 2025-03-31 00:33:42 UTC (rev 45610)
+++ trunk/vice/doc/vice.texi 2025-03-31 01:04:31 UTC (rev 45611)
@@ -8802,9 +8802,14 @@
@vindex WIC64IPAddress
@item WIC64IPAddress
-String specifying the IP address used by the wic64 emulation
+String specifying the IP address used by the wic64 emulation (if DHCP is disabled)
(vic20, x64, x64sc, xscpu64 and x128 only).
+@vindex WIC64DHCP
+@item WIC64DHCP
+Boolean specifying whether the WiC64 local IP address should be choosen automatically
+(vic20, x64, x64sc, xscpu64 and x128 only).
+
@vindex WIC64Logenabled
@item WIC64Logenabled
Integer, 1: user selected WiC64 tracing, 0: no tracing
@@ -8893,6 +8898,27 @@
Timeout to wait for URLs in seconds, 1 - 255
(vic20, x64, x64sc, xscpu64 and x128 only).
+@findex -wic64ipaddress
+@item -wic64ipaddress <IP>
+Specify WiC64 IP (when DHCP is disabled)
+(vic20, x64, x64sc, xscpu64 and x128 only).
+
+@findex -wic64macaddress
+@item -wic64macaddress <MAC>
+Specify WiC64 MAC
+(vic20, x64, x64sc, xscpu64 and x128 only).
+
+@findex -wic64token
+@item -wic64token <token>
+Specify WiC64 security token
+(vic20, x64, x64sc, xscpu64 and x128 only).
+
+@findex -wic64dhcp, +wic64dhcp
+@item -wic64dhcp
+@itemx +wic64dhcp
+Enable/disable automatically setting the local IP address (default: enabled)
+(vic20, x64, x64sc, xscpu64 and x128 only).
+
@end table
@c -----------------------------------------------------------------------------
Modified: trunk/vice/src/arch/gtk3/widgets/settings_userport.c
===================================================================
--- trunk/vice/src/arch/gtk3/widgets/settings_userport.c 2025-03-31 00:33:42 UTC (rev 45610)
+++ trunk/vice/src/arch/gtk3/widgets/settings_userport.c 2025-03-31 01:04:31 UTC (rev 45611)
@@ -358,7 +358,7 @@
"Enable WiC64 logging");
}
-/** \brief Create widget for the "WIC64Logenabled" resource
+/** \brief Create widget for the "WIC64Resetuser" resource
*
* \return GtkCheckButton
*/
@@ -398,7 +398,7 @@
return combo;
}
-#if 0 /* disabled, as security token editable actually makes no sense */
+#if 1 /* disabled, as security token editable actually makes no sense */
/** \brief Handler for the 'icon-press' event of the "Security token" entry
*
* Toggle visibility of the WIC64 security token when clicking the "eye" icon
@@ -441,8 +441,21 @@
vice_gtk3_resource_entry_factory(wic64_server_save);
vice_gtk3_resource_spin_int_factory(wic64_remote_timeout_save);
vice_gtk3_resource_combo_int_sync(wic64_tz_save);
+ /* FIXME: also update MAC, SecToken */
}
+/** \brief Handler for the 'clicked' event of the 'dhcp' checkbox
+ *
+ * \param[in] widget checkbox triggering the event
+ * \param[in] user_data the textfield to enable/disable accordingly
+ */
+static void on_wic64_dhcp_clicked(GtkWidget *dhcp, gpointer p)
+{
+ GtkWidget *ip_addr = p;
+ gboolean enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dhcp)) ^ 1;
+ gtk_widget_set_sensitive(ip_addr, enabled);
+}
+
/** \brief Append WIC64 widgets to the main grid
*
* \param[in] parent_grid main grid
@@ -460,11 +473,11 @@
GtkWidget *resetuser;
GtkWidget *lines_widget;
GtkWidget *trace_level;
-#if 0
GtkWidget *mac_addr;
GtkWidget *ip_addr;
GtkWidget *sec_token;
-#endif
+ GtkWidget *dhcp;
+
GtkWidget *reset;
int row = 0;
@@ -494,7 +507,6 @@
gtk_grid_attach(GTK_GRID(grid), server, 1, row, 1, 1);
row++;
-#if 0
label = label_helper("MAC address");
mac_addr = vice_gtk3_resource_entry_new("WIC64MACAddress");
gtk_widget_set_hexpand(mac_addr, TRUE);
@@ -504,12 +516,16 @@
label = label_helper("IP address");
ip_addr = vice_gtk3_resource_entry_new("WIC64IPAddress");
+ dhcp = vice_gtk3_resource_check_button_new("WIC64DHCP", "DHCP");
gtk_widget_set_hexpand(ip_addr, TRUE);
gtk_grid_attach(GTK_GRID(grid), label, 0, row, 1, 1);
gtk_grid_attach(GTK_GRID(grid), ip_addr, 1, row, 1, 1);
+ gtk_grid_attach(GTK_GRID(grid), dhcp, 2, row, 1, 1);
row++;
-#endif
+ g_signal_connect(dhcp, "clicked", G_CALLBACK(on_wic64_dhcp_clicked), ip_addr);
+ gtk_widget_set_sensitive(ip_addr, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dhcp)) ^ 1);
+
label = label_helper("Timezone");
wic64_tz_save = tz_widget = create_wic64_timezone_combo();
gtk_widget_set_hexpand(tz_widget, TRUE);
@@ -517,7 +533,7 @@
gtk_grid_attach(GTK_GRID(grid), tz_widget, 1, row, 1, 1);
row++;
-#if 0 /* keep it for now, as it was @compyx's fun to hack it ;-) */
+#if 1 /* keep it for now, as it was @compyx's fun to hack it ;-) */
label = label_helper("Security token");
sec_token = vice_gtk3_resource_entry_new("WIC64SecToken");
gtk_widget_set_hexpand(sec_token, TRUE);
Modified: trunk/vice/src/arch/sdl/menu_wic64.c
===================================================================
--- trunk/vice/src/arch/sdl/menu_wic64.c 2025-03-31 00:33:42 UTC (rev 45610)
+++ trunk/vice/src/arch/sdl/menu_wic64.c 2025-03-31 01:04:31 UTC (rev 45611)
@@ -44,7 +44,6 @@
static ui_menu_entry_t *dyn_menu_wic64;
UI_MENU_DEFINE_TOGGLE(WIC64Logenabled)
-UI_MENU_DEFINE_TOGGLE(WIC64ColorizeLog)
UI_MENU_DEFINE_INT(WIC64Hexdumplines);
UI_MENU_DEFINE_INT(WIC64RemoteTimeout);
UI_MENU_DEFINE_INT(WIC64LogLevel);
@@ -51,6 +50,10 @@
UI_MENU_DEFINE_STRING(WIC64DefaultServer)
UI_MENU_DEFINE_TOGGLE(WIC64Resetuser)
UI_MENU_DEFINE_RADIO(WIC64Timezone);
+UI_MENU_DEFINE_STRING(WIC64SecToken)
+UI_MENU_DEFINE_STRING(WIC64IPAddress)
+UI_MENU_DEFINE_STRING(WIC64MACAddress)
+UI_MENU_DEFINE_TOGGLE(WIC64DHCP)
/** \brief Generate WiC64 runtime timezones menu
*
@@ -96,7 +99,7 @@
return NULL;
}
-#define MENTRIES 12
+#define MENTRIES 16
ui_menu_entry_t wic64_menu[MENTRIES];
ui_callback_data_t uiwic64_menu_create(void)
@@ -123,53 +126,52 @@
j++;
wic64_menu[j].action = ACTION_NONE;
- wic64_menu[j].string = "WiC64 tracing";
- wic64_menu[j].type = MENU_ENTRY_RESOURCE_TOGGLE;
- wic64_menu[j].callback = toggle_WIC64Logenabled_callback;
+ wic64_menu[j].string = "Remote Timeout";
+ wic64_menu[j].type = MENU_ENTRY_RESOURCE_INT;
+ wic64_menu[j].callback = int_WIC64RemoteTimeout_callback;
wic64_menu[j].data = NULL;
j++;
wic64_menu[j].action = ACTION_NONE;
- wic64_menu[j].string = "Hexdump lines (0=unlimited):";
- wic64_menu[j].type = MENU_ENTRY_RESOURCE_INT;
- wic64_menu[j].callback = int_WIC64Hexdumplines_callback;
+ wic64_menu[j].string = "Default server:";
+ wic64_menu[j].type = MENU_ENTRY_RESOURCE_STRING;
+ wic64_menu[j].callback = string_WIC64DefaultServer_callback;
wic64_menu[j].data = NULL;
j++;
wic64_menu[j].action = ACTION_NONE;
- wic64_menu[j].string = "Remote Timeout";
- wic64_menu[j].type = MENU_ENTRY_RESOURCE_INT;
- wic64_menu[j].callback = int_WIC64RemoteTimeout_callback;
- wic64_menu[j].data = NULL;
+ wic64_menu[j].string = "Timezone";
+ wic64_menu[j].type = MENU_ENTRY_DYNAMIC_SUBMENU;
+ wic64_menu[j].callback = submenu_radio_callback;
+ wic64_menu[j].data = dyn_menu_wic64;
j++;
wic64_menu[j].action = ACTION_NONE;
- wic64_menu[j].string = "Colorized tracing";
+ wic64_menu[j].string = "DHCP (set IP automatically)";
wic64_menu[j].type = MENU_ENTRY_RESOURCE_TOGGLE;
- wic64_menu[j].callback = toggle_WIC64ColorizeLog_callback;
+ wic64_menu[j].callback = toggle_WIC64DHCP_callback;
wic64_menu[j].data = NULL;
j++;
wic64_menu[j].action = ACTION_NONE;
- sprintf(tl, "Trace level (0..%d, 0: off)", WIC64_MAXTRACELEVEL);
- wic64_menu[j].string = tl;
- wic64_menu[j].type = MENU_ENTRY_RESOURCE_INT;
- wic64_menu[j].callback = int_WIC64LogLevel_callback;
+ wic64_menu[j].string = "IP Address:";
+ wic64_menu[j].type = MENU_ENTRY_RESOURCE_STRING;
+ wic64_menu[j].callback = string_WIC64IPAddress_callback;
wic64_menu[j].data = NULL;
j++;
wic64_menu[j].action = ACTION_NONE;
- wic64_menu[j].string = "Default server:";
+ wic64_menu[j].string = "MAC Address:";
wic64_menu[j].type = MENU_ENTRY_RESOURCE_STRING;
- wic64_menu[j].callback = string_WIC64DefaultServer_callback;
+ wic64_menu[j].callback = string_WIC64MACAddress_callback;
wic64_menu[j].data = NULL;
j++;
wic64_menu[j].action = ACTION_NONE;
- wic64_menu[j].string = "Timezone";
- wic64_menu[j].type = MENU_ENTRY_DYNAMIC_SUBMENU;
- wic64_menu[j].callback = submenu_radio_callback;
- wic64_menu[j].data = dyn_menu_wic64;
+ wic64_menu[j].string = "Security Token:";
+ wic64_menu[j].type = MENU_ENTRY_RESOURCE_STRING;
+ wic64_menu[j].callback = string_WIC64SecToken_callback;
+ wic64_menu[j].data = NULL;
j++;
wic64_menu[j].action = ACTION_NONE;
@@ -185,6 +187,29 @@
wic64_menu[j].callback = custom_wic64_reset_callback;
wic64_menu[j].data = NULL;
j++;
+
+ wic64_menu[j].action = ACTION_NONE;
+ wic64_menu[j].string = "WiC64 tracing";
+ wic64_menu[j].type = MENU_ENTRY_RESOURCE_TOGGLE;
+ wic64_menu[j].callback = toggle_WIC64Logenabled_callback;
+ wic64_menu[j].data = NULL;
+ j++;
+
+ wic64_menu[j].action = ACTION_NONE;
+ wic64_menu[j].string = "Hexdump lines (0=unlimited):";
+ wic64_menu[j].type = MENU_ENTRY_RESOURCE_INT;
+ wic64_menu[j].callback = int_WIC64Hexdumplines_callback;
+ wic64_menu[j].data = NULL;
+ j++;
+
+ wic64_menu[j].action = ACTION_NONE;
+ sprintf(tl, "Trace level (0..%d, 0: off)", WIC64_MAXTRACELEVEL);
+ wic64_menu[j].string = tl;
+ wic64_menu[j].type = MENU_ENTRY_RESOURCE_INT;
+ wic64_menu[j].callback = int_WIC64LogLevel_callback;
+ wic64_menu[j].data = NULL;
+ j++;
+
wic64_menu[j].string = NULL;
if (j >= MENTRIES) {
log_error(LOG_DEFAULT, "internal error: %s, %d >= MENTRIES(%d)", __FUNCTION__, j, MENTRIES);
Modified: trunk/vice/src/userport/userport_wic64.c
===================================================================
--- trunk/vice/src/userport/userport_wic64.c 2025-03-31 00:33:42 UTC (rev 45610)
+++ trunk/vice/src/userport/userport_wic64.c 2025-03-31 01:04:31 UTC (rev 45611)
@@ -104,6 +104,7 @@
static int wic64_set_ipaddress(const char *val, void *p);
static int wic64_set_sectoken(const char *val, void *p);
static int wic64_set_timezone(int val, void *param);
+static int wic64_set_dhcp(int val, void *param);
static int wic64_set_logenabled(int val, void *param);
static int wic64_set_loglevel(int val, void *param);
static int wic64_set_resetuser(int val, void *param);
@@ -170,6 +171,7 @@
static char *wic64_mac_address = NULL; /* c-string std. notation e.g 0a:02:0b:04:05:0c */
static char *wic64_internal_ip = NULL; /* c-string std. notation e.g. 192.168.1.10 */
static unsigned char wic64_external_ip[4] = { 0, 0, 0, 0 }; /* just a dummy, report not implemented to user cmd 0x13 */
+
static uint8_t wic64_timezone[2] = { 0, 0};
static uint16_t wic64_udp_port = 0;
static uint16_t wic64_tcp_port = 0;
@@ -179,7 +181,8 @@
static uint8_t wic64_remote_timeout_triggered = 0;
static int force_timeout = 0;
static char *wic64_sec_token = NULL;
-static int current_tz = 2;
+static int current_tz = 2; /* WIC64Timezone */
+static int current_dhcp = 1; /* WIC64DHCP */
static int wic64_logenabled = 0;
static int wic64_loglevel = 0;
static int wic64_resetuser = 0;
@@ -304,15 +307,19 @@
/* ---------------------------------------------------------------------*/
+#define IPADDR_INVALID "255.255.255.255"
+#define MACADDR_INVALID "FF:FF:FF:FF:FF:FF"
+#define SECTOKEN_INVALID "0123456789ab"
+
static const resource_string_t wic64_resources[] =
{
{ "WIC64DefaultServer", "http://x.wic64.net/", (resource_event_relevant_t)0, NULL,
&default_server_hostname, wic64_set_default_server, NULL },
- { "WIC64MACAddress", "DEADBE", (resource_event_relevant_t)0, NULL,
+ { "WIC64MACAddress", MACADDR_INVALID, (resource_event_relevant_t)0, NULL,
(char **) &wic64_mac_address, wic64_set_macaddress, NULL },
- { "WIC64IPAddress", "AAAA", (resource_event_relevant_t)0, NULL,
+ { "WIC64IPAddress", IPADDR_INVALID, (resource_event_relevant_t)0, NULL,
(char **) &wic64_internal_ip, wic64_set_ipaddress, NULL },
- { "WIC64SecToken", "0123456789ab", (resource_event_relevant_t)0, NULL,
+ { "WIC64SecToken", SECTOKEN_INVALID, (resource_event_relevant_t)0, NULL,
(char **) &wic64_sec_token, wic64_set_sectoken, NULL },
RESOURCE_STRING_LIST_END,
};
@@ -320,6 +327,8 @@
static const resource_int_t wic64_resources_int[] = {
{ "WIC64Timezone", 2, RES_EVENT_NO, NULL,
¤t_tz, wic64_set_timezone, NULL },
+ { "WIC64DHCP", 1, RES_EVENT_NO, NULL,
+ ¤t_dhcp, wic64_set_dhcp, NULL },
{ "WIC64Logenabled", 0, RES_EVENT_NO, NULL,
&wic64_logenabled, wic64_set_logenabled, NULL },
{ "WIC64LogLevel", 0, RES_EVENT_NO, NULL,
@@ -376,6 +385,21 @@
{ "-wic64timezone", SET_RESOURCE, CMDLINE_ATTRIB_NEED_ARGS,
NULL, NULL, "WIC64Timezone", NULL,
"<0..31>", "Specify default timezone index, e.g. 2: European Central Time" },
+ { "-wic64ipaddress", SET_RESOURCE, CMDLINE_ATTRIB_NEED_ARGS,
+ NULL, NULL, "WIC64IPAddress", NULL,
+ "<IP>", "Specify WiC64 IP" },
+ { "-wic64macaddress", SET_RESOURCE, CMDLINE_ATTRIB_NEED_ARGS,
+ NULL, NULL, "WIC64MACAddress", NULL,
+ "<MAC>", "Specify WiC64 MAC" },
+ { "-wic64token", SET_RESOURCE, CMDLINE_ATTRIB_NEED_ARGS,
+ NULL, NULL, "WIC64SecToken", NULL,
+ "<token>", "Specify WiC64 security token" },
+ { "-wic64dhcp", SET_RESOURCE, CMDLINE_ATTRIB_NONE,
+ NULL, NULL, "WIC64DHCP", (void *)1,
+ NULL, "Enable WiC64 DHCP" },
+ { "+wic64DHCP", SET_RESOURCE, CMDLINE_ATTRIB_NONE,
+ NULL, NULL, "WIC64DHCP", (void *)0,
+ NULL, "Disable WiC64 DHCP" },
{ "-wic64trace", SET_RESOURCE, CMDLINE_ATTRIB_NONE,
NULL, NULL, "WIC64Logenabled", (void *)1,
NULL, "Enable WiC64 tracing" },
@@ -635,18 +659,42 @@
static int wic64_set_macaddress(const char *val, void *v)
{
- util_string_set((char **)&wic64_mac_address, val);
- return 0;
+ unsigned int a, b, c, d, e, f;
+ int ret;
+ /* validate string */
+ ret = sscanf(val, "%02x:%02x:%02x:%02x:%02x:%02x", &a, &b, &c, &d, &e, &f);
+ if ((ret == 6) &&
+ (/*(a >= 0) &&*/ (a <= 255)) &&
+ (/*(b >= 0) &&*/ (b <= 255)) &&
+ (/*(c >= 0) &&*/ (c <= 255)) &&
+ (/*(d >= 0) &&*/ (d <= 255)) &&
+ (/*(e >= 0) &&*/ (e <= 255)) &&
+ (/*(f >= 0) &&*/ (f <= 255))) {
+ util_string_set((char **)&wic64_mac_address, val);
+ return 0;
+ }
+ return -1;
}
static int wic64_set_ipaddress(const char *val, void *v)
{
- util_string_set((char **)&wic64_internal_ip, val);
- return 0;
+ int ret, a, b, c, d;
+ /* validate string */
+ ret = sscanf(val, "%d.%d.%d.%d", &a, &b, &c, &d);
+ if ((ret == 4) &&
+ ((a >= 0) && (a <= 255)) &&
+ ((b >= 0) && (b <= 255)) &&
+ ((c >= 0) && (c <= 255)) &&
+ ((d >= 0) && (d <= 255))) {
+ util_string_set((char **)&wic64_internal_ip, val);
+ return 0;
+ }
+ return -1;
}
static int wic64_set_sectoken(const char *val, void *v)
{
+ /* TODO: validate string */
util_string_set((char **)&wic64_sec_token, val);
return 0;
}
@@ -657,6 +705,12 @@
return 0;
}
+static int wic64_set_dhcp(int val, void *param)
+{
+ current_dhcp = val;
+ return 0;
+}
+
static int wic64_set_logenabled(int val, void *param)
{
wic64_logenabled = val;
@@ -778,7 +832,7 @@
lib_unsigned_rand(0, 15),
lib_unsigned_rand(0, 15));
resources_set_string("WIC64MACAddress", tmp);
- resources_set_string("WIC64SecToken", "0123456789ab");
+ resources_set_string("WIC64SecToken", SECTOKEN_INVALID);
}
void userport_wic64_factory_reset(void)
@@ -2541,10 +2595,60 @@
}
}
+/*
+ return a reasonable "local IP"
+
+ this is used in two cases:
+ - the WIC64IPAddress in the config is empty, and WIC64DHCP is 0. In that
+ case we use the local IP as default
+ - WIC64DHCP is 1. In that case we should always use the local IP
+
+ Note: This is a surprisingly non trivial operation. For instance, due to
+ the high level approach of the emulation, we can't really tell what our
+ local IP is, without trying to connect somewhere.
+
+ What we really intend to do here, is determining the IP address, which will
+ be used by libcurl when we make connections, so it can be shown to the user
+ in the emulation.
+*/
+static int getlocalip(char *str)
+{
+ char *ip;
+ CURLcode res;
+ CURL *c = curl_easy_init();
+
+ *str = 0;
+
+ /* try to connect to the default server */
+ curl_easy_setopt(c, CURLOPT_URL, default_server_hostname);
+ curl_easy_setopt(c, CURLOPT_CONNECT_ONLY, 0);
+
+ /* Perform the connect */
+ res = curl_easy_perform(c);
+ /* Check for errors */
+ if((res == CURLE_OK) &&
+ !curl_easy_getinfo(c, CURLINFO_LOCAL_IP, &ip) && ip) {
+ /* if the connection was successful, libcurl will return the local ip */
+ strcpy(str, ip);
+ } else {
+ /* as a last resort, just produce a random 'local' IP */
+ snprintf(str, 16, "192.168.%u.%u",
+ lib_unsigned_rand(1, 254),
+ lib_unsigned_rand(1, 254));
+ }
+
+ /* always cleanup */
+ curl_easy_reset(c);
+ curl_easy_cleanup(c);
+
+ return 0;
+}
+
static void userport_wic64_reset(void)
{
char *tmp;
int tmp_tz;
+ int tmp_dhcp;
wic64_log(CONS_COL_NO, "%s", __FUNCTION__);
commandptr = input_state = input_length = force_timeout = 0;
@@ -2553,36 +2657,6 @@
memset(sec_token, 0, 32);
sec_init = 0;
- if ((resources_get_string("WIC64MACAddress", (const char **)&tmp) == -1) ||
- (tmp == NULL) ||
- (strcmp((const char*)tmp, "DEADBE") == 0)) {
- wic64_mac_address = lib_malloc(32);
- snprintf(wic64_mac_address, 32, "08:d1:f9:%02x:%02x:%02x",
- lib_unsigned_rand(0, 15),
- lib_unsigned_rand(0, 15),
- lib_unsigned_rand(0, 15));
- debug_log(CONS_COL_NO, 2, "WIC64: generated MAC: %s", wic64_mac_address);
- } else {
- wic64_mac_address = tmp;
- }
-
- if ((resources_get_string("WIC64IPAddress", (const char **)&tmp) == -1) ||
- (tmp == NULL) ||
- (strcmp((const char *)tmp, "AAAA") == 0)) {
- wic64_internal_ip = lib_malloc(16);
- snprintf(wic64_internal_ip, 16, "192.168.%u.%u",
- lib_unsigned_rand(1, 254),
- lib_unsigned_rand(1, 254));
- debug_log(CONS_COL_NO, 2, "WIC64: generated internal IP: %s", wic64_internal_ip);
- } else {
- wic64_internal_ip = tmp;
- }
- if (resources_get_int("WIC64Timezone", &tmp_tz) == -1) {
- current_tz = 2;
- } else {
- current_tz = tmp_tz;
- }
-
if (http_get_alarm) {
alarm_unset(http_get_alarm);
}
@@ -2617,6 +2691,58 @@
lib_free(post_url);
post_url = NULL;
}
+
+ if (resources_get_int("WIC64Timezone", &tmp_tz) == -1) {
+ current_tz = 2;
+ } else {
+ current_tz = tmp_tz;
+ }
+
+ if (resources_get_int("WIC64DHCP", &tmp_dhcp) == -1) {
+ current_dhcp = 1;
+ } else {
+ current_dhcp = tmp_dhcp;
+ }
+
+ if ((resources_get_string("WIC64MACAddress", (const char **)&tmp) == -1) ||
+ (tmp == NULL) ||
+ (strcmp((const char*)tmp, MACADDR_INVALID) == 0)) {
+ /* if MAC is empty in the config, then generate a random one and save it
+ in the resource */
+ wic64_mac_address = lib_malloc(32);
+ snprintf(wic64_mac_address, 32, "08:d1:f9:%02x:%02x:%02x",
+ lib_unsigned_rand(0, 15),
+ lib_unsigned_rand(0, 15),
+ lib_unsigned_rand(0, 15));
+ debug_log(CONS_COL_NO, 2, "WIC64: generated MAC: %s", wic64_mac_address);
+ } else {
+ wic64_mac_address = tmp;
+ debug_log(CONS_COL_NO, 2, "WIC64: using saved MAC: %s", wic64_mac_address);
+ }
+
+ if (current_dhcp) {
+ if (wic64_internal_ip == NULL) {
+ wic64_internal_ip = lib_malloc(16);
+ }
+ getlocalip(wic64_internal_ip);
+ debug_log(CONS_COL_NO, 2, "WIC64: generated internal IP: %s", wic64_internal_ip);
+ }
+
+ if ((resources_get_string("WIC64IPAddress", (const char **)&tmp) == -1) ||
+ (tmp == NULL) ||
+ (strcmp((const char *)tmp, IPADDR_INVALID) == 0)) {
+ /* ip is empty */
+ if (wic64_internal_ip == NULL) {
+ wic64_internal_ip = lib_malloc(16);
+ }
+ getlocalip(wic64_internal_ip);
+ debug_log(CONS_COL_NO, 2, "WIC64: generated internal IP: %s", wic64_internal_ip);
+ } else {
+ /* use saved ip */
+ wic64_internal_ip = tmp;
+ }
+
+
/* wic64_set_status("RESET"); real HW doesn't tell this */
wic64_log(LOG_COL_LBLUE, "cyan color: host -> WiC64 communication");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|