Skip to content

Commit

Permalink
Always return correct network interface when queried (only valid when…
Browse files Browse the repository at this point in the history
… connected though!)

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed Sep 9, 2013
1 parent 120caa5 commit c7d4b6e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/usb_moded-config.c
Expand Up @@ -34,6 +34,7 @@
#include <glib/gkeyfile.h>
#include <glib/gstdio.h>
*/
#include "usb_moded.h"
#include "usb_moded-config.h"
#include "usb_moded-config-private.h"
#include "usb_moded-log.h"
Expand Down Expand Up @@ -386,6 +387,7 @@ int set_network_setting(const char *config, const char *setting)
const char * get_network_setting(const char *config)
{
const char * ret = 0;
struct mode_list_elem *data;

if(!strcmp(config, NETWORK_IP_KEY))
{
Expand All @@ -395,7 +397,15 @@ const char * get_network_setting(const char *config)
}
else if(!strcmp(config, NETWORK_INTERFACE_KEY))
{

data = get_usb_mode_data();
if(data)
{
if(data->network_interface)
{
ret = strdup(data->network_interface);
goto end;
}
}
ret = get_network_interface();
if(!ret)
ret = strdup("usb0");
Expand All @@ -405,6 +415,7 @@ const char * get_network_setting(const char *config)
else
/* no matching keys, return error */
return(NULL);
end:
return(ret);
}

Expand Down
3 changes: 3 additions & 0 deletions src/usb_moded-network.c
Expand Up @@ -49,8 +49,11 @@ static char* get_interface(struct mode_list_elem *data)
{
if(data->network_interface)
{
/*
interface = malloc(32*sizeof(char));
strncpy(interface, data->network_interface, 32);
*/
strdup(data->network_interface);
}
}
else
Expand Down

0 comments on commit c7d4b6e

Please sign in to comment.