Пример #1
0
uint8_t
params_get_eui64(uint8_t *eui64) {
    size_t size = sizeof(rimeaddr_t);
    if(settings_get(SETTINGS_KEY_EUI64, 0, (unsigned char*)eui64, &size) == SETTINGS_STATUS_OK) {
        PRINTD("<-Get EUI64 MAC\n");
        return 0;
    }
#if CONTIKI_CONF_RANDOM_MAC
    PRINTD("Generating random EUI64 MAC\n");
    generate_new_eui64(eui64);
#else
    {
        uint8_t i;    //test this
        for (i=0; i<8; i++) eui64[i] = pgm_read_byte_near(default_mac_address+i);
    }
#endif
    if (settings_add(SETTINGS_KEY_EUI64,(unsigned char*)eui64,8) == SETTINGS_STATUS_OK) {
        PRINTD("->Set EEPROM MAC address\n");
    }
#if CONTIKI_CONF_RANDOM_MAC
    return 1;
#else
    return 0;
#endif
}
Пример #2
0
void settings_add_size_module(const char *module, const char *section,
			      const char *key, const char *def)
{
	SettingValue default_value;

	memset(&default_value, 0, sizeof(default_value));
	default_value.v_string = g_strdup(def);
	settings_add(module, section, key, SETTING_TYPE_SIZE, &default_value, NULL);
}
Пример #3
0
void settings_add_bool_module(const char *module, const char *section,
			      const char *key, int def)
{
	SettingValue default_value;

	memset(&default_value, 0, sizeof(default_value));
        default_value.v_bool = def;
	settings_add(module, section, key, SETTING_TYPE_BOOLEAN, &default_value, NULL);
}
Пример #4
0
void settings_add_choice_module(const char *module, const char *section,
				const char *key, int def, const char *choices)
{
	SettingValue default_value;

	memset(&default_value, 0, sizeof(default_value));
	default_value.v_int = def;
	settings_add(module, section, key, SETTING_TYPE_CHOICE, &default_value, choices);
}
Пример #5
0
void settings_add_int_module(const char *module, const char *section,
			     const char *key, int def)
{
	SettingValue default_value;

	memset(&default_value, 0, sizeof(default_value));
        default_value.v_int = def;
	settings_add(module, section, key, SETTING_TYPE_INT, &default_value);
}
Пример #6
0
static bool get_eui64_from_eeprom(uint8_t macptr[8]) {
	size_t size = 8;
	if(settings_get(SETTINGS_KEY_EUI64, 0, (unsigned char*)macptr, &size)==SETTINGS_STATUS_OK) {
      PRINTD("<=Get EEPROM MAC address.\n");
      return true;		
    }
#if JACKDAW_CONF_RANDOM_MAC
    PRINTA("--Generating random MAC address.\n");
    generate_new_eui64(macptr);
#else
    {uint8_t i;for (i=0;i<8;i++) macptr[i] = pgm_read_byte_near(default_mac_address+i);}
#endif
    settings_add(SETTINGS_KEY_EUI64,(unsigned char*)macptr,8);
    PRINTA("->Set EEPROM MAC address.\n");
	return true;
}
Пример #7
0
int
wl_save(struct tab *t, struct karg *args, int list)
{
	char			file[PATH_MAX], *lst_str = NULL;
	FILE			*f = NULL;
	char			*line = NULL, *lt = NULL, *dom;
	size_t			linelen;
	const gchar		*uri;
	struct karg		a;
	struct domain		*d;
	GSList			*cf;
	SoupCookie		*ci, *c;

	if (t == NULL || args == NULL)
		return (1);

	if (runtime_settings[0] == '\0')
		return (1);

	switch (list) {
	case XT_WL_JAVASCRIPT:
		lst_str = "JavaScript";
		break;
	case XT_WL_COOKIE:
		lst_str = "Cookie";
		break;
	case XT_WL_PLUGIN:
		lst_str = "Plugin";
		break;
	default:
		show_oops(t, "Invalid list id: %d", list);
		return (1);
	}

	uri = get_uri(t);
	dom = find_domain(uri, args->i & XT_WL_TOPLEVEL);
	if (uri == NULL || dom == NULL ||
	    webkit_web_view_get_load_status(t->wv) == WEBKIT_LOAD_FAILED) {
		show_oops(t, "Can't add domain to %s white list", lst_str);
		goto done;
	}

	switch (list) {
	case XT_WL_JAVASCRIPT:
		lt = g_strdup_printf("js_wl=%s", dom);
		break;
	case XT_WL_COOKIE:
		lt = g_strdup_printf("cookie_wl=%s", dom);
		break;
	case XT_WL_PLUGIN:
		lt = g_strdup_printf("pl_wl=%s", dom);
		break;
	default:
		/* can't happen */
		show_oops(t, "Invalid list id: %d", list);
		goto done;
	}

	snprintf(file, sizeof file, "%s" PS "%s", work_dir, runtime_settings);
	if ((f = fopen(file, "r+")) == NULL) {
		show_oops(t, "can't open file %s");
		goto done;
	}

	while (!feof(f)) {
		line = fparseln(f, &linelen, NULL, NULL, 0);
		if (line == NULL)
			continue;
		if (!strcmp(line, lt))
			goto done;
		free(line);
		line = NULL;
	}

	fprintf(f, "%s\n", lt);

	a.i = XT_WL_ENABLE;
	a.i |= args->i;
	switch (list) {
	case XT_WL_JAVASCRIPT:
		d = wl_find(dom, &js_wl);
		if (!d) {
			settings_add("js_wl", dom);
			d = wl_find(dom, &js_wl);
		}
		toggle_js(t, &a);
		break;

	case XT_WL_COOKIE:
		d = wl_find(dom, &c_wl);
		if (!d) {
			settings_add("cookie_wl", dom);
			d = wl_find(dom, &c_wl);
		}
		toggle_cwl(t, &a);

		/* find and add to persistent jar */
		cf = soup_cookie_jar_all_cookies(s_cookiejar);
		for (;cf; cf = cf->next) {
			ci = cf->data;
			if (!strcmp(dom, ci->domain) ||
			    !strcmp(&dom[1], ci->domain)) /* deal with leading . */ {
				c = soup_cookie_copy(ci);
				_soup_cookie_jar_add_cookie(p_cookiejar, c);
			}
		}
		soup_cookies_free(cf);
		break;

	case XT_WL_PLUGIN:
		d = wl_find(dom, &pl_wl);
		if (!d) {
			settings_add("pl_wl", dom);
			d = wl_find(dom, &pl_wl);
		}
		toggle_pl(t, &a);
		break;
	default:
		abort(); /* can't happen */
	}
	if (d)
		d->handy = 1;

done:
	if (line)
		free(line);
	if (dom)
		g_free(dom);
	if (lt)
		g_free(lt);
	if (f)
		fclose(f);

	return (0);
}