diff options
| author | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2007-09-28 13:25:27 +0000 | 
|---|---|---|
| committer | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2007-09-28 13:25:27 +0000 | 
| commit | ec7083e9e5ba28b679f231c7bc341330feddf2ce (patch) | |
| tree | 3a4d6f463fe5e3aabbb4fa0a74940510a72680a3 | |
| parent | 6113615ecfb8026a6a3ce0af38fc79ec8abec748 (diff) | |
Fixes codestyle, bridge creation and some code cleanup.
| -rw-r--r-- | network/common.c | 5 | ||||
| -rw-r--r-- | network/connection.c | 20 | ||||
| -rw-r--r-- | network/main.c | 7 | ||||
| -rw-r--r-- | network/manager.c | 14 | ||||
| -rw-r--r-- | network/network.conf | 2 | ||||
| -rw-r--r-- | network/server.c | 7 | 
6 files changed, 29 insertions, 26 deletions
diff --git a/network/common.c b/network/common.c index 991073ec..96821f84 100644 --- a/network/common.c +++ b/network/common.c @@ -226,6 +226,7 @@ int bnep_if_up(const char *devname, uint16_t id)  	struct ifreq ifr;  	const char *argv[3], *script;  	struct bnep_data *bnep; +	GSpawnFlags flags;  	sd = socket(AF_INET6, SOCK_DGRAM, 0);  	memset(&ifr, 0, sizeof(ifr)); @@ -256,8 +257,8 @@ int bnep_if_up(const char *devname, uint16_t id)  	argv[0] = script;  	argv[1] = devname;  	argv[2] = NULL; -	if (!g_spawn_async(NULL, (char **) argv, NULL, -				G_SPAWN_DO_NOT_REAP_CHILD, bnep_setup, +	flags = G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH; +	if (!g_spawn_async(NULL, (char **) argv, NULL, flags, bnep_setup,  				(gpointer) devname, &pid, NULL)) {  		error("Unable to execute %s", argv[0]);  		return -1; diff --git a/network/connection.c b/network/connection.c index 6157e377..245d4cc9 100644 --- a/network/connection.c +++ b/network/connection.c @@ -680,8 +680,8 @@ int connection_store(const char *path, gboolean default_path)  	char src_addr[18], dst_addr[18];  	int len, err; -	if (!dbus_connection_get_object_user_data(connection, path, -		(void *) &nc)) +	if (!dbus_connection_get_object_user_data(connection, +				path, (void *) &nc))  		return -ENOENT;  	if (!nc->name || !nc->desc) @@ -716,8 +716,8 @@ int connection_find_data(const char *path, const char *pattern)  	char addr[18], key[32];  	const char *role; -	if (!dbus_connection_get_object_user_data(connection, path, -		(void *) &nc)) +	if (!dbus_connection_get_object_user_data(connection, +		path, (void *) &nc))  		return -1;  	if (strcasecmp(pattern, nc->dev) == 0) @@ -744,8 +744,8 @@ gboolean connection_has_pending(const char *path)  {  	struct network_conn *nc; -	if (!dbus_connection_get_object_user_data(connection, path, -		(void *) &nc)) +	if (!dbus_connection_get_object_user_data(connection, +				path, (void *) &nc))  		return FALSE;  	return (nc->state == CONNECTING); @@ -760,8 +760,8 @@ int connection_remove_stored(const char *path)  	char src_addr[18], dst_addr[18];  	int err; -	if (!dbus_connection_get_object_user_data(connection, path, -		(void *) &nc)) +	if (!dbus_connection_get_object_user_data(connection, +				path, (void *) &nc))  		return -ENOENT;  	ba2str(&nc->dst, dst_addr); @@ -780,8 +780,8 @@ gboolean connection_is_connected(const char *path)  {  	struct network_conn *nc; -	if (!dbus_connection_get_object_user_data(connection, path, -		(void *) &nc)) +	if (!dbus_connection_get_object_user_data(connection, +				path, (void *) &nc))  		return FALSE;  	return (nc->state == CONNECTED); diff --git a/network/main.c b/network/main.c index 3ede75fe..6225ff4e 100644 --- a/network/main.c +++ b/network/main.c @@ -103,7 +103,7 @@ static void read_config(const char *file)  		err = NULL;  	} -	conf.security = g_key_file_get_boolean(keyfile, "General", +	conf.security = !g_key_file_get_boolean(keyfile, "General",  						"DisableSecurity", &err);  	if (err) {  		debug("%s: %s", file, err->message); @@ -155,8 +155,9 @@ static void read_config(const char *file)  		err = NULL;  	} -	debug("Config options: InterfacePrefix=%s, PANUScript=%s, GNScript=%s, " -		"NAPScript=%s, GNInterface=%s, NAPInterface=%s, Security=%s", +	debug("Config options: InterfacePrefix=%s, PANU_Script=%s, " +		"GN_Script=%s, NAP_Script=%s, GN_Interface=%s, " +		"NAP_Interface=%s, Security=%s",  		conf.iface_prefix, conf.panu_script, conf.gn_script,  		conf.nap_script, conf.gn_iface, conf.nap_iface,  		conf.security ? "true" : "false"); diff --git a/network/manager.c b/network/manager.c index c82d1c03..b5b4f0a8 100644 --- a/network/manager.c +++ b/network/manager.c @@ -928,12 +928,6 @@ int network_init(DBusConnection *conn, struct network_conf *service_conf)  		return -1;  	} -	if (bridge_create(BNEP_SVC_GN) < 0) -		error("Can't create GN bridge"); - -	if (bridge_create(BNEP_SVC_NAP) < 0) -		error("Can't create NAP bridge"); -  	if (bnep_init(conf->panu_script, conf->gn_script, conf->nap_script)) {  		error("Can't init bnep module");  		return -1; @@ -967,6 +961,12 @@ int network_init(DBusConnection *conn, struct network_conf *service_conf)  		return -1;  	} +	if (bridge_create(BNEP_SVC_GN) < 0) +		error("Can't create GN bridge"); + +	if (bridge_create(BNEP_SVC_NAP) < 0) +		error("Can't create NAP bridge"); +  	connection = dbus_connection_ref(conn);  	info("Registered manager path:%s", NETWORK_PATH); @@ -984,10 +984,10 @@ int network_init(DBusConnection *conn, struct network_conf *service_conf)  void network_exit(void)  {  	server_exit(); +	connection_exit();  	dbus_connection_destroy_object_path(connection, NETWORK_PATH);  	dbus_connection_unref(connection); -  	connection = NULL;  	if (bridge_remove(BNEP_SVC_GN) < 0) diff --git a/network/network.conf b/network/network.conf index 29e77fff..98524bfc 100644 --- a/network/network.conf +++ b/network/network.conf @@ -34,4 +34,4 @@ Script=avahi-autoipd  Interface=pan1  # Network Access Point connection interface up script. default:none -Script=/sbin/dhclient +Script=dhclient diff --git a/network/server.c b/network/server.c index 80ab49a1..de30f72e 100644 --- a/network/server.c +++ b/network/server.c @@ -80,6 +80,7 @@ struct network_server {  	char		*path;		/* D-Bus path */  	gboolean	enable;		/* Enable flag */  	gboolean	secure;		/* Security flag */ +	gboolean	up;		/* Interface up flag */  	uint32_t	record_id;	/* Service record id */  	uint16_t	id;		/* Service class identifier */  	GSList		*clients;	/* Active connections */ @@ -345,14 +346,14 @@ static void authorization_callback(DBusPendingCall *pcall, void *data)  	bridge = bridge_get_name(ns->id);  	if (bridge) {  		bnep_if_up(devname, 0); -		bnep_if_up(bridge, ns->id); +		if (!ns->up) +			bnep_if_up(bridge, ns->id);  	} else  		bnep_if_up(devname, ns->id); +	ns->up = TRUE;  	ns->clients = g_slist_append(ns->clients, g_strdup(s->address)); -	/* FIXME: Enable routing if applied */ -  	/* FIXME: send the D-Bus message to notify the new bnep iface */  failed:  | 
