Hello community,

here is the log from the commit of package libhdhomerun for openSUSE:Factory 
checked in at 2019-11-06 14:05:22
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/libhdhomerun (Old)
 and      /work/SRC/openSUSE:Factory/.libhdhomerun.new.2990 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "libhdhomerun"

Wed Nov  6 14:05:22 2019 rev:8 rq:745351 version:20190621

Changes:
--------
--- /work/SRC/openSUSE:Factory/libhdhomerun/libhdhomerun.changes        
2018-08-27 13:00:23.812884761 +0200
+++ /work/SRC/openSUSE:Factory/.libhdhomerun.new.2990/libhdhomerun.changes      
2019-11-06 14:05:28.300746196 +0100
@@ -1,0 +2,6 @@
+Wed Oct 30 17:43:04 UTC 2019 - Bjørn Lie <[email protected]>
+
+- Update to version 20190621:
+  Please read https://www.silicondust.com/support/downloads/software-changelog/
+
+-------------------------------------------------------------------

Old:
----
  hdhomerun_config_gui_20180327.tgz
  libhdhomerun_20180327.tgz

New:
----
  hdhomerun_config_gui_20190621.tgz
  libhdhomerun_20190621.tgz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ libhdhomerun.spec ++++++
--- /var/tmp/diff_new_pack.MkthMY/_old  2019-11-06 14:05:30.648748654 +0100
+++ /var/tmp/diff_new_pack.MkthMY/_new  2019-11-06 14:05:30.648748654 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package libhdhomerun
 #
-# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -12,13 +12,13 @@
 # license that conforms to the Open Source Definition (Version 1.9)
 # published by the Open Source Initiative.
 
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
 #
 
 
 %define         SO_NR 2
 Name:           libhdhomerun
-Version:        20180327
+Version:        20190621
 Release:        0
 Summary:        HDHomeRun library
 License:        LGPL-2.1-only


++++++ hdhomerun_config_gui_20180327.tgz -> hdhomerun_config_gui_20190621.tgz 
++++++

++++++ libhdhomerun_20180327.tgz -> libhdhomerun_20190621.tgz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhdhomerun/Makefile new/libhdhomerun/Makefile
--- old/libhdhomerun/Makefile   2016-11-18 19:48:11.000000000 +0100
+++ new/libhdhomerun/Makefile   2019-05-03 19:45:43.000000000 +0200
@@ -32,7 +32,7 @@
     LDFLAGS += -lsocket
   endif
   ifeq ($(OS),Darwin)
-    CFLAGS += -arch i386 -arch x86_64
+    CFLAGS += -arch x86_64
     LIBEXT := .dylib
     SHARED := -dynamiclib -install_name libhdhomerun$(LIBEXT)
   endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhdhomerun/hdhomerun_config.c 
new/libhdhomerun/hdhomerun_config.c
--- old/libhdhomerun/hdhomerun_config.c 2017-08-16 05:21:53.000000000 +0200
+++ new/libhdhomerun/hdhomerun_config.c 2019-04-09 20:00:26.000000000 +0200
@@ -91,27 +91,37 @@
        }
 
        struct hdhomerun_discover_device_t result_list[64];
-       int count = hdhomerun_discover_find_devices_custom_v2(target_ip, 
HDHOMERUN_DEVICE_TYPE_TUNER, HDHOMERUN_DEVICE_ID_WILDCARD, result_list, 64);
-       if (count < 0) {
+       int result_count = hdhomerun_discover_find_devices_custom_v2(target_ip, 
HDHOMERUN_DEVICE_TYPE_WILDCARD, HDHOMERUN_DEVICE_ID_WILDCARD, result_list, 64);
+       if (result_count < 0) {
                fprintf(stderr, "error sending discover request\n");
                return -1;
        }
-       if (count == 0) {
-               printf("no devices found\n");
-               return 0;
-       }
 
-       int index;
-       for (index = 0; index < count; index++) {
-               struct hdhomerun_discover_device_t *result = 
&result_list[index];
+       struct hdhomerun_discover_device_t *result = result_list;
+       struct hdhomerun_discover_device_t *result_end = result_list + 
result_count;
+
+       int valid_count = 0;
+       while (result < result_end) {
+               if (result->device_id == 0) {
+                       result++;
+                       continue;
+               }
+
                printf("hdhomerun device %08X found at %u.%u.%u.%u\n",
                        (unsigned int)result->device_id,
                        (unsigned int)(result->ip_addr >> 24) & 0x0FF, 
(unsigned int)(result->ip_addr >> 16) & 0x0FF,
                        (unsigned int)(result->ip_addr >> 8) & 0x0FF, (unsigned 
int)(result->ip_addr >> 0) & 0x0FF
                );
+
+               valid_count++;
+               result++;
+       }
+
+       if (valid_count == 0) {
+               printf("no devices found\n");
        }
 
-       return count;
+       return valid_count;
 }
 
 static int cmd_get(const char *item)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhdhomerun/hdhomerun_discover.c 
new/libhdhomerun/hdhomerun_discover.c
--- old/libhdhomerun/hdhomerun_discover.c       2017-06-12 21:31:29.000000000 
+0200
+++ new/libhdhomerun/hdhomerun_discover.c       2019-06-20 23:44:00.000000000 
+0200
@@ -168,34 +168,12 @@
        return hdhomerun_sock_sendto(dss->sock, target_ip, 
HDHOMERUN_DISCOVER_UDP_PORT, tx_pkt->start, tx_pkt->end - tx_pkt->start, 0);
 }
 
-static bool hdhomerun_discover_send_wildcard_ip(struct hdhomerun_discover_t 
*ds, uint32_t device_type, uint32_t device_id)
+static bool hdhomerun_discover_send(struct hdhomerun_discover_t *ds, uint32_t 
target_ip, uint32_t device_type, uint32_t device_id)
 {
-       bool result = false;
-
-       /*
-        * Send subnet broadcast using each local ip socket.
-        * This will work with multiple separate 169.254.x.x interfaces.
-        */
-       unsigned int i;
-       for (i = 1; i < ds->sock_count; i++) {
-               struct hdhomerun_discover_sock_t *dss = &ds->socks[i];
-               uint32_t target_ip = dss->local_ip | ~dss->subnet_mask;
-               result |= hdhomerun_discover_send_internal(ds, dss, target_ip, 
device_type, device_id);
+       if (target_ip == 0x00000000) {
+               target_ip = 0xFFFFFFFF;
        }
 
-       /*
-        * If no local ip sockets then fall back to sending a global broadcast 
letting the OS choose the interface.
-        */
-       if (!result) {
-               struct hdhomerun_discover_sock_t *dss = &ds->socks[0];
-               result = hdhomerun_discover_send_internal(ds, dss, 0xFFFFFFFF, 
device_type, device_id);
-       }
-
-       return result;
-}
-
-static bool hdhomerun_discover_send_target_ip(struct hdhomerun_discover_t *ds, 
uint32_t target_ip, uint32_t device_type, uint32_t device_id)
-{
        bool result = false;
 
        /*
@@ -205,11 +183,14 @@
        unsigned int i;
        for (i = 1; i < ds->sock_count; i++) {
                struct hdhomerun_discover_sock_t *dss = &ds->socks[i];
-               if (dss->subnet_mask == 0) {
-                       continue;
-               }
-               if ((target_ip & dss->subnet_mask) != (dss->local_ip & 
dss->subnet_mask)) {
-                       continue;
+       
+               if (target_ip != 0xFFFFFFFF) {
+                       if (dss->subnet_mask == 0) {
+                               continue;
+                       }
+                       if ((target_ip & dss->subnet_mask) != (dss->local_ip & 
dss->subnet_mask)) {
+                               continue;
+                       }
                }
 
                result |= hdhomerun_discover_send_internal(ds, dss, target_ip, 
device_type, device_id);
@@ -226,15 +207,6 @@
        return result;
 }
 
-static bool hdhomerun_discover_send(struct hdhomerun_discover_t *ds, uint32_t 
target_ip, uint32_t device_type, uint32_t device_id)
-{
-       if (target_ip == 0) {
-               return hdhomerun_discover_send_wildcard_ip(ds, device_type, 
device_id);
-       } else {
-               return hdhomerun_discover_send_target_ip(ds, target_ip, 
device_type, device_id);
-       }
-}
-
 static bool hdhomerun_discover_is_legacy(uint32_t device_id)
 {
        switch (device_id >> 20) {
@@ -257,7 +229,7 @@
        }
 }
 
-static bool hdhomerun_discover_recv_internal(struct hdhomerun_discover_t *ds, 
struct hdhomerun_discover_sock_t *dss, struct hdhomerun_discover_device_t 
*result)
+static bool hdhomerun_discover_recv_internal(struct hdhomerun_discover_t *ds, 
struct hdhomerun_discover_sock_t *dss, size_t result_struct_size, struct 
hdhomerun_discover_device_t *result)
 {
        static char hdhomerun_discover_recv_base64_encode_table[64 + 1] = 
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
        struct hdhomerun_pkt_t *rx_pkt = &ds->rx_pkt;
@@ -280,13 +252,10 @@
                return false;
        }
 
-       memset(result, 0, sizeof(struct hdhomerun_discover_device_t));
+       struct hdhomerun_discover_device_v3_t *result_v3 = (result_struct_size 
>= sizeof(struct hdhomerun_discover_device_v3_t)) ? (struct 
hdhomerun_discover_device_v3_t *)(void *)result : NULL;
+       memset(result, 0, result_struct_size);
        result->ip_addr = remote_addr;
 
-       hdhomerun_sprintf(result->base_url, result->base_url + 
sizeof(result->base_url), "http://%u.%u.%u.%u:80";,
-               (remote_addr >> 24) & 0xFF, (remote_addr >> 16) & 0xFF, 
(remote_addr >> 8) & 0xFF, (remote_addr >> 0) & 0xFF
-       );
-
        while (1) {
                uint8_t tag;
                size_t len;
@@ -327,13 +296,13 @@
                        result->device_auth[len] = 0;
                        break;
 
-               case HDHOMERUN_TAG_DEVICE_AUTH_BIN:
+               case HDHOMERUN_TAG_DEVICE_AUTH_BIN_DEPRECATED:
                        if (len != 18) {
                                break;
                        }
                        for (i = 0; i < 24; i += 4) {
                                uint32_t raw24;
-                               raw24  = 
(uint32_t)hdhomerun_pkt_read_u8(rx_pkt) << 16;
+                               raw24 = (uint32_t)hdhomerun_pkt_read_u8(rx_pkt) 
<< 16;
                                raw24 |= 
(uint32_t)hdhomerun_pkt_read_u8(rx_pkt) << 8;
                                raw24 |= 
(uint32_t)hdhomerun_pkt_read_u8(rx_pkt) << 0;
                                result->device_auth[i + 0] = 
hdhomerun_discover_recv_base64_encode_table[(raw24 >> 18) & 0x3F];
@@ -352,6 +321,39 @@
                        result->base_url[len] = 0;
                        break;
 
+               case HDHOMERUN_TAG_STORAGE_ID:
+                       if (!result_v3) {
+                               break;
+                       }
+                       if (len >= sizeof(result_v3->storage_id)) {
+                               break;
+                       }
+                       hdhomerun_pkt_read_mem(rx_pkt, result_v3->storage_id, 
len);
+                       result_v3->storage_id[len] = 0;
+                       break;
+
+               case HDHOMERUN_TAG_LINEUP_URL:
+                       if (!result_v3) {
+                               break;
+                       }
+                       if (len >= sizeof(result_v3->lineup_url)) {
+                               break;
+                       }
+                       hdhomerun_pkt_read_mem(rx_pkt, result_v3->lineup_url, 
len);
+                       result_v3->lineup_url[len] = 0;
+                       break;
+
+               case HDHOMERUN_TAG_STORAGE_URL:
+                       if (!result_v3) {
+                               break;
+                       }
+                       if (len >= sizeof(result_v3->storage_url)) {
+                               break;
+                       }
+                       hdhomerun_pkt_read_mem(rx_pkt, result_v3->storage_url, 
len);
+                       result_v3->storage_url[len] = 0;
+                       break;
+
                default:
                        break;
                }
@@ -359,34 +361,44 @@
                rx_pkt->pos = next;
        }
 
-       /* Fixup for old firmware. */
-       if (result->tuner_count == 0) {
-               switch (result->device_id >> 20) {
-               case 0x102:
-                       result->tuner_count = 1;
-                       break;
+       /*
+        * Fixup for old firmware.
+        */
+       if (result->device_type == HDHOMERUN_DEVICE_TYPE_TUNER) {
+               if (result->tuner_count == 0) {
+                       switch (result->device_id >> 20) {
+                       case 0x102:
+                               result->tuner_count = 1;
+                               break;
 
-               case 0x100:
-               case 0x101:
-               case 0x121:
-                       result->tuner_count = 2;
-                       break;
+                       case 0x100:
+                       case 0x101:
+                       case 0x121:
+                               result->tuner_count = 2;
+                               break;
 
-               default:
-                       break;
+                       default:
+                               break;
+                       }
+               }
+
+               if (!result->base_url[0]) {
+                       hdhomerun_sprintf(result->base_url, result->base_url + 
sizeof(result->base_url), "http://%u.%u.%u.%u:80";,
+                               (remote_addr >> 24) & 0xFF, (remote_addr >> 16) 
& 0xFF, (remote_addr >> 8) & 0xFF, (remote_addr >> 0) & 0xFF
+                       );
                }
        }
 
        return true;
 }
 
-static bool hdhomerun_discover_recv(struct hdhomerun_discover_t *ds, struct 
hdhomerun_discover_device_t *result)
+static bool hdhomerun_discover_recv(struct hdhomerun_discover_t *ds, size_t 
result_struct_size, struct hdhomerun_discover_device_t *result)
 {
        unsigned int i;
        for (i = 0; i < ds->sock_count; i++) {
                struct hdhomerun_discover_sock_t *dss = &ds->socks[i];
 
-               if (hdhomerun_discover_recv_internal(ds, dss, result)) {
+               if (hdhomerun_discover_recv_internal(ds, dss, 
result_struct_size, result)) {
                        return true;
                }
        }
@@ -394,36 +406,48 @@
        return false;
 }
 
-static struct hdhomerun_discover_device_t 
*hdhomerun_discover_find_in_list(struct hdhomerun_discover_device_t 
result_list[], int count, struct hdhomerun_discover_device_t *lookup)
+static struct hdhomerun_discover_device_t 
*hdhomerun_discover_result_by_index(size_t result_struct_size, struct 
hdhomerun_discover_device_t result_list[], int index)
+{
+       uint8_t *ptr = (uint8_t *)(void *)result_list;
+       ptr += result_struct_size * index;
+       return (struct hdhomerun_discover_device_t *)(void *)ptr;
+}
+
+static struct hdhomerun_discover_device_t 
*hdhomerun_discover_find_in_list(size_t result_struct_size, struct 
hdhomerun_discover_device_t result_list[], int count, struct 
hdhomerun_discover_device_t *lookup)
 {
        int index;
        for (index = 0; index < count; index++) {
-               struct hdhomerun_discover_device_t *entry = &result_list[index];
-               if (memcmp(lookup, entry, sizeof(struct 
hdhomerun_discover_device_t)) == 0) {
-                       return entry;
+               struct hdhomerun_discover_device_t *entry = 
hdhomerun_discover_result_by_index(result_struct_size, result_list, index);
+               if (lookup->ip_addr != entry->ip_addr) {
+                       continue;
                }
+
+               if (strcmp(lookup->base_url, entry->base_url) != 0) {
+                       continue;
+               }
+
+               return entry;
        }
 
        return NULL;
 }
 
-int hdhomerun_discover_find_devices_v2(struct hdhomerun_discover_t *ds, 
uint32_t target_ip, uint32_t device_type, uint32_t device_id, struct 
hdhomerun_discover_device_t result_list[], int max_count)
+static int hdhomerun_discover_find_devices(struct hdhomerun_discover_t *ds, 
uint32_t target_ip, uint32_t device_type_match, uint32_t device_id_match, 
size_t result_struct_size, struct hdhomerun_discover_device_t result_list[], 
int max_count)
 {
        hdhomerun_discover_sock_detect(ds);
 
        int count = 0;
        int attempt;
        for (attempt = 0; attempt < 2; attempt++) {
-               if (!hdhomerun_discover_send(ds, target_ip, device_type, 
device_id)) {
+               if (!hdhomerun_discover_send(ds, target_ip, device_type_match, 
device_id_match)) {
                        return -1;
                }
 
                uint64_t timeout = getcurrenttime() + 200;
                while (1) {
-                       struct hdhomerun_discover_device_t *result = 
&result_list[count];
-                       memset(result, 0, sizeof(struct 
hdhomerun_discover_device_t));
+                       struct hdhomerun_discover_device_t *result = 
hdhomerun_discover_result_by_index(result_struct_size, result_list, count);
 
-                       if (!hdhomerun_discover_recv(ds, result)) {
+                       if (!hdhomerun_discover_recv(ds, result_struct_size, 
result)) {
                                if (getcurrenttime() >= timeout) {
                                        break;
                                }
@@ -431,20 +455,16 @@
                                continue;
                        }
 
-                       /* Filter. */
-                       if (device_type != HDHOMERUN_DEVICE_TYPE_WILDCARD) {
-                               if (device_type != result->device_type) {
-                                       continue;
-                               }
+                       /* Filter */
+                       if ((device_type_match != 
HDHOMERUN_DEVICE_TYPE_WILDCARD) && (result->device_type != device_type_match)) {
+                               continue;
                        }
-                       if (device_id != HDHOMERUN_DEVICE_ID_WILDCARD) {
-                               if (device_id != result->device_id) {
-                                       continue;
-                               }
+                       if ((device_id_match != HDHOMERUN_DEVICE_ID_WILDCARD) 
&& (result->device_id != device_id_match)) {
+                               continue;
                        }
 
                        /* Ensure not already in list. */
-                       if (hdhomerun_discover_find_in_list(result_list, count, 
result)) {
+                       if (hdhomerun_discover_find_in_list(result_struct_size, 
result_list, count, result)) {
                                continue;
                        }
 
@@ -459,19 +479,36 @@
        return count;
 }
 
-int hdhomerun_discover_find_devices_custom_v2(uint32_t target_ip, uint32_t 
device_type, uint32_t device_id, struct hdhomerun_discover_device_t 
result_list[], int max_count)
+int hdhomerun_discover_find_devices_v3(struct hdhomerun_discover_t *ds, 
uint32_t target_ip, uint32_t device_type_match, uint32_t device_id_match, 
struct hdhomerun_discover_device_v3_t result_list[], int max_count)
 {
-       if (hdhomerun_discover_is_ip_multicast(target_ip)) {
-               return 0;
-       }
+       return hdhomerun_discover_find_devices(ds, target_ip, 
device_type_match, device_id_match, sizeof(struct 
hdhomerun_discover_device_v3_t), (struct hdhomerun_discover_device_t *)(void 
*)result_list, max_count);
+}
+
+int hdhomerun_discover_find_devices_v2(struct hdhomerun_discover_t *ds, 
uint32_t target_ip, uint32_t device_type_match, uint32_t device_id_match, 
struct hdhomerun_discover_device_t result_list[], int max_count)
+{
+       return hdhomerun_discover_find_devices(ds, target_ip, 
device_type_match, device_id_match, sizeof(struct hdhomerun_discover_device_t), 
(struct hdhomerun_discover_device_t *)(void *)result_list, max_count);
+}
 
+int hdhomerun_discover_find_devices_custom_v3(uint32_t target_ip, uint32_t 
device_type_match, uint32_t device_id_match, struct 
hdhomerun_discover_device_v3_t result_list[], int max_count)
+{
        struct hdhomerun_discover_t *ds = hdhomerun_discover_create(NULL);
        if (!ds) {
                return -1;
        }
 
-       int ret = hdhomerun_discover_find_devices_v2(ds, target_ip, 
device_type, device_id, result_list, max_count);
+       int ret = hdhomerun_discover_find_devices(ds, target_ip, 
device_type_match, device_id_match, sizeof(struct 
hdhomerun_discover_device_v3_t), (struct hdhomerun_discover_device_t *)(void 
*)result_list, max_count);
+       hdhomerun_discover_destroy(ds);
+       return ret;
+}
+
+int hdhomerun_discover_find_devices_custom_v2(uint32_t target_ip, uint32_t 
device_type_match, uint32_t device_id_match, struct hdhomerun_discover_device_t 
result_list[], int max_count)
+{
+       struct hdhomerun_discover_t *ds = hdhomerun_discover_create(NULL);
+       if (!ds) {
+               return -1;
+       }
 
+       int ret = hdhomerun_discover_find_devices(ds, target_ip, 
device_type_match, device_id_match, sizeof(struct hdhomerun_discover_device_t), 
(struct hdhomerun_discover_device_t *)(void *)result_list, max_count);
        hdhomerun_discover_destroy(ds);
        return ret;
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhdhomerun/hdhomerun_discover.h 
new/libhdhomerun/hdhomerun_discover.h
--- old/libhdhomerun/hdhomerun_discover.h       2017-03-20 01:22:34.000000000 
+0100
+++ new/libhdhomerun/hdhomerun_discover.h       2019-06-20 23:44:00.000000000 
+0200
@@ -1,7 +1,7 @@
 /*
  * hdhomerun_discover.h
  *
- * Copyright © 2006-2015 Silicondust USA Inc. <www.silicondust.com>.
+ * Copyright © 2006-2019 Silicondust USA Inc. <www.silicondust.com>.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -31,12 +31,26 @@
        char base_url[29];
 };
 
+struct hdhomerun_discover_device_v3_t {
+       uint32_t ip_addr;
+       uint32_t device_type;
+       uint32_t device_id;
+       uint8_t tuner_count;
+       bool is_legacy;
+       char device_auth[25];
+       char base_url[29];
+
+       char storage_id[37];
+       char lineup_url[128];
+       char storage_url[128];
+};
+
 /*
  * Find devices.
  *
  * The device information is stored in caller-supplied array of 
hdhomerun_discover_device_t vars.
  * Multiple attempts are made to find devices.
- * Execution time is typically 400ms if max_count is not reached.
+ * Execution time is typically 400ms unless max_count is reached.
  *
  * Set target_ip to zero to auto-detect the IP address.
  * Set device_type to HDHOMERUN_DEVICE_TYPE_TUNER to detect HDHomeRun tuner 
devices.
@@ -45,14 +59,16 @@
  * Returns the number of devices found.
  * Retruns -1 on error.
  */
-extern LIBHDHOMERUN_API int hdhomerun_discover_find_devices_custom_v2(uint32_t 
target_ip, uint32_t device_type, uint32_t device_id, struct 
hdhomerun_discover_device_t result_list[], int max_count);
+extern LIBHDHOMERUN_API int hdhomerun_discover_find_devices_custom_v2(uint32_t 
target_ip, uint32_t device_type_match, uint32_t device_id_match, struct 
hdhomerun_discover_device_t result_list[], int max_count);
+extern LIBHDHOMERUN_API int hdhomerun_discover_find_devices_custom_v3(uint32_t 
target_ip, uint32_t device_type_match, uint32_t device_id_match, struct 
hdhomerun_discover_device_v3_t result_list[], int max_count);
 
 /*
  * Optional: persistent discover instance available for discover polling use.
  */
 extern LIBHDHOMERUN_API struct hdhomerun_discover_t 
*hdhomerun_discover_create(struct hdhomerun_debug_t *dbg);
 extern LIBHDHOMERUN_API void hdhomerun_discover_destroy(struct 
hdhomerun_discover_t *ds);
-extern LIBHDHOMERUN_API int hdhomerun_discover_find_devices_v2(struct 
hdhomerun_discover_t *ds, uint32_t target_ip, uint32_t device_type, uint32_t 
device_id, struct hdhomerun_discover_device_t result_list[], int max_count);
+extern LIBHDHOMERUN_API int hdhomerun_discover_find_devices_v2(struct 
hdhomerun_discover_t *ds, uint32_t target_ip, uint32_t device_type_match, 
uint32_t device_id_match, struct hdhomerun_discover_device_t result_list[], int 
max_count);
+extern LIBHDHOMERUN_API int hdhomerun_discover_find_devices_v3(struct 
hdhomerun_discover_t *ds, uint32_t target_ip, uint32_t device_type_match, 
uint32_t device_id_match, struct hdhomerun_discover_device_v3_t result_list[], 
int max_count);
 
 /*
  * Verify that the device ID given is valid.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhdhomerun/hdhomerun_os_posix.h 
new/libhdhomerun/hdhomerun_os_posix.h
--- old/libhdhomerun/hdhomerun_os_posix.h       2017-06-12 21:31:29.000000000 
+0200
+++ new/libhdhomerun/hdhomerun_os_posix.h       2019-06-07 01:34:25.000000000 
+0200
@@ -53,6 +53,10 @@
 
 #define LIBHDHOMERUN_API
 
+#if !defined(alignas) && !defined(__cplusplus)
+#define alignas(n) __attribute__((aligned(n)))
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhdhomerun/hdhomerun_os_windows.h 
new/libhdhomerun/hdhomerun_os_windows.h
--- old/libhdhomerun/hdhomerun_os_windows.h     2017-06-12 21:31:29.000000000 
+0200
+++ new/libhdhomerun/hdhomerun_os_windows.h     2018-07-29 21:02:23.000000000 
+0200
@@ -56,6 +56,14 @@
 #define LIBHDHOMERUN_API
 #endif
 
+#if !defined(__unused)
+#define __unused __pragma(warning(suppress: 4100 4101))
+#endif
+
+#if !defined(alignas) && !defined(__cplusplus)
+#define alignas(n) __declspec(align(n))
+#endif
+
 typedef void (*sig_t)(int);
 typedef void (*thread_task_func_t)(void *arg);
 typedef HANDLE thread_task_t;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhdhomerun/hdhomerun_pkt.h 
new/libhdhomerun/hdhomerun_pkt.h
--- old/libhdhomerun/hdhomerun_pkt.h    2016-11-18 19:48:11.000000000 +0100
+++ new/libhdhomerun/hdhomerun_pkt.h    2019-06-20 23:44:00.000000000 +0200
@@ -127,9 +127,12 @@
 #define HDHOMERUN_TAG_GETSET_LOCKKEY 0x15
 #define HDHOMERUN_TAG_ERROR_MESSAGE 0x05
 #define HDHOMERUN_TAG_TUNER_COUNT 0x10
-#define HDHOMERUN_TAG_DEVICE_AUTH_BIN 0x29
+#define HDHOMERUN_TAG_LINEUP_URL 0x27
+#define HDHOMERUN_TAG_STORAGE_URL 0x28
+#define HDHOMERUN_TAG_DEVICE_AUTH_BIN_DEPRECATED 0x29
 #define HDHOMERUN_TAG_BASE_URL 0x2A
 #define HDHOMERUN_TAG_DEVICE_AUTH_STR 0x2B
+#define HDHOMERUN_TAG_STORAGE_ID 0x2C
 
 #define HDHOMERUN_DEVICE_TYPE_WILDCARD 0xFFFFFFFF
 #define HDHOMERUN_DEVICE_TYPE_TUNER 0x00000001
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhdhomerun/hdhomerun_sock_posix.c 
new/libhdhomerun/hdhomerun_sock_posix.c
--- old/libhdhomerun/hdhomerun_sock_posix.c     2017-03-20 01:22:34.000000000 
+0100
+++ new/libhdhomerun/hdhomerun_sock_posix.c     2019-06-11 22:11:19.000000000 
+0200
@@ -1,7 +1,7 @@
 /*
  * hdhomerun_sock_posix.c
  *
- * Copyright © 2010-2016 Silicondust USA Inc. <www.silicondust.com>.
+ * Copyright © 2010-2019 Silicondust USA Inc. <www.silicondust.com>.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -20,16 +20,13 @@
 
 #include "hdhomerun.h"
 
-#include <net/if.h>
+#if defined(LIBHDHOMERUN_USE_SIOCGIFCONF)
 #include <sys/ioctl.h>
-
-#ifndef SIOCGIFCONF
-#include <sys/sockio.h>
+#else
+#include <ifaddrs.h>
 #endif
 
-#ifndef _SIZEOF_ADDR_IFREQ
-#define _SIZEOF_ADDR_IFREQ(x) sizeof(x)
-#endif
+#include <net/if.h>
 
 #ifndef MSG_NOSIGNAL
 #define MSG_NOSIGNAL 0
@@ -39,93 +36,134 @@
        int sock;
 };
 
+#if defined(LIBHDHOMERUN_USE_SIOCGIFCONF)
 int hdhomerun_local_ip_info(struct hdhomerun_local_ip_info_t ip_info_list[], 
int max_count)
 {
-       int sock = socket(AF_INET, SOCK_DGRAM, 0);
+       int sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
        if (sock == -1) {
                return -1;
        }
 
-       struct ifconf ifc;
-       size_t ifreq_buffer_size = 1024;
-
-       while (1) {
-               ifc.ifc_len = (int)ifreq_buffer_size;
-               ifc.ifc_buf = (char *)malloc(ifreq_buffer_size);
-               if (!ifc.ifc_buf) {
-                       close(sock);
-                       return -1;
-               }
-
-               memset(ifc.ifc_buf, 0, ifreq_buffer_size);
-
-               if (ioctl(sock, SIOCGIFCONF, &ifc) != 0) {
-                       free(ifc.ifc_buf);
-                       close(sock);
-                       return -1;
-               }
+       int ifreq_buffer_size = 128 * sizeof(struct ifreq);
+       char *ifreq_buffer = (char *)calloc(ifreq_buffer_size, 1);
+       if (!ifreq_buffer) {
+               close(sock);
+               return -1;
+       }
 
-               if (ifc.ifc_len < (int)ifreq_buffer_size) {
-                       break;
-               }
+       struct ifconf ifc;
+       ifc.ifc_len = ifreq_buffer_size;
+       ifc.ifc_buf = ifreq_buffer;
 
-               free(ifc.ifc_buf);
-               ifreq_buffer_size += 1024;
+       if (ioctl(sock, SIOCGIFCONF, &ifc) != 0) {
+               free(ifreq_buffer);
+               close(sock);
+               return -1;
        }
+       
+       if (ifc.ifc_len > ifreq_buffer_size) {
+               ifc.ifc_len = ifreq_buffer_size;
+       }
+
+       struct hdhomerun_local_ip_info_t *ip_info = ip_info_list;
+       int count = 0;
 
        char *ptr = ifc.ifc_buf;
        char *end = ifc.ifc_buf + ifc.ifc_len;
 
-       int count = 0;
-       while (ptr < end) {
+       while (ptr + sizeof(struct ifreq) <= end) {
                struct ifreq *ifr = (struct ifreq *)ptr;
-               ptr += _SIZEOF_ADDR_IFREQ(*ifr);
+               ptr += sizeof(struct ifreq);
+
+               /* Local IP address. */
+               struct sockaddr_in *ip_addr_in = (struct sockaddr_in 
*)&ifr->ifr_addr;
+               uint32_t ip_addr = ntohl(ip_addr_in->sin_addr.s_addr);
+               if (ip_addr == 0) {
+                       continue;
+               }
 
                /* Flags. */
                if (ioctl(sock, SIOCGIFFLAGS, ifr) != 0) {
                        continue;
                }
 
-               if ((ifr->ifr_flags & IFF_UP) == 0) {
+               unsigned int flags = ifr->ifr_flags & (IFF_LOOPBACK | 
IFF_POINTOPOINT | IFF_UP | IFF_RUNNING);
+               if (flags != (IFF_UP | IFF_RUNNING)) {
                        continue;
                }
-               if ((ifr->ifr_flags & IFF_RUNNING) == 0) {
+
+               /* Subnet mask. */
+               if (ioctl(sock, SIOCGIFNETMASK, ifr) != 0) {
                        continue;
                }
 
-               /* Local IP address. */
-               if (ioctl(sock, SIOCGIFADDR, ifr) != 0) {
+               struct sockaddr_in *subnet_mask_in = (struct sockaddr_in 
*)&ifr->ifr_addr;
+               uint32_t subnet_mask = ntohl(subnet_mask_in->sin_addr.s_addr);
+
+               /* Result. */
+               if (count < max_count) {
+                       ip_info->ip_addr = ip_addr;
+                       ip_info->subnet_mask = subnet_mask;
+                       ip_info++;
+               }
+
+               count++;
+       }
+
+       free(ifreq_buffer);
+       close(sock);
+       return count;
+}
+#else
+int hdhomerun_local_ip_info(struct hdhomerun_local_ip_info_t ip_info_list[], 
int max_count)
+{
+       struct ifaddrs *ifaddrs;
+       if (getifaddrs(&ifaddrs) != 0) {
+               return -1;
+       }
+
+       struct hdhomerun_local_ip_info_t *ip_info = ip_info_list;
+       struct ifaddrs *ifa = ifaddrs;
+       int count = 0;
+
+       while (ifa) {
+               if (ifa->ifa_addr == NULL) {
+                       ifa = ifa->ifa_next;
                        continue;
                }
 
-               struct sockaddr_in *ip_addr_in = (struct sockaddr_in 
*)&(ifr->ifr_addr);
-               uint32_t ip_addr = ntohl(ip_addr_in->sin_addr.s_addr);
-               if (ip_addr == 0) {
+               if (ifa->ifa_addr->sa_family != AF_INET) {
+                       ifa = ifa->ifa_next;
                        continue;
                }
 
-               /* Subnet mask. */
-               if (ioctl(sock, SIOCGIFNETMASK, ifr) != 0) {
+               unsigned int flags = ifa->ifa_flags & (IFF_LOOPBACK | 
IFF_POINTOPOINT | IFF_UP | IFF_RUNNING);
+               if (flags != (IFF_UP | IFF_RUNNING)) {
+                       ifa = ifa->ifa_next;
                        continue;
                }
 
-               struct sockaddr_in *subnet_mask_in = (struct sockaddr_in 
*)&(ifr->ifr_addr);
-               uint32_t subnet_mask = ntohl(subnet_mask_in->sin_addr.s_addr);
+               struct sockaddr_in *addr_in = (struct sockaddr_in 
*)ifa->ifa_addr;
+               uint32_t ip_addr = ntohl(addr_in->sin_addr.s_addr);
+
+               struct sockaddr_in *netmask_in = (struct sockaddr_in 
*)ifa->ifa_netmask;
+               uint32_t subnet_mask = ntohl(netmask_in->sin_addr.s_addr);
+
+               ifa = ifa->ifa_next;
 
-               /* Report. */
                if (count < max_count) {
-                       struct hdhomerun_local_ip_info_t *ip_info = 
&ip_info_list[count];
                        ip_info->ip_addr = ip_addr;
                        ip_info->subnet_mask = subnet_mask;
+                       ip_info++;
                }
 
                count++;
        }
 
-       free(ifc.ifc_buf);
-       close(sock);
+       freeifaddrs(ifaddrs);
        return count;
 }
+#endif
 
 static struct hdhomerun_sock_t *hdhomerun_sock_create_internal(int protocol)
 {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhdhomerun/hdhomerun_video.c 
new/libhdhomerun/hdhomerun_video.c
--- old/libhdhomerun/hdhomerun_video.c  2017-06-09 23:45:25.000000000 +0200
+++ new/libhdhomerun/hdhomerun_video.c  2018-10-31 01:31:49.000000000 +0100
@@ -183,18 +183,26 @@
 
 static void hdhomerun_video_stats_ts_pkt(struct hdhomerun_video_sock_t *vs, 
uint8_t *ptr)
 {
-       uint16_t packet_identifier = ((uint16_t)(ptr[1] & 0x1F) << 8) | 
(uint16_t)ptr[2];
-       if (packet_identifier == 0x1FFF) {
-               return;
-       }
+       uint16_t packet_identifier;
+       packet_identifier  = (uint16_t)(ptr[1] & 0x1F) << 8;
+       packet_identifier |= (uint16_t)ptr[2] << 0;
 
-       bool transport_error = ptr[1] >> 7;
+       bool transport_error = (ptr[1] & 0x80) != 0;
        if (transport_error) {
                vs->transport_error_count++;
                vs->sequence[packet_identifier] = 0xFF;
                return;
        }
 
+       if (packet_identifier == 0x1FFF) {
+               return;
+       }
+
+       bool payload_present = (ptr[3] & 0x10) != 0;
+       if (!payload_present) {
+               return;
+       }
+
        uint8_t sequence = ptr[3] & 0x0F;
 
        uint8_t previous_sequence = vs->sequence[packet_identifier];
@@ -206,9 +214,6 @@
        if (sequence == ((previous_sequence + 1) & 0x0F)) {
                return;
        }
-       if (sequence == previous_sequence) {
-               return;
-       }
 
        vs->sequence_error_count++;
 }


Reply via email to