summaryrefslogtreecommitdiffstats
path: root/discover/discover-server.c
Commit message (Collapse)AuthorAgeFilesLines
* discover/discover-server: explicit #include <string.h>Brett Grandbois2018-03-231-0/+1
| | | | | | | for musl libc Signed-off-by: Brett Grandbois <brett.grandbois@opengear.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Handle plugin install requestSamuel Mendoza-Jonas2017-08-151-0/+6
| | | | | | | | | Handle "_PLUGIN_INSTALL" requests from clients. Calling the pb-plugin script from pb-discover ensures different clients don't trip over each other. Successfully installed plugins are automatically communicated back to clients once pb-plugin sends a 'plugin' user event. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Handle and track plugin_optionsSamuel Mendoza-Jonas2017-08-151-1/+60
| | | | | | | | | | Track plugin_options in the device_handler. Plugins can be added with device_handler_add_plugin_option() and accessed via device_handler_get_plugin(). Extend discover_server to support the new 'add' and 'remove' pb-protocol actions and advertise new plugins to connecting clients. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Maintain a backlog of status updatesSamuel Mendoza-Jonas2016-12-201-0/+25
| | | | | | | | | Add status updates to a persistent list in the discover_server struct, and send each client the backlog on connect. This avoids clients missing useful messages from early init. Clients will only show this in the backlog screen to avoid flooding the client's status line. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* types: shorten boot_status definitionsJeremy Kerr2016-12-201-2/+2
| | | | | | | | | | | struct boot_status is a bit misnamed; we report status on things that aren't just the boot status (eg, discovery). This change refactors struct boot_status into just struct status. We give the type enum a name, and shorten the enum values to suit. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* Fix sparse warningsAndrew Donnellan2016-04-201-1/+1
| | | | | | | | Fix some sparse warnings by using NULL instead of 0 and static-ifying a variable not used outside its file. Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: extend URL in UI to support auto-discoveryNishanth Aravamudan2015-12-181-1/+2
| | | | | | | | | | | | | The URL field currently only supports loading a particular file for static network configurations. But it makes sense in certain static network configurations to 'auto-discover' a file like petitboot does with DHCP -- based off the MAC address and IP. Extend device_handler_process_url to take those as parameters, and toggle off the URL ending in a '/' to indicate whether to 'auto-discover' or directly load the specified URL. Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com> Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* discover: Add support for 'add-url' actionsSamuel Mendoza-Jonas2014-07-281-0/+7
| | | | | Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* protocol: expose discovery reinit over client/server protocolJeremy Kerr2014-04-021-0/+4
| | | | | | | Now that we can re-initialise the device handler, allow this to be triggered from UIs over the petitboot protocol. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* pb-config: Move config storage modules to "platform" modules in discover codeJeremy Kerr2014-01-301-0/+1
| | | | | | | | | | | | | | | | | | There's no need to include the config storage code in lib/ as only the discover server should be using it. This change moves the config-storage code to discover/, with the platform-specific parts moved to a 'struct platform'. Each platform has a probe function, which is called during init. The first probe function to return a platform is used. At present we only have the one platform, but it's now non-intrusive to add others. We keep an array of platform pointers in a separate ("platforms") section, to allow the test module to drop-in its own test "platform". Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Handle incoming configuration messagesJeremy Kerr2013-11-131-0/+14
| | | | | | | When the client sends us a PB_PROTOCOL_ACTION_CONFIG message, we want to update the current config. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* config: Implement config messagesJeremy Kerr2013-11-131-0/+33
| | | | | | On client connect, send a PB_PROTOCOL_ACTION_CONFIG message. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* logging: Clean up debug logsJeremy Kerr2013-11-011-2/+2
| | | | | | | We have quite a few pb_logs which should be pb_debug. This change moves developer-specific info to pb_debug. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Don't free clients on write failureJeremy Kerr2013-10-151-5/+8
| | | | | | | | | | | | | | Currently, if we see an error when writing to a client, we free the client immediately. This means that any pending reads will be discarded. Additionally, if a client disconnects before we have finished the writes in discover_server_process_connection, we won't register the waiter to read from the socket. Instead of freeing the client on write failure, this change sets a flag (se we don't continue to write), and we rely on the read EOF to free the client. This means we don't drop incoming messages. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Add system info messagesJeremy Kerr2013-10-091-0/+33
| | | | | | | | Add a little infrastructure for communicating information about the system to the petitboot UIs. We just send some identifying info (type and identifier), as well as the interfaces. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add "cancel default boot" messagesJeremy Kerr2013-06-241-9/+19
| | | | | | | Allow the default boot process to be cancelled, via a message with action PB_PROTOCOL_ACTION_CANCEL_DEFAULT. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/waiter: Add timeout waitersJeremy Kerr2013-06-241-3/+4
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: fix error handling from failed client writesJeremy Kerr2013-05-211-4/+9
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Fix accept() return value checkJeremy Kerr2013-05-211-1/+1
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: destroy client if message read failedJeremy Kerr2013-05-211-4/+11
| | | | | | | When a client disconnects, the read from the client's fd will return EOF. We should destroy the client in this situation. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Don't resend all options to all clientsJeremy Kerr2013-05-071-2/+1
| | | | | | | | | | Currently, when a new UI client connects, we send all boot options to all clients. This results in existing clients getting duplicate add events. Instead, we only want to send existing boot options to the new client. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add discover_server_notify_boot_statusJeremy Kerr2013-05-061-0/+27
| | | | | | Add a function to the server to notify clients of boot status updates. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Introduce a container type for boot optionsJeremy Kerr2013-04-291-4/+5
| | | | | | | | | This change introduces a new type, struct discover_boot_option. Like struct discover_device adds discover-specific data to struct device, struct discover_boot_option allows the discover server to store more than just the boot option strings for a boot option. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* protocol: Separate device add from boot-option add messagesJeremy Kerr2013-04-161-9/+41
| | | | | | | | | | | | | | | | | | | | We want to cater for situations where boot options may be discovered some time after we get notificiation about devices. For instance, discovering boot options from DHCP configuration parameters. In this case, we'll need to notify UIs of boot options appear some time after the device (and/or other boot options on the same device) has appeared. This change adds a new protocol message type, PB_PROTOCOL_ACTION_BOOT_OPTION_ADD. We also rename PB_PROTOCOL_ACTION_ADD to make it clear that it is just for devices. The discover server is updated to send boot option add events at device discover time, but we are now able to decouple this later. We also update the clients to handle the boot option add events separately. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* pb-protocol: Don't allocate in deserialise functionsJeremy Kerr2013-04-161-2/+5
| | | | | | | | | | | | | Curently, the protocol deserialise functions are allocating device and boot_command structures. This (implicitly) makes them responsible for initialisation of these structures too. Rather that making the protocol responsible for initialising the devices and boot commands, this change gives the deserialise functions an argument to an already-instanciated structure. This means that the creation is no longer implied by the deserialise. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Implement device handler boot pathJeremy Kerr2013-04-151-1/+1
| | | | | | | | | | This change adds a funtion, device_handler_boot, which processes the boot command message from the discover server. We add a new file, discover/boot.c (and a corresponding header) with a skeleton for the final kexec code. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: parse boot message from incoming ACTION_BOOT messagesJeremy Kerr2013-04-151-1/+9
| | | | | | | Add a function in the protocol code to deserialise a boot message, and use it to extract a boot_command in the discover server. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover-server: Add reference to server in struct clientJeremy Kerr2013-04-151-0/+2
| | | | | | We'll need to reference the server when handling messages from clients. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Allow discover server to receive boot messagesJeremy Kerr2013-04-151-2/+24
| | | | | | | | | | | | | | | Currently, the petitboot socket is one way: messages are only sent from server to client. Beause we want the clients to trigger a boot, this change allows the server to receive messages on the petitboot socket. This is just a matter of adding a waiter to the client-specific socket, then handling incoming messages. At present we don't do anything with the messages, but we'll add a handler later. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* waiter: Don't rely on global variables to keep waiter stateJeremy Kerr2013-04-101-3/+5
| | | | | | | | | Rather than defining the set of waiters (and pollfds) in waiter.c, add a struct waitset to contain these. A waitset is created with waitset_create, which is passed to the waiter_* functions. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Geoff Levand <geoff@infradead.org>
* Add discover device reportGeoff Levand2009-06-301-5/+7
| | | | | | | | | | Fillout the missing discover code that reports current devices. Replaces device_handler_get_current_devices() with two new accessor routines device_handler_get_device_count() and device_handler_get_device(). Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Log server messages to fileGeoff Levand2009-03-231-2/+2
| | | | | | | Log discover server messages to a file. Helps in debugging the server when is has problems at system startup. Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
* Make device instance constantGeoff Levand2009-02-011-2/+2
| | | | | | | Make the instance of devices read-only. Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Move log to libraryGeoff Levand2009-02-011-1/+1
| | | | | | | | | | | Move the log routines to the petitboot library. The log routines are generic enough to be used for both server and client. Does not change the log source. jk: move to lib/log/ instead of lib/ Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Move waiter to libraryGeoff Levand2009-02-011-1/+1
| | | | | | | | | | | Move the waiter routines into the petitboot library. The waiter routines are generic enough to be used for both server and client. Does not change the waiter source. jk: move to lib/waiter/ instead of lib/ Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Fix unused parameter warningsJeremy Kerr2009-02-011-1/+2
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Fix build warningsGeoff Levand2009-02-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | Fix various minor build warnings: lib/pb-protocol/pb-protocol.c:72: warning: comparison between signed and unsigned lib/pb-protocol/pb-protocol.c:78: warning: comparison between signed and unsigned lib/pb-protocol/pb-protocol.c:141: warning: unused parameter 'buf_len' lib/pb-protocol/pb-protocol.c:241: warning: comparison between signed and unsigned discover/pb-discover.c:14: warning: no previous prototype for 'sigint_handler' discover/pb-discover.c:13: warning: unused parameter 'signum' discover/log.c:22: warning: no previous prototype for 'pb_log_set_stream' discover/discover-server.c:159: warning: no previous prototype for 'discover_server_notify_add' discover/discover-server.c:169: warning: no previous prototype for 'discover_server_notify_remove' discover/discover-server.c:179: warning: no previous prototype for 'discover_server_set_device_source' discover/discover-server.c:184: warning: no previous prototype for 'discover_server_init' discover/discover-server.c:229: warning: no previous prototype for 'discover_server_destroy' discover/device-handler.c:395: warning: comparison between signed and unsigned discover/paths.c:44: warning: comparison between signed and unsigned Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Hook up parsers to device discoveryJeremy Kerr2009-01-021-0/+20
| | | | | | | | Iterate the parsers from the device handler on an add event. Initial change to just the kboot parser. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Remove reference to device.hJeremy Kerr2008-12-311-1/+0
| | | | | | It isn't needed anymore. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Create device-handler for managing registered devicesJeremy Kerr2008-12-151-29/+15
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Initial support for multiple UIsJeremy Kerr2008-12-151-0/+227
Move the device discovery code from separate udev helpers to a single process to listen on two sockets: one SOCK_DGRAM for incoming udev events, and one SOCK_STREAM for UIs to connect. Initial support for client/server infrastructure, still need to wire-up the udev messages. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
OpenPOWER on IntegriCloud