Commit 42eb1eda authored by spiiroin's avatar spiiroin

Merge branch 'jb45312_sighup_corruption' into 'master'

Fix data corruption after SIGHUP config reload

See merge request mer-core/usb-moded!48
parents b6f0fdad 8a6390ec
...@@ -316,10 +316,24 @@ endif ...@@ -316,10 +316,24 @@ endif
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
.SUFFIXES: .q .p .g .SUFFIXES: .q .p .g
.PRECIOUS: .q
%.q : %.c ; $(CC) -o $@ -E $< $(CPPFLAGS) $(MCE_CFLAGS)
%.p : %.q ; cproto -s < $< | prettyproto.py > $@ PROTO_CPPFLAGS += -DAPP_SYNC
%.g : %.q ; cproto < $< | prettyproto.py > $@ PROTO_CPPFLAGS += -DAPP_SYNC_DBUS
PROTO_CPPFLAGS += -DCONNMAN
PROTO_CPPFLAGS += -DDEAD_CODE
PROTO_CPPFLAGS += -DDEBIAN
PROTO_CPPFLAGS += -DMEEGOLOCK
PROTO_CPPFLAGS += -DOFONO
PROTO_CPPFLAGS += -DSYSTEMD
PROTO_CPPFLAGS += -DUSE_MER_SSU
PROTO_CPPFLAGS += -DCONNMAN_WORKS_BETTER=1
PROTO_CPPFLAGS += -DVERBOSE_WAKELOCKING=1
%.q : CPPFLAGS += $(PROTO_CPPFLAGS)
%.q : %.c ; $(CC) -o $@ -E $< $(CPPFLAGS) -O
%.p : %.q prettyproto.groups ; cproto -s < $< | prettyproto.py > $@
%.g : %.q prettyproto.groups ; cproto < $< | prettyproto.py > $@
clean:: clean::
$(RM) *.[qpg] src/*.[qpg] utils/*.[qpg] $(RM) *.[qpg] src/*.[qpg] utils/*.[qpg]
......
/** /**
* @file usb_moded-android.c * @file usb_moded-android.c
* *
* Copyright (C) 2013-2018 Jolla. All rights reserved. * Copyright (C) 2013-2019 Jolla. All rights reserved.
* *
* @author: Philippe De Swert <philippe.deswert@jollamobile.com> * @author: Philippe De Swert <philippe.deswert@jollamobile.com>
* @author: Simo Piiroinen <simo.piiroinen@jollamobile.com> * @author: Simo Piiroinen <simo.piiroinen@jollamobile.com>
...@@ -34,11 +34,14 @@ ...@@ -34,11 +34,14 @@
#include <stdlib.h> #include <stdlib.h>
/* ========================================================================= * /* ========================================================================= *
* Functions * Prototypes
* ========================================================================= */ * ========================================================================= */
/* -- android -- */ /* ------------------------------------------------------------------------- *
* ANDROID
* ------------------------------------------------------------------------- */
static bool android_write_file (const char *path, const char *text);
bool android_in_use (void); bool android_in_use (void);
static bool android_probe (void); static bool android_probe (void);
gchar *android_get_serial (void); gchar *android_get_serial (void);
......
/** /**
* @file usb_moded-android.h * @file usb_moded-android.h
* *
* Copyright (C) 2013-2018 Jolla. All rights reserved. * Copyright (C) 2013-2019 Jolla. All rights reserved.
* *
* @author: Philippe De Swert <philippe.deswert@jollamobile.com> * @author: Philippe De Swert <philippe.deswert@jollamobile.com>
* @author: Simo Piiroinen <simo.piiroinen@jollamobile.com> * @author: Simo Piiroinen <simo.piiroinen@jollamobile.com>
...@@ -44,7 +44,9 @@ ...@@ -44,7 +44,9 @@
* Prototypes * Prototypes
* ========================================================================= */ * ========================================================================= */
/* -- android -- */ /* ------------------------------------------------------------------------- *
* ANDROID
* ------------------------------------------------------------------------- */
bool android_in_use (void); bool android_in_use (void);
gchar *android_get_serial (void); gchar *android_get_serial (void);
......
/* /*
* Copyright (C) 2010 Nokia Corporation. All rights reserved. * Copyright (C) 2010 Nokia Corporation. All rights reserved.
* Copyright (C) 2018 Jolla Ltd. * Copyright (C) 2018-2019 Jolla Ltd.
* *
* Author: Philippe De Swert <philippe.de-swert@nokia.com> * Author: Philippe De Swert <philippe.de-swert@nokia.com>
* Author: Philippe De Swert <phdeswer@lumi.maa> * Author: Philippe De Swert <phdeswer@lumi.maa>
...@@ -33,7 +33,9 @@ ...@@ -33,7 +33,9 @@
* Prototypes * Prototypes
* ========================================================================= */ * ========================================================================= */
/* -- dbusappsync -- */ /* ------------------------------------------------------------------------- *
* DBUSAPPSYNC
* ------------------------------------------------------------------------- */
gboolean dbusappsync_init_connection(void); gboolean dbusappsync_init_connection(void);
gboolean dbusappsync_init (void); gboolean dbusappsync_init (void);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @file usb_moded-dbus.c * @file usb_moded-dbus.c
* *
* Copyright (C) 2010 Nokia Corporation. All rights reserved. * Copyright (C) 2010 Nokia Corporation. All rights reserved.
* Copyright (C) 2013-2018 Jolla Ltd. * Copyright (C) 2013-2019 Jolla Ltd.
* *
* @author: Philippe De Swert <philippe.de-swert@nokia.com> * @author: Philippe De Swert <philippe.de-swert@nokia.com>
* @author: Philippe De Swert <phdeswer@lumi.maa> * @author: Philippe De Swert <phdeswer@lumi.maa>
...@@ -38,7 +38,9 @@ ...@@ -38,7 +38,9 @@
* Prototypes * Prototypes
* ========================================================================= */ * ========================================================================= */
/* -- dbusappsync -- */ /* ------------------------------------------------------------------------- *
* DBUSAPPSYNC
* ------------------------------------------------------------------------- */
static void dbusappsync_release_name (void); static void dbusappsync_release_name (void);
static gboolean dbusappsync_obtain_name (void); static gboolean dbusappsync_obtain_name (void);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @file usb_moded-appsync.c * @file usb_moded-appsync.c
* *
* Copyright (C) 2010 Nokia Corporation. All rights reserved. * Copyright (C) 2010 Nokia Corporation. All rights reserved.
* Copyright (C) 2013-2018 Jolla Ltd. * Copyright (C) 2013-2019 Jolla Ltd.
* *
* @author: Philippe De Swert <philippe.de-swert@nokia.com> * @author: Philippe De Swert <philippe.de-swert@nokia.com>
* @author: Philippe De Swert <phdeswer@lumi.maa> * @author: Philippe De Swert <phdeswer@lumi.maa>
...@@ -40,27 +40,27 @@ ...@@ -40,27 +40,27 @@
* Prototypes * Prototypes
* ========================================================================= */ * ========================================================================= */
/* -- appsync -- */ /* ------------------------------------------------------------------------- *
* APPSYNC
static void appsync_free_elem (list_elem_t *elem); * ------------------------------------------------------------------------- */
static void appsync_free_elem_cb (gpointer elem, gpointer user_data);
void appsync_free_appsync_list (void); static void appsync_free_elem (list_elem_t *elem);
static gint appsync_list_sort_func (gconstpointer a, gconstpointer b); static void appsync_free_elem_cb (gpointer elem, gpointer user_data);
void appsync_read_list (int diag); void appsync_free_appsync_list (void);
static list_elem_t *appsync_read_file (const gchar *filename, int diag); static gint appsync_list_sort_func (gconstpointer a, gconstpointer b);
int appsync_activate_sync (const char *mode); void appsync_read_list (int diag);
int appsync_activate_sync_post (const char *mode); static list_elem_t *appsync_read_file (const gchar *filename, int diag);
int appsync_mark_active (const gchar *name, int post); int appsync_activate_sync (const char *mode);
int appsync_activate_sync_post (const char *mode);
int appsync_mark_active (const gchar *name, int post);
#ifdef APP_SYNC_DBUS #ifdef APP_SYNC_DBUS
static gboolean appsync_enumerate_usb_cb (gpointer data); static gboolean appsync_enumerate_usb_cb (gpointer data);
static void appsync_start_enumerate_usb_timer (void); static void appsync_start_enumerate_usb_timer (void);
static void appsync_cancel_enumerate_usb_timer(void); static void appsync_cancel_enumerate_usb_timer(void);
static void appsync_enumerate_usb (void); static void appsync_enumerate_usb (void);
#endif #endif // APP_SYNC_DBUS
void appsync_stop_apps (int post);
void appsync_stop_apps (int post); int appsync_stop (gboolean force);
int appsync_stop (gboolean force);
/* ========================================================================= * /* ========================================================================= *
* Data * Data
......
/* /*
* Copyright (C) 2010 Nokia Corporation. All rights reserved. * Copyright (C) 2010 Nokia Corporation. All rights reserved.
* Copyright (C) 2013-2018 Jolla Ltd. * Copyright (C) 2013-2019 Jolla Ltd.
* *
* author: Philippe De Swert <philippe.de-swert@nokia.com> * author: Philippe De Swert <philippe.de-swert@nokia.com>
* author: Philippe De Swert <phdeswer@lumi.maa> * author: Philippe De Swert <phdeswer@lumi.maa>
...@@ -74,14 +74,16 @@ typedef struct list_elem_t ...@@ -74,14 +74,16 @@ typedef struct list_elem_t
* Prototypes * Prototypes
* ========================================================================= */ * ========================================================================= */
/* -- appsync -- */ /* ------------------------------------------------------------------------- *
* APPSYNC
* ------------------------------------------------------------------------- */
void appsync_free_appsync_list (void); void appsync_free_appsync_list (void);
void appsync_read_list (int diag); void appsync_read_list (int diag);
int appsync_activate_sync (const char *mode); int appsync_activate_sync (const char *mode);
int appsync_activate_sync_post(const char *mode); int appsync_activate_sync_post(const char *mode);
int appsync_mark_active (const gchar *name, int post); int appsync_mark_active (const gchar *name, int post);
int appsync_stop (gboolean force);
void appsync_stop_apps (int post); void appsync_stop_apps (int post);
int appsync_stop (gboolean force);
#endif /* USB_MODED_APPSYNC_H_ */ #endif /* USB_MODED_APPSYNC_H_ */
...@@ -35,11 +35,15 @@ typedef struct modemapping_t ...@@ -35,11 +35,15 @@ typedef struct modemapping_t
* Prototypes * Prototypes
* ========================================================================= */ * ========================================================================= */
/* -- cable -- */ /* ------------------------------------------------------------------------- *
* CABLE_STATE
* ------------------------------------------------------------------------- */
const char *cable_state_repr(cable_state_t state); const char *cable_state_repr(cable_state_t state);
/* -- common -- */ /* ------------------------------------------------------------------------- *
* COMMON
* ------------------------------------------------------------------------- */
const char *common_map_mode_to_hardware (const char *internal_mode); const char *common_map_mode_to_hardware (const char *internal_mode);
const char *common_map_mode_to_external (const char *internal_mode); const char *common_map_mode_to_external (const char *internal_mode);
...@@ -55,6 +59,7 @@ FILE *common_popen_ (const char *file, int line, co ...@@ -55,6 +59,7 @@ FILE *common_popen_ (const char *file, int line, co
waitres_t common_wait (unsigned tot_ms, bool (*ready_cb)(void *aptr), void *aptr); waitres_t common_wait (unsigned tot_ms, bool (*ready_cb)(void *aptr), void *aptr);
bool common_msleep_ (const char *file, int line, const char *func, unsigned msec); bool common_msleep_ (const char *file, int line, const char *func, unsigned msec);
static bool common_mode_in_list (const char *mode, char *const *modes); static bool common_mode_in_list (const char *mode, char *const *modes);
bool common_modename_is_internal (const char *modename);
int common_valid_mode (const char *mode); int common_valid_mode (const char *mode);
gchar *common_get_mode_list (mode_list_type_t type); gchar *common_get_mode_list (mode_list_type_t type);
...@@ -439,6 +444,25 @@ static bool common_mode_in_list(const char *mode, char * const *modes) ...@@ -439,6 +444,25 @@ static bool common_mode_in_list(const char *mode, char * const *modes)
return false; return false;
} }
/** Check if given usb mode is internal
*
* @param modename name of a more
*
* @return true if mode is internal, false otherwise
*/
bool
common_modename_is_internal(const char *modename)
{
LOG_REGISTER_CONTEXT;
return (!g_strcmp0(modename, MODE_UNDEFINED) ||
!g_strcmp0(modename, MODE_CHARGER) ||
!g_strcmp0(modename, MODE_CHARGING_FALLBACK) ||
!g_strcmp0(modename, MODE_ASK) ||
!g_strcmp0(modename, MODE_CHARGING) ||
!g_strcmp0(modename, MODE_BUSY));
}
/** check if a given usb_mode exists /** check if a given usb_mode exists
* *
* @param mode The mode to look for * @param mode The mode to look for
...@@ -457,24 +481,21 @@ int common_valid_mode(const char *mode) ...@@ -457,24 +481,21 @@ int common_valid_mode(const char *mode)
} }
else else
{ {
gchar *whitelist_value = 0; const modedata_t *data = usbmoded_get_modedata(mode);
gchar **whitelist_array = 0;
if( (whitelist_value = config_get_mode_whitelist()) ) if( data ) {
whitelist_array = g_strsplit(whitelist_value, ",", 0); gchar *whitelist_value = 0;
gchar **whitelist_array = 0;
for( GList *iter = usbmoded_get_modelist(); iter; iter = g_list_next(iter) ) { if( (whitelist_value = config_get_mode_whitelist()) )
mode_list_elem_t *data = iter->data; whitelist_array = g_strsplit(whitelist_value, ",", 0);
if( strcmp(mode, data->mode_name) )
continue;
if (!whitelist_array || common_mode_in_list(data->mode_name, whitelist_array)) if (!whitelist_array || common_mode_in_list(data->mode_name, whitelist_array))
valid = 0; valid = 0;
break;
}
g_strfreev(whitelist_array); g_strfreev(whitelist_array);
g_free(whitelist_value); g_free(whitelist_value);
}
} }
return valid; return valid;
} }
...@@ -521,7 +542,7 @@ gchar *common_get_mode_list(mode_list_type_t type) ...@@ -521,7 +542,7 @@ gchar *common_get_mode_list(mode_list_type_t type)
for( GList *iter = usbmoded_get_modelist(); iter; iter = g_list_next(iter) ) for( GList *iter = usbmoded_get_modelist(); iter; iter = g_list_next(iter) )
{ {
mode_list_elem_t *data = iter->data; modedata_t *data = iter->data;
/* skip items in the hidden list */ /* skip items in the hidden list */
if (common_mode_in_list(data->mode_name, hidden_modes_array)) if (common_mode_in_list(data->mode_name, hidden_modes_array))
......
...@@ -34,14 +34,18 @@ typedef enum waitres_t ...@@ -34,14 +34,18 @@ typedef enum waitres_t
} waitres_t; } waitres_t;
/* ========================================================================= * /* ========================================================================= *
* Functions * Prototypes
* ========================================================================= */ * ========================================================================= */
/* -- cable -- */ /* ------------------------------------------------------------------------- *
* CABLE_STATE
* ------------------------------------------------------------------------- */
const char *cable_state_repr(cable_state_t state); const char *cable_state_repr(cable_state_t state);
/* -- common -- */ /* ------------------------------------------------------------------------- *
* COMMON
* ------------------------------------------------------------------------- */
const char *common_map_mode_to_hardware (const char *internal_mode); const char *common_map_mode_to_hardware (const char *internal_mode);
const char *common_map_mode_to_external (const char *internal_mode); const char *common_map_mode_to_external (const char *internal_mode);
...@@ -55,6 +59,7 @@ int common_system_ (const char *file, int line, con ...@@ -55,6 +59,7 @@ int common_system_ (const char *file, int line, con
FILE *common_popen_ (const char *file, int line, const char *func, const char *command, const char *type); FILE *common_popen_ (const char *file, int line, const char *func, const char *command, const char *type);
waitres_t common_wait (unsigned tot_ms, bool (*ready_cb)(void *aptr), void *aptr); waitres_t common_wait (unsigned tot_ms, bool (*ready_cb)(void *aptr), void *aptr);
bool common_msleep_ (const char *file, int line, const char *func, unsigned msec); bool common_msleep_ (const char *file, int line, const char *func, unsigned msec);
bool common_modename_is_internal (const char *modename);
int common_valid_mode (const char *mode); int common_valid_mode (const char *mode);
gchar *common_get_mode_list (mode_list_type_t type); gchar *common_get_mode_list (mode_list_type_t type);
......
/* /*
* Copyright (C) 2010 Nokia Corporation. All rights reserved. * Copyright (C) 2010 Nokia Corporation. All rights reserved.
* Copyright (C) 2012-2018 Jolla. All rights reserved. * Copyright (C) 2012-2019 Jolla. All rights reserved.
* *
* Author: Philippe De Swert <philippe.de-swert@nokia.com> * Author: Philippe De Swert <philippe.de-swert@nokia.com>
* Author: Philippe De Swert <philippedeswert@gmail.com> * Author: Philippe De Swert <philippedeswert@gmail.com>
...@@ -53,7 +53,9 @@ ...@@ -53,7 +53,9 @@
* Prototypes * Prototypes
* ========================================================================= */ * ========================================================================= */
/* -- config -- */ /* ------------------------------------------------------------------------- *
* CONFIG
* ------------------------------------------------------------------------- */
char *config_find_mounts (void); char *config_find_mounts (void);
int config_find_sync (void); int config_find_sync (void);
...@@ -65,8 +67,8 @@ char *config_get_trigger_subsystem (void); ...@@ -65,8 +67,8 @@ char *config_get_trigger_subsystem (void);
char *config_get_trigger_mode (void); char *config_get_trigger_mode (void);
char *config_get_trigger_property (void); char *config_get_trigger_property (void);
char *config_get_trigger_value (void); char *config_get_trigger_value (void);
char *config_get_conf_string (const gchar *entry, const gchar *key);
char *config_get_mode_setting (void); char *config_get_mode_setting (void);
int config_value_changed (GKeyFile *settingsfile, const char *entry, const char *key, const char *new_value);
set_config_result_t config_set_config_setting (const char *entry, const char *key, const char *value); set_config_result_t config_set_config_setting (const char *entry, const char *key, const char *value);
set_config_result_t config_set_mode_setting (const char *mode); set_config_result_t config_set_mode_setting (const char *mode);
set_config_result_t config_set_hide_mode_setting (const char *mode); set_config_result_t config_set_hide_mode_setting (const char *mode);
...@@ -83,7 +85,6 @@ char *config_get_android_product_id (void); ...@@ -83,7 +85,6 @@ char *config_get_android_product_id (void);
char *config_get_hidden_modes (void); char *config_get_hidden_modes (void);
char *config_get_mode_whitelist (void); char *config_get_mode_whitelist (void);
int config_is_roaming_not_allowed (void); int config_is_roaming_not_allowed (void);
char *config_get_conf_string (const gchar *entry, const gchar *key);
/* ========================================================================= * /* ========================================================================= *
* Macros * Macros
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @file usb_moded-config.c * @file usb_moded-config.c
* *
* Copyright (C) 2010 Nokia Corporation. All rights reserved. * Copyright (C) 2010 Nokia Corporation. All rights reserved.
* Copyright (C) 2012-2018 Jolla. All rights reserved. * Copyright (C) 2012-2019 Jolla. All rights reserved.
* *
* @author: Philippe De Swert <philippe.de-swert@nokia.com> * @author: Philippe De Swert <philippe.de-swert@nokia.com>
* @author: Philippe De Swert <phdeswer@lumi.maa> * @author: Philippe De Swert <phdeswer@lumi.maa>
...@@ -57,7 +57,9 @@ ...@@ -57,7 +57,9 @@
* Prototypes * Prototypes
* ========================================================================= */ * ========================================================================= */
/* -- config -- */ /* ------------------------------------------------------------------------- *
* CONFIG
* ------------------------------------------------------------------------- */
static int config_validate_ip (const char *ipadd); static int config_validate_ip (const char *ipadd);
char *config_find_mounts (void); char *config_find_mounts (void);
...@@ -413,6 +415,7 @@ set_config_result_t config_set_config_setting(const char *entry, const char *key ...@@ -413,6 +415,7 @@ set_config_result_t config_set_config_setting(const char *entry, const char *key
if( g_strcmp0(prev, value) ) { if( g_strcmp0(prev, value) ) {
g_key_file_set_string(active_ini, entry, key, value); g_key_file_set_string(active_ini, entry, key, value);
ret = SET_CONFIG_UPDATED; ret = SET_CONFIG_UPDATED;
umdbus_send_config_signal(entry, key, value);
} }
/* Filter out dynamic data that matches static values */ /* Filter out dynamic data that matches static values */
...@@ -434,7 +437,11 @@ set_config_result_t config_set_mode_setting(const char *mode) ...@@ -434,7 +437,11 @@ set_config_result_t config_set_mode_setting(const char *mode)
if (strcmp(mode, MODE_ASK) && common_valid_mode(mode)) if (strcmp(mode, MODE_ASK) && common_valid_mode(mode))
return SET_CONFIG_ERROR; return SET_CONFIG_ERROR;
return config_set_config_setting(MODE_SETTING_ENTRY, MODE_SETTING_KEY, mode);
int ret = config_set_config_setting(MODE_SETTING_ENTRY,
MODE_SETTING_KEY, mode);
return ret;
} }
/* Builds the string used for hidden modes, when hide set to one builds the /* Builds the string used for hidden modes, when hide set to one builds the
...@@ -586,9 +593,7 @@ set_config_result_t config_set_mode_in_whitelist(const char *mode, int allowed) ...@@ -586,9 +593,7 @@ set_config_result_t config_set_mode_in_whitelist(const char *mode, int allowed)
char *whitelist = config_make_modes_string(MODE_WHITELIST_KEY, mode, allowed); char *whitelist = config_make_modes_string(MODE_WHITELIST_KEY, mode, allowed);
if (whitelist) { ret = config_set_mode_whitelist(whitelist ?: "");
ret = config_set_mode_whitelist(whitelist);
}
g_free(whitelist); g_free(whitelist);
...@@ -615,55 +620,50 @@ set_config_result_t config_set_network_setting(const char *config, const char *s ...@@ -615,55 +620,50 @@ set_config_result_t config_set_network_setting(const char *config, const char *s
return SET_CONFIG_ERROR; return SET_CONFIG_ERROR;
} }
char * config_get_network_setting(const char *config) char *config_get_network_setting(const char *config)
{ {
LOG_REGISTER_CONTEXT; LOG_REGISTER_CONTEXT;
char * ret = 0; char *ret = 0;
mode_list_elem_t *data;
if(!strcmp(config, NETWORK_IP_KEY)) modedata_t *data = 0;
{
ret = config_get_network_ip();
if(!ret)
ret = strdup("192.168.2.15");
}
else if(!strcmp(config, NETWORK_INTERFACE_KEY))
{
if( !g_strcmp0(config, NETWORK_IP_KEY) ) {
if( !(ret = config_get_network_ip()) )
ret = g_strdup("192.168.2.15");
}
else if( !g_strcmp0(config, NETWORK_INTERFACE_KEY)) {
/* check main configuration before using /* check main configuration before using
* the information from the specific mode */ * the information from the specific mode */
ret = config_get_network_interface(); if( (ret = config_get_network_interface()) )
goto EXIT;
if(ret)
goto end;
/* no interface override specified, let's use the one /* no interface override specified, let's use the one
* from the mode config */ * from the mode config */
data = worker_get_usb_mode_data(); if( (data = worker_dup_usb_mode_data()) ) {
if(data) if( (ret = g_strdup(data->network_interface)) )
{ goto EXIT;
if(data->network_interface)
{
ret = strdup(data->network_interface);
goto end;
}
} }
ret = strdup("usb0");
ret = g_strdup("usb0");
} }
else if(!strcmp(config, NETWORK_GATEWAY_KEY)) else if( !g_strcmp0(config, NETWORK_GATEWAY_KEY) ) {
return config_get_network_gateway(); ret = config_get_network_gateway();
else if(!strcmp(config, NETWORK_NETMASK_KEY)) }
{ else if( !g_strcmp0(config, NETWORK_NETMASK_KEY) ) {
ret = config_get_network_netmask(); if( !(ret = config_get_network_netmask()) )
if(!ret) ret = g_strdup("255.255.255.0");
ret = strdup("255.255.255.0"); }
else if( !g_strcmp0(config, NETWORK_NAT_INTERFACE_KEY) ) {
ret = config_get_network_nat_interface();
} }
else if(!strcmp(config, NETWORK_NAT_INTERFACE_KEY)) else {
return config_get_network_nat_interface();
else
/* no matching keys, return error */ /* no matching keys, return error */
return NULL; }
end:
EXIT:
modedata_free(data);
return ret; return ret;
} }
......
/** /**
* @file usb_moded-configfs.c * @file usb_moded-configfs.c
* *
* Copyright (C) 2018 Jolla. All rights reserved. * Copyright (C) 2018-2019 Jolla. All rights reserved.
* *
* @author: Simo Piiroinen <simo.piiroinen@jollamobile.com> * @author: Simo Piiroinen <simo.piiroinen@jollamobile.com>
* *
...@@ -64,7 +64,9 @@ ...@@ -64,7 +64,9 @@
* Prototypes * Prototypes
* ========================================================================= */ * ========================================================================= */
/* -- configfs -- */ /* ------------------------------------------------------------------------- *
* CONFIGFS
* ------------------------------------------------------------------------- */
static gchar *configfs_get_conf (const char *key, const char *def); static gchar *configfs_get_conf (const char *key, const char *def);
static void configfs_read_configuration (void); static void configfs_read_configuration (void);
...@@ -75,6 +77,9 @@ static const char *configfs_config_path (char *buff, size_t size, con ...@@ -75,6 +77,9 @@ static const char *configfs_config_path (char *buff, size_t size, con
static bool configfs_mkdir (const char *path); static bool configfs_mkdir (const char *path);
static bool configfs_rmdir (const char *path); static bool configfs_rmdir (const char *path);
static const char *configfs_register_function (const char *function); static const char *configfs_register_function (const char *function);
#ifdef DEAD_CODE
static bool configfs_unregister_function (const char *function);
#endif //DEAD_CODE
static const char *configfs_add_unit (const char *function, const char *unit); static const char *configfs_add_unit (const char *function, const char *unit);
static bool configfs_remove_unit (const char *function, const char *unit); static bool configfs_remove_unit (const char *function, const char *unit);
static bool configfs_enable_function (const char *function); static bool configfs_enable_function (const char *function);
...@@ -86,6 +91,9 @@ static bool configfs_probe (void); ...@@ -86,6 +91,9 @@ static bool configfs_probe (void);
static const char *configfs_udc_enable_value (void); static const char *configfs_udc_enable_value (void);
static bool configfs_write_file (const char *path, const char *text); static bool configfs_write_file (const char *path, const char *text);
static bool configfs_read_file (const char *path, char *buff, size_t size); static bool configfs_read_file (const char *path, char *buff, size_t size);
#ifdef DEAD_CODE
static bool configfs_read_udc (char *buff, size_t size);
#endif // DEAD_CODE
static bool configfs_write_udc (const char *text); static bool configfs_write_udc (const char *text);
bool configfs_set_udc (bool enable); bool configfs_set_udc (bool enable);
bool configfs_init (void); bool configfs_init (void);
......
/** /**
* @file usb_moded-configfs.h * @file usb_moded-configfs.h
* *
* Copyright (C) 2018 Jolla. All rights reserved. * Copyright (C) 2018-2019 Jolla. All rights reserved.
* *
* @author: Simo Piiroinen <simo.piiroinen@jollamobile.com> * @author: Simo Piiroinen <simo.piiroinen@jollamobile.com>
* *
...@@ -29,7 +29,9 @@ ...@@ -29,7 +29,9 @@
* Prototypes * Prototypes
* ========================================================================= */ * ========================================================================= */
/* -- configfs -- */ /* ------------------------------------------------------------------------- *
* CONFIGFS