Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Backports:SLE-15:Update
ushare
upnp167-port.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File upnp167-port.patch of Package ushare
--- src/http.c | 22 +++++++++++++--------- src/http.h | 5 +---- src/ushare.c | 25 ++++++++++++++++++------- 3 files changed, 32 insertions(+), 20 deletions(-) --- a/src/http.c +++ b/src/http.c @@ -404,12 +404,16 @@ http_close (UpnpWebFileHandle fh) return 0; } -struct UpnpVirtualDirCallbacks virtual_dir_callbacks = - { - http_get_info, - http_open, - http_read, - http_write, - http_seek, - http_close - }; +int register_virtual_dir_callbacks(void) +{ + int ret = 0; + + ret |= UpnpVirtualDir_set_GetInfoCallback(http_get_info); + ret |= UpnpVirtualDir_set_OpenCallback(http_open); + ret |= UpnpVirtualDir_set_ReadCallback(http_read); + ret |= UpnpVirtualDir_set_WriteCallback(http_write); + ret |= UpnpVirtualDir_set_SeekCallback(http_seek); + ret |= UpnpVirtualDir_set_CloseCallback(http_close); + + return ret; +} --- a/src/http.h +++ b/src/http.h @@ -22,9 +22,6 @@ #ifndef _HTTP_H_ #define _HTTP_H_ -#include <upnp/upnp.h> -#include <upnp/upnptools.h> - -struct UpnpVirtualDirCallbacks virtual_dir_callbacks; +int register_virtual_dir_callbacks(void); #endif /* _HTTP_H_ */ --- a/src/ushare.c +++ b/src/ushare.c @@ -28,6 +28,8 @@ #include <errno.h> #include <getopt.h> +#include <arpa/inet.h> + #if (defined(BSD) || defined(__FreeBSD__) || defined(__APPLE__)) #include <sys/socket.h> #include <sys/sysctl.h> @@ -171,13 +173,23 @@ ushare_signal_exit (void) pthread_mutex_unlock (&ut->termination_mutex); } +static const void *get_address_ptr(struct sockaddr *sa) +{ + switch (sa->sa_family) { + case AF_INET: + return &(((struct sockaddr_in*)sa)->sin_addr); + case AF_INET6: + return &(((struct sockaddr_in6*)sa)->sin6_addr); + } + return NULL; +} + static void handle_action_request (struct Upnp_Action_Request *request) { struct service_t *service; struct service_action_t *action; char val[256]; - uint32_t ip; if (!request || !ut) return; @@ -188,10 +200,9 @@ handle_action_request (struct Upnp_Actio if (strcmp (request->DevUDN + 5, ut->udn)) return; - ip = request->CtrlPtIPAddr.s_addr; - ip = ntohl (ip); - sprintf (val, "%d.%d.%d.%d", - (ip >> 24) & 0xFF, (ip >> 16) & 0xFF, (ip >> 8) & 0xFF, ip & 0xFF); + inet_ntop(request->CtrlPtIPAddr.ss_family, + get_address_ptr((struct sockaddr *)&request->CtrlPtIPAddr), val, + sizeof(val)); if (ut->verbose) { @@ -348,8 +359,8 @@ init_upnp (struct ushare_t *ut) UpnpEnableWebserver (TRUE); - res = UpnpSetVirtualDirCallbacks (&virtual_dir_callbacks); - if (res != UPNP_E_SUCCESS) + res = register_virtual_dir_callbacks(); + if (res) { log_error (_("Cannot set virtual directory callbacks\n")); free (description);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor