| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * dhcpcd-dbus | 2  * dhcpcd-dbus | 
| 3  * Copyright 2009 Roy Marples <roy@marples.name> | 3  * Copyright 2009 Roy Marples <roy@marples.name> | 
| 4  * | 4  * | 
| 5  * Redistribution and use in source and binary forms, with or without | 5  * Redistribution and use in source and binary forms, with or without | 
| 6  * modification, are permitted provided that the following conditions | 6  * modification, are permitted provided that the following conditions | 
| 7  * are met: | 7  * are met: | 
| 8  * 1. Redistributions of source code must retain the above copyright | 8  * 1. Redistributions of source code must retain the above copyright | 
| 9  *    notice, this list of conditions and the following disclaimer. | 9  *    notice, this list of conditions and the following disclaimer. | 
| 10  * 2. Redistributions in binary form must reproduce the above copyright | 10  * 2. Redistributions in binary form must reproduce the above copyright | 
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 475         if (dbus_message_is_method_call(msg, DBUS_INTERFACE_INTROSPECTABLE, | 475         if (dbus_message_is_method_call(msg, DBUS_INTERFACE_INTROSPECTABLE, | 
| 476                                         "Introspect")) { | 476                                         "Introspect")) { | 
| 477                 return introspect(con, msg); | 477                 return introspect(con, msg); | 
| 478         } else if (IsMethod(msg, "GetVersion")) { | 478         } else if (IsMethod(msg, "GetVersion")) { | 
| 479                 return version(con, msg, VERSION); | 479                 return version(con, msg, VERSION); | 
| 480         } else if (IsMethod(msg, "GetInterfaces")) { | 480         } else if (IsMethod(msg, "GetInterfaces")) { | 
| 481                 return dhcpcd_get_interfaces(con, msg); | 481                 return dhcpcd_get_interfaces(con, msg); | 
| 482         } else if (IsMethod(msg, "GetStatus")) { | 482         } else if (IsMethod(msg, "GetStatus")) { | 
| 483                 return return_status(con, msg); | 483                 return return_status(con, msg); | 
| 484         } else if (IsMethod(msg, "Rebind")) { | 484         } else if (IsMethod(msg, "Rebind")) { | 
| 485 »       »       bind_interface(ifaces);»»       /* XXX */ | 485 »       »       start_interface(ifaces); | 
| 486                 return dbus_ack(con, msg); | 486                 return dbus_ack(con, msg); | 
| 487         } else if (IsMethod(msg, "Release")) { | 487         } else if (IsMethod(msg, "Release")) { | 
| 488 »       »       raise(SIGHUP); | 488 »       »       send_release(ifaces); | 
|  | 489 »       »       stop_interface(ifaces); | 
| 489                 return dbus_ack(con, msg); | 490                 return dbus_ack(con, msg); | 
| 490         } else if (IsMethod(msg, "Stop")) { | 491         } else if (IsMethod(msg, "Stop")) { | 
| 491 »       »       /* NB: must ack first 'cuz handle_signal exit's */ | 492 »       »       stop_interface(ifaces); | 
| 492                 (void) dbus_ack(con, msg); | 493                 (void) dbus_ack(con, msg); | 
| 493 »       »       raise(SIGINT); | 494 »       »       exit(EXIT_FAILURE); | 
| 494 »       »       /*NOTREACHED*/ | 495 »       } else if (dbus_message_is_signal(msg, DBUS_INTERFACE_LOCAL, | 
|  | 496 »       »       »       »       »         "Disconnected")) { | 
|  | 497 »       »       stop_interface(ifaces); | 
|  | 498 »       »       exit(EXIT_FAILURE); | 
| 495         } | 499         } | 
| 496         return return_dbus_error(con, msg, S_EINVAL, S_ARGS); | 500         return return_dbus_error(con, msg, S_EINVAL, S_ARGS); | 
| 497 #undef IsMethod | 501 #undef IsMethod | 
| 498 } | 502 } | 
| 499 | 503 | 
| 500 static void | 504 static void | 
| 501 dbus_event(int revents, void *watch) | 505 dbus_event(int revents, void *watch) | 
| 502 { | 506 { | 
| 503         int flags; | 507         int flags; | 
| 504 | 508 | 
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 571         connection = dbus_bus_get(DBUS_BUS_SYSTEM, &err); | 575         connection = dbus_bus_get(DBUS_BUS_SYSTEM, &err); | 
| 572         if (connection == NULL) { | 576         if (connection == NULL) { | 
| 573                 if (dbus_error_is_set(&err)) | 577                 if (dbus_error_is_set(&err)) | 
| 574                         syslog(LOG_ERR, "%s", err.message); | 578                         syslog(LOG_ERR, "%s", err.message); | 
| 575                 else | 579                 else | 
| 576                         syslog(LOG_ERR, "failed to get a dbus connection"); | 580                         syslog(LOG_ERR, "failed to get a dbus connection"); | 
| 577                 return -1; | 581                 return -1; | 
| 578         } | 582         } | 
| 579         atexit(dhcpcd_dbus_close); | 583         atexit(dhcpcd_dbus_close); | 
| 580 | 584 | 
| 581 #if 0 |  | 
| 582         ret = dbus_bus_request_name(connection, DHCPCD_SERVICE, |  | 
| 583             DBUS_NAME_FLAG_REPLACE_EXISTING, &err); |  | 
| 584         if (dbus_error_is_set(&err)) { |  | 
| 585                 syslog(LOG_ERR, "%s", err.message); |  | 
| 586                 return -1; |  | 
| 587         } |  | 
| 588 #endif |  | 
| 589         if (!dbus_connection_set_watch_functions(connection, | 585         if (!dbus_connection_set_watch_functions(connection, | 
| 590                 add_watch, remove_watch, NULL, NULL, NULL)) | 586                 add_watch, remove_watch, NULL, NULL, NULL)) | 
| 591         { | 587         { | 
| 592                 syslog(LOG_ERR, "dbus: failed to set watch functions"); | 588                 syslog(LOG_ERR, "dbus: failed to set watch functions"); | 
| 593                 return -1; | 589                 return -1; | 
| 594         } | 590         } | 
| 595         if (!dbus_connection_register_object_path(connection, | 591         if (!dbus_connection_register_object_path(connection, | 
| 596                 DHCPCD_PATH, &vt, NULL)) | 592                 DHCPCD_PATH, &vt, NULL)) | 
| 597         { | 593         { | 
| 598                 syslog(LOG_ERR, "dbus: failed to register object path"); | 594                 syslog(LOG_ERR, "dbus: failed to register object path"); | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 610 | 606 | 
| 611                 if (write_lease(ifp, ifp->state->new) == -1) | 607                 if (write_lease(ifp, ifp->state->new) == -1) | 
| 612                         syslog(LOG_ERR, "write_lease: %m"); | 608                         syslog(LOG_ERR, "write_lease: %m"); | 
| 613         } | 609         } | 
| 614         return 0; | 610         return 0; | 
| 615 } | 611 } | 
| 616 | 612 | 
| 617 int | 613 int | 
| 618 run_script(const struct interface *ifp) | 614 run_script(const struct interface *ifp) | 
| 619 { | 615 { | 
| 620         syslog(LOG_DEBUG, "executing `%s', reason %s", |  | 
| 621             ifp->name, ifp->state->reason); |  | 
| 622 #if 0 |  | 
| 623         /* push state over d-bus */ |  | 
| 624         dhcpcd_dbus_configure(ifp, ifp->state->reason); |  | 
| 625 #endif |  | 
| 626         return 0; | 616         return 0; | 
| 627 } | 617 } | 
| OLD | NEW | 
|---|