GNOME Bugzilla – Bug 729613
Add support to add vendor specific headers to messages
Last modified: 2019-02-22 09:30:03 UTC
Created attachment 275932 [details] [review] Add support for additionnal vendor specific headers in messages I'm developping a library to control a Sonos system. The controller discover the components using SSDP, however, the messages add a custom a custom field to avoir discovery response from other Sonos systems. X-RINCON-HOUSEHOLD: Sonos_somelongidentifier The ideal solution would be to be have an api directly in gssdp to do that. Here's my take on this. New methods are: void gssdp_client_append_header (GSSDPClient *client, const char *name, const char *value); void gssdp_client_remove_header (GSSDPClient *client, const gchar *name); void gssdp_client_clear_headers (GSSDPClient *client); Of course, some other methods could easily be added if needed, for example: void gssdp_client_append_headers (GSSDPClient *client, ...); const char* gssdp_client_lookup_header (GSSDPClient *client, const char *name); etc. I realize this is out of the protocol definition, but I couldn't find a better way to realize that without re-implementating the whole of GSSDP in my library.
Created attachment 276251 [details] [review] Check each existing attachment made obsolete by your new attachment. Re-upload the diff so it appears as a patch
This patch breaks the functional tests: /functional/resource-group/discovery/ssdp:all: ** (/home/jens/Source/gssdp/tests/gtest/.libs/lt-test-functional:20515): WARNING **: Received packet lacks "\r\n\r\n" sequence. Packed dropped.
Created attachment 277112 [details] [review] Add support for additionnal vendor specific headers in messages Fix the tests
Review of attachment 277112 [details] [review]: ::: libgssdp/gssdp-client.c @@ +852,3 @@ + const gchar *message) +{ + GList *iter; Somehow implementing this using GString would look easier to me than dupping, mallocing joining and freeing @@ +1002,3 @@ inet_address = g_inet_address_new_from_string (dest_ip); address = g_inet_socket_address_new (inet_address, dest_port); + extended_message = append_header_fields (client, message); Are you sure you want to apply the headers to all kind of messages?
Created attachment 277114 [details] [review] Add support for additionnal vendor specific headers in messages Use GString instread of joining substrings
(In reply to comment #4) > Are you sure you want to apply the headers to all kind of messages? For my use case, I only need the extensions on the discovery requests but I'm not quite sure what other scenarios are possible. Also, ideally, we could read the vendor-specific headers of received messages. Unfortunately, I don't see how that's possible without breaking the API...
(In reply to comment #6) > (In reply to comment #4) > Also, ideally, we could read the vendor-specific headers of received messages. > Unfortunately, I don't see how that's possible without breaking the API... True. Maybe something to keep in mind for when that's the case.
Attachment 277114 [details] pushed as 9f02229 - Add support for additionnal vendor specific headers in messages
Have to re-open. This patch breaks sending of SSDP packets to my WDTV live.
Sorry, fooled by bisect