[Patch] dict based vpnc plugin



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hi,

As first step, I ported NM's vpnc plugin to the newer dict API. It seems
to work fine here when connecting to my university's network.
I've attached a cvs diff from the vpn-daemons/ directory.
I'd be glad if someone could have a look at it to verify that I've done
everything right.
Now as there are two plugins using the same communication API, maybe it
would be a good idea to move the dbus/dict related stuff to a common
source file in the vpn-daemons/ directory that can be used by all
plugins beneath vpn-daemons/.

Regards,
Thomas

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFQ6u9xVmZpTAq4IgRAo8oAJ92Xcj89KIHVjCJOpHXdJ0bPhe35wCgh3Vs
8m3dc+HgoLSMk5crpq2okBg=
=6ria
-----END PGP SIGNATURE-----
? backup-101920061846-pre-vpnc.tgz
? backup-102820061906-pre-networkmanager-vpnc.tgz
? description-pak
? doc-pak
? networkmanager-vpnc_0.7.0-1_i386.deb
? vpnc_0.7.0-1_i386.deb
? auth-dialog/.deps
? auth-dialog/.libs
? po/.intltool-merge-cache
? po/ca.gmo
? po/en_GB.gmo
? po/es.gmo
? po/fi.gmo
? po/hu.gmo
? po/it.gmo
? po/ja.gmo
? po/vi.gmo
? po/zh_CN.gmo
? properties/.deps
? properties/.libs
? properties/libnm-vpnc-properties.la
? properties/libnm_vpnc_properties_la-nm-vpnc.lo
? src/.deps
? src/.libs
Index: src/nm-utils.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/vpn-daemons/vpnc/src/nm-utils.c,v
retrieving revision 1.1
diff -r1.1 nm-utils.c
26a27
> #include <dbus/dbus.h>
132a134,606
> 
> 
> /**
>  * Start a dict in a dbus message.  Should be paired with a call to
>  * { link nmu_dbus_dict_close_write}.
>  *
>  * @param iter A valid dbus message iterator
>  * @param iter_dict (out) A dict iterator to pass to further dict functions
>  * @return TRUE on success, FALSE on failure
>  *
>  */
> dbus_bool_t
> nmu_dbus_dict_open_write (DBusMessageIter *iter, DBusMessageIter *iter_dict)
> {	
> 	if (!iter || !iter_dict)
> 		return FALSE;
> 
> 	return dbus_message_iter_open_container (iter,
> 					  DBUS_TYPE_ARRAY,
> 					  DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
> 					  DBUS_TYPE_STRING_AS_STRING
> 					  DBUS_TYPE_VARIANT_AS_STRING
> 					  DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
> 					  iter_dict);
> }
> 
> /**
>  * End a dict element in a dbus message.  Should be paired with
>  * a call to { link nmu_dbus_dict_open_write}.
>  *
>  * @param iter valid dbus message iterator, same as passed to
>  *    nmu_dbus_dict_open_write()
>  * @param iter_dict a dbus dict iterator returned from { link nmu_dbus_dict_open_write}
>  * @return TRUE on success, FALSE on failure
>  *
>  */
> dbus_bool_t
> nmu_dbus_dict_close_write (DBusMessageIter *iter, DBusMessageIter *iter_dict)
> {	
> 	if (!iter || !iter_dict)
> 		return FALSE;
> 
> 	return dbus_message_iter_close_container (iter, iter_dict);
> }
> 
> 
> static const char *
> _nmu_get_type_as_string_from_type (const int type)
> {
> 	switch (type)
> 	{
> 		case DBUS_TYPE_BYTE:
> 			return DBUS_TYPE_BYTE_AS_STRING;
> 		case DBUS_TYPE_BOOLEAN:
> 			return DBUS_TYPE_BOOLEAN_AS_STRING;
> 		case DBUS_TYPE_INT16:
> 			return DBUS_TYPE_INT16_AS_STRING;
> 		case DBUS_TYPE_UINT16:
> 			return DBUS_TYPE_UINT16_AS_STRING;
> 		case DBUS_TYPE_INT32:
> 			return DBUS_TYPE_INT32_AS_STRING;
> 		case DBUS_TYPE_UINT32:
> 			return DBUS_TYPE_UINT32_AS_STRING;
> 		case DBUS_TYPE_INT64:
> 			return DBUS_TYPE_INT64_AS_STRING;
> 		case DBUS_TYPE_UINT64:
> 			return DBUS_TYPE_UINT64_AS_STRING;
> 		case DBUS_TYPE_DOUBLE:
> 			return DBUS_TYPE_DOUBLE_AS_STRING;
> 		case DBUS_TYPE_STRING:
> 			return DBUS_TYPE_STRING_AS_STRING;
> 		case DBUS_TYPE_OBJECT_PATH:
> 			return DBUS_TYPE_OBJECT_PATH_AS_STRING;
> 		case DBUS_TYPE_ARRAY:
> 			return DBUS_TYPE_ARRAY_AS_STRING;
> 		default:
> 			return NULL;
> 	}
> 	return NULL;
> }
> 
> 
> static dbus_bool_t
> _nmu_dbus_add_dict_entry_start (DBusMessageIter *iter_dict,
>                                 DBusMessageIter *iter_dict_entry,
>                                 const char *key,
>                                 const int value_type)
> {
> 	if (!dbus_message_iter_open_container (iter_dict,
> 					  DBUS_TYPE_DICT_ENTRY,
> 					  NULL,
> 					  iter_dict_entry))
> 		return FALSE;
> 
> 	if (!dbus_message_iter_append_basic (iter_dict_entry, DBUS_TYPE_STRING, &key))
> 		return FALSE;
> 
> 	return TRUE;
> }
> 
> 
> static dbus_bool_t
> _nmu_dbus_add_dict_entry_end (DBusMessageIter *iter_dict,
>                               DBusMessageIter *iter_dict_entry,
>                               DBusMessageIter *iter_dict_val)
> {
> 	if (!dbus_message_iter_close_container (iter_dict_entry, iter_dict_val))
> 		return FALSE;
> 	if (!dbus_message_iter_close_container (iter_dict, iter_dict_entry))
> 		return FALSE;
> 
> 	return TRUE;
> }
> 
> 
> static dbus_bool_t
> _nmu_dbus_add_dict_entry_basic (DBusMessageIter *iter_dict,
>                                 const char *key,
>                                 const int value_type,
>                                 const void *value)
> {
> 	DBusMessageIter iter_dict_entry, iter_dict_val;
> 	const char * type_as_string = NULL;
> 
> 	type_as_string = _nmu_get_type_as_string_from_type (value_type);
> 	if (!type_as_string)
> 		return FALSE;
> 
> 	if (!_nmu_dbus_add_dict_entry_start (iter_dict, &iter_dict_entry,
> 			key, value_type))
> 		return FALSE;
> 
> 	if (!dbus_message_iter_open_container (&iter_dict_entry,
> 					  DBUS_TYPE_VARIANT,
> 					  type_as_string,
> 					  &iter_dict_val))
> 		return FALSE;
> 
> 	if (!dbus_message_iter_append_basic (&iter_dict_val, value_type, value))
> 		return FALSE;
> 
> 	if (!_nmu_dbus_add_dict_entry_end (iter_dict, &iter_dict_entry,
> 			&iter_dict_val))
> 		return FALSE;
> 
> 	return TRUE;
> }
> 
> 
> static dbus_bool_t
> _nmu_dbus_add_dict_entry_byte_array (DBusMessageIter *iter_dict,
>                                      const char *key,
>                                      const char *value,
>                                      const dbus_uint32_t value_len)
> {
> 	DBusMessageIter iter_dict_entry, iter_dict_val, iter_array;
> 	dbus_uint32_t i;
> 
> 	if (!_nmu_dbus_add_dict_entry_start (iter_dict, &iter_dict_entry,
> 			key, DBUS_TYPE_ARRAY))
> 		return FALSE;
> 
> 	if (!dbus_message_iter_open_container (&iter_dict_entry,
> 					  DBUS_TYPE_VARIANT,
> 					  DBUS_TYPE_ARRAY_AS_STRING
> 					  DBUS_TYPE_BYTE_AS_STRING,
> 					  &iter_dict_val))
> 		return FALSE;
> 
> 	if (!dbus_message_iter_open_container (&iter_dict_val, DBUS_TYPE_ARRAY,
> 			DBUS_TYPE_BYTE_AS_STRING, &iter_array))
> 		return FALSE;
> 
> 	for (i = 0; i < value_len; i++)
> 	{
> 		if (!dbus_message_iter_append_basic (&iter_array, DBUS_TYPE_BYTE,
> 				&(value[i])))
> 			return FALSE;
> 	}
> 	
> 	if (!dbus_message_iter_close_container (&iter_dict_val, &iter_array))
> 		return FALSE;
> 
> 	if (!_nmu_dbus_add_dict_entry_end (iter_dict, &iter_dict_entry,
> 			&iter_dict_val))
> 		return FALSE;
> 
> 	return TRUE;
> }
> 
> 
> static dbus_bool_t
> _nmu_dbus_add_dict_entry_string_array (DBusMessageIter *iter_dict,
>                                        const char *key,
>                                        const char **items,
>                                        const dbus_uint32_t num_items)
> {
> 	DBusMessageIter iter_dict_entry, iter_dict_val, iter_array;
> 	dbus_uint32_t i;
> 
> 	if (!_nmu_dbus_add_dict_entry_start (iter_dict, &iter_dict_entry,
> 			key, DBUS_TYPE_ARRAY))
> 		return FALSE;
> 
> 	if (!dbus_message_iter_open_container (&iter_dict_entry,
> 					  DBUS_TYPE_VARIANT,
> 					  DBUS_TYPE_ARRAY_AS_STRING
> 					  DBUS_TYPE_STRING_AS_STRING,
> 					  &iter_dict_val))
> 		return FALSE;
> 
> 	if (!dbus_message_iter_open_container (&iter_dict_val, DBUS_TYPE_ARRAY,
> 			DBUS_TYPE_BYTE_AS_STRING, &iter_array))
> 		return FALSE;
> 
> 	for (i = 0; i < num_items; i++)
> 	{
> 		if (!dbus_message_iter_append_basic (&iter_array, DBUS_TYPE_STRING,
> 				&(items[i])))
> 			return FALSE;
> 	}
> 	
> 	if (!dbus_message_iter_close_container (&iter_dict_val, &iter_array))
> 		return FALSE;
> 
> 	if (!_nmu_dbus_add_dict_entry_end (iter_dict, &iter_dict_entry,
> 			&iter_dict_val))
> 		return FALSE;
> 
> 	return TRUE;
> }
> 
> /**
>  * Add a string entry to the dict.
>  *
>  * @param iter_dict A valid DBusMessageIter returned from { link nmu_dbus_dict_open_write}
>  * @param key The key of the dict item
>  * @param value The string value
>  * @return TRUE on success, FALSE on failure
>  *
>  */
> dbus_bool_t
> nmu_dbus_dict_append_string (DBusMessageIter *iter_dict,
>                              const char * key,
>                              const char * value)
> {
> 	if (!key || !value) return FALSE;
> 	return _nmu_dbus_add_dict_entry_basic (iter_dict, key, DBUS_TYPE_STRING, &value);
> }
> 
> /**
>  * Add a byte entry to the dict.
>  *
>  * @param iter_dict A valid DBusMessageIter returned from { link nmu_dbus_dict_open_write}
>  * @param key The key of the dict item
>  * @param value The byte value
>  * @return TRUE on success, FALSE on failure
>  *
>  */
> dbus_bool_t
> nmu_dbus_dict_append_byte (DBusMessageIter *iter_dict,
>                            const char * key,
>                            const char value)
> {
> 	if (!key) return FALSE;
> 	return _nmu_dbus_add_dict_entry_basic (iter_dict, key, DBUS_TYPE_BYTE, &value);
> }
> 
> /**
>  * Add a boolean entry to the dict.
>  *
>  * @param iter_dict A valid DBusMessageIter returned from { link nmu_dbus_dict_open_write}
>  * @param key The key of the dict item
>  * @param value The boolean value
>  * @return TRUE on success, FALSE on failure
>  *
>  */
> dbus_bool_t
> nmu_dbus_dict_append_bool (DBusMessageIter *iter_dict,
>                            const char * key,
>                            const dbus_bool_t value)
> {
> 	if (!key) return FALSE;
> 	return _nmu_dbus_add_dict_entry_basic (iter_dict, key, DBUS_TYPE_BOOLEAN, &value);
> }
> 
> /**
>  * Add a 16-bit signed integer entry to the dict.
>  *
>  * @param iter_dict A valid DBusMessageIter returned from { link nmu_dbus_dict_open_write}
>  * @param key The key of the dict item
>  * @param value The 16-bit signed integer value
>  * @return TRUE on success, FALSE on failure
>  *
>  */
> dbus_bool_t
> nmu_dbus_dict_append_int16 (DBusMessageIter *iter_dict,
>                             const char * key,
>                             const dbus_int16_t value)
> {
> 	if (!key) return FALSE;
> 	return _nmu_dbus_add_dict_entry_basic (iter_dict, key, DBUS_TYPE_INT16, &value);
> }
> 
> /**
>  * Add a 16-bit unsigned integer entry to the dict.
>  *
>  * @param iter_dict A valid DBusMessageIter returned from { link nmu_dbus_dict_open_write}
>  * @param key The key of the dict item
>  * @param value The 16-bit unsigned integer value
>  * @return TRUE on success, FALSE on failure
>  *
>  */
> dbus_bool_t
> nmu_dbus_dict_append_uint16 (DBusMessageIter *iter_dict,
>                              const char * key,
>                              const dbus_uint16_t value)
> {
> 	if (!key) return FALSE;
> 	return _nmu_dbus_add_dict_entry_basic (iter_dict, key, DBUS_TYPE_UINT16, &value);
> }
> 
> /**
>  * Add a 32-bit signed integer to the dict.
>  *
>  * @param iter_dict A valid DBusMessageIter returned from { link nmu_dbus_dict_open_write}
>  * @param key The key of the dict item
>  * @param value The 32-bit signed integer value
>  * @return TRUE on success, FALSE on failure
>  *
>  */
> dbus_bool_t
> nmu_dbus_dict_append_int32 (DBusMessageIter *iter_dict,
>                             const char * key,
>                             const dbus_int32_t value)
> {
> 	if (!key) return FALSE;
> 	return _nmu_dbus_add_dict_entry_basic (iter_dict, key, DBUS_TYPE_INT32, &value);
> }
> 
> /**
>  * Add a 32-bit unsigned integer entry to the dict.
>  *
>  * @param iter_dict A valid DBusMessageIter returned from { link nmu_dbus_dict_open_write}
>  * @param key The key of the dict item
>  * @param value The 32-bit unsigned integer value
>  * @return TRUE on success, FALSE on failure
>  *
>  */
> dbus_bool_t
> nmu_dbus_dict_append_uint32 (DBusMessageIter *iter_dict,
>                              const char * key,
>                              const dbus_uint32_t value)
> {
> 	if (!key) return FALSE;
> 	return _nmu_dbus_add_dict_entry_basic (iter_dict, key, DBUS_TYPE_UINT32, &value);
> }
> 
> /**
>  * Add a 64-bit integer entry to the dict.
>  *
>  * @param iter_dict A valid DBusMessageIter returned from { link nmu_dbus_dict_open_write}
>  * @param key The key of the dict item
>  * @param value The 64-bit integer value
>  * @return TRUE on success, FALSE on failure
>  *
>  */
> dbus_bool_t
> nmu_dbus_dict_append_int64 (DBusMessageIter *iter_dict,
>                             const char * key,
>                             const dbus_int64_t value)
> {
> 	if (!key) return FALSE;
> 	return _nmu_dbus_add_dict_entry_basic (iter_dict, key, DBUS_TYPE_INT64, &value);
> }
> 
> /**
>  * Add a 64-bit unsigned integer entry to the dict.
>  *
>  * @param iter_dict A valid DBusMessageIter returned from { link nmu_dbus_dict_open_write}
>  * @param key The key of the dict item
>  * @param value The 64-bit unsigned integer value
>  * @return TRUE on success, FALSE on failure
>  *
>  */
> dbus_bool_t
> nmu_dbus_dict_append_uint64 (DBusMessageIter *iter_dict,
>                              const char * key,
>                              const dbus_uint64_t value)
> {
> 	if (!key) return FALSE;
> 	return _nmu_dbus_add_dict_entry_basic (iter_dict, key, DBUS_TYPE_UINT64, &value);
> }
> 
> /**
>  * Add a double-precision floating point entry to the dict.
>  *
>  * @param iter_dict A valid DBusMessageIter returned from { link nmu_dbus_dict_open_write}
>  * @param key The key of the dict item
>  * @param value The double-precision floating point value
>  * @return TRUE on success, FALSE on failure
>  *
>  */
> dbus_bool_t
> nmu_dbus_dict_append_double (DBusMessageIter *iter_dict,
>                              const char * key,
>                              const double value)
> {
> 	if (!key) return FALSE;
> 	return _nmu_dbus_add_dict_entry_basic (iter_dict, key, DBUS_TYPE_DOUBLE, &value);
> }
> 
> /**
>  * Add a DBus object path entry to the dict.
>  *
>  * @param iter_dict A valid DBusMessageIter returned from { link nmu_dbus_dict_open_write}
>  * @param key The key of the dict item
>  * @param value The DBus object path value
>  * @return TRUE on success, FALSE on failure
>  *
>  */
> dbus_bool_t
> nmu_dbus_dict_append_object_path (DBusMessageIter *iter_dict,
>                                   const char * key,
>                                   const char * value)
> {
> 	if (!key || !value) return FALSE;
> 	return _nmu_dbus_add_dict_entry_basic (iter_dict, key, DBUS_TYPE_OBJECT_PATH, &value);
> }
> 
> /**
>  * Add a byte array entry to the dict.
>  *
>  * @param iter_dict A valid DBusMessageIter returned from { link nmu_dbus_dict_open_write}
>  * @param key The key of the dict item
>  * @param value The byte array
>  * @param value_len The length of the byte array, in bytes
>  * @return TRUE on success, FALSE on failure
>  *
>  */
> dbus_bool_t
> nmu_dbus_dict_append_byte_array (DBusMessageIter *iter_dict,
>                                  const char * key,
>                                  const char * value,
>                                  const dbus_uint32_t value_len)
> {
> 	if (!key) return FALSE;
> 	if (!value && (value_len != 0)) return FALSE;
> 	return _nmu_dbus_add_dict_entry_byte_array (iter_dict, key, value, value_len);
> }
> 
> 
> /**
>  * Add a string array entry to the dict.
>  *
>  * @param iter_dict A valid DBusMessageIter returned from { link nmu_dbus_dict_open_write}
>  * @param key The key of the dict item
>  * @param items The array of strings
>  * @param num_items The number of strings in the array
>  * @return TRUE on success, FALSE on failure
>  *
>  */
> dbus_bool_t
> nmu_dbus_dict_append_string_array (DBusMessageIter *iter_dict,
>                                    const char * key,
>                                    const char ** items,
>                                    const dbus_uint32_t num_items)
> {
> 	if (!key) return FALSE;
> 	if (!items && (num_items != 0)) return FALSE;
> 	return _nmu_dbus_add_dict_entry_string_array (iter_dict, key, items, num_items);
> }
> 
Index: src/nm-utils.h
===================================================================
RCS file: /cvs/gnome/NetworkManager/vpn-daemons/vpnc/src/nm-utils.h,v
retrieving revision 1.2
diff -r1.2 nm-utils.h
130a131,209
> /*
>  * Adding a dict to a DBusMessage
>  */
> 
> dbus_bool_t
> nmu_dbus_dict_open_write (DBusMessageIter *iter,
>                           DBusMessageIter *iter_dict);
> 
> dbus_bool_t
> nmu_dbus_dict_close_write (DBusMessageIter *iter,
>                            DBusMessageIter *iter_dict);
> 
> dbus_bool_t
> nmu_dbus_dict_append_string (DBusMessageIter *iter_dict,
>                              const char * key,
>                              const char * value);
> 
> dbus_bool_t
> nmu_dbus_dict_append_byte (DBusMessageIter *iter_dict,
>                            const char * key,
>                            const char value);
> 
> dbus_bool_t
> nmu_dbus_dict_append_bool (DBusMessageIter *iter_dict,
>                            const char * key,
>                            const dbus_bool_t value);
> 
> dbus_bool_t
> nmu_dbus_dict_append_int16 (DBusMessageIter *iter_dict,
>                             const char * key,
>                             const dbus_int16_t value);
> 
> dbus_bool_t
> nmu_dbus_dict_append_uint16 (DBusMessageIter *iter_dict,
>                              const char * key,
>                              const dbus_uint16_t value);
> 
> dbus_bool_t
> nmu_dbus_dict_append_int32 (DBusMessageIter *iter_dict,
>                             const char * key,
>                             const dbus_int32_t value);
> 
> dbus_bool_t
> nmu_dbus_dict_append_uint32 (DBusMessageIter *iter_dict,
>                              const char * key,
>                              const dbus_uint32_t value);
> 
> dbus_bool_t
> nmu_dbus_dict_append_int64 (DBusMessageIter *iter_dict,
>                             const char * key,
>                             const dbus_int64_t value);
> 
> dbus_bool_t
> nmu_dbus_dict_append_uint64 (DBusMessageIter *iter_dict,
>                              const char * key,
>                              const dbus_uint64_t value);
> 
> dbus_bool_t
> nmu_dbus_dict_append_double (DBusMessageIter *iter_dict,
>                              const char * key,
>                              const double value);
> 
> dbus_bool_t
> nmu_dbus_dict_append_object_path (DBusMessageIter *iter_dict,
>                                   const char * key,
>                                   const char * value);
> 
> dbus_bool_t
> nmu_dbus_dict_append_byte_array (DBusMessageIter *iter_dict,
>                                  const char * key,
>                                  const char * value,
>                                  const dbus_uint32_t value_len);
> 
> dbus_bool_t
> nmu_dbus_dict_append_string_array (DBusMessageIter *iter_dict,
>                                    const char * key,
>                                    const char ** items,
>                                    const dbus_uint32_t num_items);
> 
Index: src/nm-vpnc-service.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/vpn-daemons/vpnc/src/nm-vpnc-service.c,v
retrieving revision 1.19
diff -r1.19 nm-vpnc-service.c
872,881c872,882
< 	guint32		ip4_vpn_gateway;
< 	char *		tundev;
< 	guint32		ip4_address;
< 	guint32		ip4_ptp_address;
< 	guint32		ip4_netmask;
< 	guint32 *		ip4_dns;
< 	guint32		ip4_dns_len;
< 	guint32 *		ip4_nbns;
< 	guint32		ip4_nbns_len;
< 	guint32		mss;
---
> 	guint32		    ip4_vpn_gateway;
> 	char *		    tundev;
> 	guint32		    ip4_address;
> 	guint32		    ip4_ptp_address;
> 	guint32		    ip4_netmask;
> 	guint32 *		    ip4_dns = NULL;
> 	guint32		    ip4_dns_len;
> 	guint32 		    ip4_dns1;
> 	guint32 		    ip4_dns2;
> 	guint32 *		    ip4_nbns = NULL;
> 	guint32		    ip4_nbns_len;
883,885c884,893
< 	char *		cisco_banner;
< 	gboolean		success = FALSE;
< 	DBusMessage *	signal;
---
> 	char *		cisco_banner;	
> 	guint32 		    ip4_nbns1;
> 	guint32 		    ip4_nbns2;
> 	guint32			mtu;
> 	guint32			mss;
> 	gboolean		    success = FALSE;
> 	char *            empty = "";
> 	DBusMessage	*signal;
> 	int               i;
> 	DBusMessageIter iter, iter_dict;
890c898
< 
---
> 	
894c902
< 
---
> 	
896c904
< 
---
> 	
907c915
< 
---
> 	
910c918
< 
---
> 	
919c927
< 
---
> 	
920a929,936
> 	{
> 		nm_warning ("Not enough memory for new dbus message!");
> 		goto out;
> 	}
> 	
> 	dbus_message_iter_init_append (signal, &iter);
> 	if (!nmu_dbus_dict_open_write (&iter, &iter_dict)) {
> 		nm_warning ("dict open write failed!");
921a938,987
> 	}
> 
> 	if (!nmu_dbus_dict_append_uint32 (&iter_dict, "gateway", ip4_vpn_gateway)) {
>     	nm_warning ("couldn't append gateway to dict");
>     	goto out;
> 	}
> 
> 	if (!nmu_dbus_dict_append_string (&iter_dict, "tundev", tundev)) {
>     	nm_warning ("couldn't append tundev to dict");
>     	goto out;
> 	}
> 
> 	if (!nmu_dbus_dict_append_uint32 (&iter_dict, "local_addr", ip4_address)) {
>     	nm_warning ("couldn't append local_address to dict");
>     	goto out;
> 	}
> 
> 	if (!nmu_dbus_dict_append_uint32 (&iter_dict, "local_netmask", ip4_netmask)) {
>     	nm_warning ("couldn't append local_netmask to dict");
> 	    goto out;
> 	}
> 
> 	if (!nmu_dbus_dict_append_uint32 (&iter_dict, "ptp_addr", ip4_ptp_address)) {
>     	nm_warning ("couldn't append ptp_address to dict");
>     	goto out;
> 	}
> 
> 	for (i=0; i < ip4_dns_len; i++) {
> 		if (!nmu_dbus_dict_append_uint32 (&iter_dict, "dns_server", ip4_dns[i])) {
> 			nm_warning ("couldn't append dns_server (number %d) to dict",i);
> 			goto out;
> 		}
> 	}
> 
> 	for (i=0; i < ip4_nbns_len; i++) {
> 		if (!nmu_dbus_dict_append_uint32 (&iter_dict, "nbns_server", ip4_dns[i])) {
> 			nm_warning ("couldn't append nbns_server (number %d) to dict",i);
> 			goto out;
> 		}
> 	}
> 
> 	if (!nmu_dbus_dict_append_string (&iter_dict, "login_banner", cisco_banner)) {
> 		nm_warning ("couldn't append login_banner to dict");
> 		goto out;
> 	}
> 
> 	if (!nmu_dbus_dict_close_write (&iter, &iter_dict)) {
> 		nm_warning ("dict close write failed!");
> 		goto out;
> 	}
923,933d988
< 	dbus_message_append_args (signal,
< 	                          DBUS_TYPE_UINT32, &ip4_vpn_gateway,
< 	                          DBUS_TYPE_STRING, &tundev,
< 	                          DBUS_TYPE_UINT32, &ip4_address,
< 	                          DBUS_TYPE_UINT32, &ip4_ptp_address,
< 	                          DBUS_TYPE_UINT32, &ip4_netmask,
< 	                          DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &ip4_dns, ip4_dns_len,
< 	                          DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &ip4_nbns, ip4_nbns_len,
< 						 DBUS_TYPE_UINT32, &mss,
< 	                          DBUS_TYPE_STRING, &cisco_def_domain,
< 	                          DBUS_TYPE_STRING, &cisco_banner, DBUS_TYPE_INVALID);
939c994
< 
---
> 	
947c1002
< 		nm_warning ("Received invalid IP4 Config information from helper, terminating vpnc.");
---
> 	nm_warning ("Received invalid IP4 Config information from helper, terminating vpnc.");
950a1006,1086
> //static void nm_vpnc_dbus_process_helper_ip4_config (DBusConnection *con, DBusMessage *message, NmVpncData *data)
> //{
> //	guint32		ip4_vpn_gateway;
> //	char *		tundev;
> //	guint32		ip4_address;
> //	guint32		ip4_ptp_address;
> //	guint32		ip4_netmask;
> //	guint32 *		ip4_dns;
> //	guint32		ip4_dns_len;
> //	guint32 *		ip4_nbns;
> //	guint32		ip4_nbns_len;
> //	guint32		mss;
> //	char *		cisco_def_domain;
> //	char *		cisco_banner;
> //	gboolean		success = FALSE;
> //	DBusMessage *	signal;
> //
> //	g_return_if_fail (data != NULL);
> //	g_return_if_fail (con != NULL);
> //	g_return_if_fail (message != NULL);
> //
> //	/* Only accept the config info if we're in STARTING state */
> //	if (data->state != NM_VPN_STATE_STARTING)
> //		return;
> //
> //	nm_vpnc_cancel_helper_timer (data);
> //
> //	if (!dbus_message_get_args(message, NULL,
> //	                          DBUS_TYPE_UINT32, &ip4_vpn_gateway,
> //	                          DBUS_TYPE_STRING, &tundev,
> //	                          DBUS_TYPE_UINT32, &ip4_address,
> //	                          DBUS_TYPE_UINT32, &ip4_netmask,
> //	                          DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &ip4_dns, &ip4_dns_len,
> //	                          DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &ip4_nbns, &ip4_nbns_len,
> //	                          DBUS_TYPE_STRING, &cisco_def_domain,
> //	                          DBUS_TYPE_STRING, &cisco_banner, DBUS_TYPE_INVALID))
> //		goto out;
> //
> //	/* For Cisco/vpnc, PtP address == local VPN address */
> //	ip4_ptp_address = ip4_address;
> //
> //	/* and we don't specify an MSS */
> //	mss = 0;
> //
> //#if 0
> //	print_vpn_config (ip4_vpn_gateway, tundev, ip4_address, ip4_netmask,
> //					ip4_dns, ip4_dns_len, ip4_nbns, ip4_nbns_len,
> //					cisco_def_domain, cisco_banner);
> //#endif
> //
> //	if (!(signal = dbus_message_new_signal (NM_DBUS_PATH_VPNC, NM_DBUS_INTERFACE_VPNC, NM_DBUS_VPN_SIGNAL_IP4_CONFIG)))
> //		goto out;
> //
> //	dbus_message_append_args (signal,
> //	                          DBUS_TYPE_UINT32, &ip4_vpn_gateway,
> //	                          DBUS_TYPE_STRING, &tundev,
> //	                          DBUS_TYPE_UINT32, &ip4_address,
> //	                          DBUS_TYPE_UINT32, &ip4_ptp_address,
> //	                          DBUS_TYPE_UINT32, &ip4_netmask,
> //	                          DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &ip4_dns, ip4_dns_len,
> //	                          DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &ip4_nbns, ip4_nbns_len,
> //						 DBUS_TYPE_UINT32, &mss,
> //	                          DBUS_TYPE_STRING, &cisco_def_domain,
> //	                          DBUS_TYPE_STRING, &cisco_banner, DBUS_TYPE_INVALID);
> //	if (!dbus_connection_send (data->con, signal, NULL))
> //	{
> //		nm_warning ("Could not raise the "NM_DBUS_VPN_SIGNAL_IP4_CONFIG" signal!");
> //		goto out;
> //	}
> //
> //	dbus_message_unref (signal);
> //	nm_vpnc_set_state (data, NM_VPN_STATE_STARTED);
> //	success = TRUE;
> //
> //out:
> //	if (!success)
> //	{
> //		nm_warning ("Received invalid IP4 Config information from helper, terminating vpnc.");
> //		nm_vpnc_dbus_handle_stop_vpn (data);
> //	}
> //}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]