~network-manager/network-manager/ubuntu.0.7

« back to all changes in this revision

Viewing changes to src/NetworkManagerPolicy.c

  • Committer: halfline
  • Date: 2005-03-15 05:30:15 UTC
  • Revision ID: vcs-imports@canonical.com-20050315053015-e48db277755385f5
2005-03-14  Ray Strode  <rstrode@redhat.com>

        Fourth (probably working) cut at porting to
        dbus 0.30 api and new hal. This cut adds
        some new logging macros to make debugging
        easier.

        * dispatcher-daemon/NetworkManagerDispatcher.c:
        * info-daemon/NetworkmanagerInfo.c:
        * info-daemon/NetworkManagerInfoPassphraseDialog.c:
        * info-daemon/NetworkManagerInfoVPN.c:
        * src/NetworkManager.c:
        * src/NetworkManagerAP.c:
        * src/NetworkManagerAPList.c:
        * src/NetworkManagerDHCP.c:
        * src/NetworkManagerDbus.c:
        * src/NetworkManagerDevice.c:
        * src/NetworkManagerPolicy.c:
        * src/NetworkManagerSystem.c:
        * src/NetworkManagerUtils.c:
        * src/NetworkManagerWireless.c:
        * src/autoip.c:
        * src/nm-dbus-nm.c:
        * src/backends/NetworkManagerDebian.c:
        * src/backends/NetworkManagerGentoo.c:
        * src/backends/NetworkManagerRedHat.c:
        * src/backends/NetworkManagerSlackware.c:
        use new logging macros.

        * dispatcher-daemon/NetworkManagerDispatcher.c:
        (nmd_dbus_filter): s/dbus_free/g_free/

        * info-daemon/Makefile.am: link in utils library.
        * info-daemon/NetworkmanagerInfo.c: use new logging
        macros.
        (nmi_dbus_get_network): don't assume enumerations
        are 32-bit.
        (nmi_dbus_nmi_message_handler): don't free what
        doesn't belong to us.

        * libnm_glib/libnm_glib.c:
        (libnm_glib_get_nm_status):
        (libnm_glib_init): don't free what doesn't
        belong to us.
        (libnm_glib_dbus): strdup result, so it doesn't get
        lost when message is unref'd.

        * panel-applet/NMWirelessAppletDbus.c:
        (nmwa_dbus_update_devices): s/dbus_free/g_free/

        * src/NetworkManager.c:
        (nm_monitor_wired_link_state): request initial status
        dump of all cards when we start up, instead of relying
        on /sys/.../carrier.
        (nm_info_handler), (nm_set_up_log_handlers):
        log handlers to specify what syslog priorites
        the logging macros default to.

        * src/NetworkManagerAPList.c:
        (nm_ap_list_populate_from_nmi):
        s/dbus_free_string_array/g_strfreev/

        * src/NetworkManagerDbus.c:
        (nm_dbus_get_network_object):
        validate d-bus message argument types.
        Advance message iterator after reading argument,
        prepend instead of append to GSList.

        * src/NetworkManagerDevice.c:
        (nm_device_probe_wired_link_status):
        remove redundant /sys in /sys path. remove wrong
        contents == NULL means has carrier assumption.

        * src/nm-netlink-monitor.c
        (nm_netlink_monitor_request_status): implement
        function to ask kernel to dump interface link
        status over netlink socket.

        * test/*.c: s/dbus_free/g_free/

        * utils/nm-utils.h:
        (nm_print_backtrace): new macro to print backtrace.
        (nm_get_timestamp): new macro to get sub-second precise
        unix timestamp.
        (nm_info), (nm_debug), (nm_warning), (nm_error):
        new logging functions. nm_info just prints,
        nm_debug includes timestamp and function,
        nm_warning includes function, nm_error includes
        backtrace and sigtrap.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#include "NetworkManagerAP.h"
34
34
#include "NetworkManagerAPList.h"
35
35
#include "NetworkManagerDbus.h"
 
36
#include "nm-utils.h"
36
37
 
37
38
 
38
39
/*
128
129
        }
129
130
 
130
131
#if 0
131
 
        syslog (LOG_NOTICE, "AUTO: Best wired device = %s, best wireless device = %s (%s)", best_wired_dev ? nm_device_get_iface (best_wired_dev) : "(null)",
 
132
        nm_info ("AUTO: Best wired device = %s, best wireless device = %s (%s)", best_wired_dev ? nm_device_get_iface (best_wired_dev) : "(null)",
132
133
                        best_wireless_dev ? nm_device_get_iface (best_wireless_dev) : "(null)", best_wireless_dev ? nm_device_get_essid (best_wireless_dev) : "null" );
133
134
#endif
134
135
 
208
209
        /* Ensure we support this driver */
209
210
        if (best_dev && (nm_device_get_driver_support_level (best_dev) == NM_DRIVER_UNSUPPORTED))
210
211
        {
211
 
                syslog (LOG_ERR, "nm_policy_get_best_device(): tried to switch to unsupported device '%s'!\n", nm_device_get_iface (best_dev));
 
212
                nm_warning ("nm_policy_get_best_device(): tried to switch to unsupported device '%s'!\n", nm_device_get_iface (best_dev));
212
213
                best_dev = NULL;
213
214
        }
214
215
 
261
262
                                        nm_ap_unref (ap);
262
263
                                }
263
264
                        }
264
 
                        syslog (LOG_INFO, "Activation (%s) successful, device activated.", nm_device_get_iface (data->active_device));
 
265
                        nm_info ("Activation (%s) successful, device activated.", nm_device_get_iface (data->active_device));
265
266
                        break;
266
267
 
267
268
                case DEVICE_ACTIVATION_FAILED:
278
279
                                        /* Unref because nm_device_get_best_ap() refs it before returning. */
279
280
                                        nm_ap_unref (ap);
280
281
                                }
281
 
                                syslog (LOG_INFO, "Activation (%s) failed for access point (%s)", nm_device_get_iface (dev), ap ? nm_ap_get_essid (ap) : "(none)");
 
282
                                nm_info ("Activation (%s) failed for access point (%s)", nm_device_get_iface (dev), ap ? nm_ap_get_essid (ap) : "(none)");
282
283
                        }
283
284
                        else
284
 
                                syslog (LOG_INFO, "Activation (%s) failed.", nm_device_get_iface (dev));
 
285
                                nm_info ("Activation (%s) failed.", nm_device_get_iface (dev));
285
286
                        if (data->active_device == dev)
286
287
                                data->active_device = NULL;
287
288
                        nm_device_deactivate (dev, FALSE);
352
353
                if (best_dev != app_data->active_device)
353
354
                {
354
355
                        if (best_dev)
355
 
                                syslog (LOG_INFO, "    SWITCH: best device changed");
 
356
                                nm_info ("    SWITCH: best device changed");
356
357
                        else
357
 
                                syslog (LOG_INFO, "    SWITCH: old device no longer good, but no better device was available");
 
358
                                nm_info ("    SWITCH: old device no longer good, but no better device was available");
358
359
                        do_switch = TRUE;       /* Device changed */
359
360
                }
360
361
                else if (best_dev)
361
362
                {
362
363
                        if (nm_device_is_wireless (best_dev) && !nm_device_is_activating (best_dev) && nm_device_need_ap_switch (best_dev))
363
364
                        {
364
 
                                syslog (LOG_INFO, "    SWITCH: need to associate with new access point or create a wireless network.");
 
365
                                nm_info ("    SWITCH: need to associate with new access point or create a wireless network.");
365
366
                                do_switch = TRUE;
366
367
                        }
367
368
                        else if (!nm_device_is_activating (best_dev) && !nm_device_get_ip4_address (best_dev))
368
369
                        {
369
 
                                syslog (LOG_INFO, "    SWITCH: need to get an IP address.");
 
370
                                nm_info ("    SWITCH: need to get an IP address.");
370
371
                                do_switch = TRUE;
371
372
                        }
372
373
                }
472
473
 
473
474
        g_return_val_if_fail (data != NULL, FALSE);
474
475
 
475
 
        syslog (LOG_INFO, "Updating allowed wireless network lists.");
 
476
        nm_info ("Updating allowed wireless network lists.");
476
477
 
477
478
        /* Query info daemon for network lists if its now running */
478
479
        if (data->allowed_ap_list)