From aa55a9051752c5510306e68770023de690b1ec2e Mon Sep 17 00:00:00 2001 From: Sven Wegener Date: Wed, 11 Nov 2015 15:58:33 +0100 Subject: [PATCH] iptv: provide list of network interfaces Signed-off-by: Sven Wegener --- configure | 10 ++++++++++ src/input/mpegts/iptv/iptv_mux.c | 1 + src/tvheadend.h | 2 ++ src/utils.c | 24 ++++++++++++++++++++++++ 4 files changed, 37 insertions(+) diff --git a/configure b/configure index 4bea36ac3..99adb4085 100755 --- a/configure +++ b/configure @@ -251,6 +251,16 @@ if enabled_or_auto dvben50221; then fi fi +check_cc_snippet ifnames ' +#include +int test(void) +{ + struct if_nameindex *ifnames = if_nameindex(); + if_freenameindex(ifnames); + return 0; +} +' + # # Python # diff --git a/src/input/mpegts/iptv/iptv_mux.c b/src/input/mpegts/iptv/iptv_mux.c index c13892ad8..6ae07704e 100644 --- a/src/input/mpegts/iptv/iptv_mux.c +++ b/src/input/mpegts/iptv/iptv_mux.c @@ -152,6 +152,7 @@ const idclass_t iptv_mux_class = .id = "iptv_interface", .name = N_("Interface"), .off = offsetof(iptv_mux_t, mm_iptv_interface), + .list = network_interfaces_enum, }, { .type = PT_BOOL, diff --git a/src/tvheadend.h b/src/tvheadend.h index d06a858a1..e8b749ac7 100644 --- a/src/tvheadend.h +++ b/src/tvheadend.h @@ -783,6 +783,8 @@ static inline uint32_t deltaU32(uint32_t a, uint32_t b) { return (a > b) ? (a - #define SKEL_USED(name) do { name = NULL; } while (0) #define SKEL_FREE(name) do { free(name); name = NULL; } while (0) +htsmsg_t *network_interfaces_enum(void *obj, const char *lang); + /* glibc wrapper */ #if ! ENABLE_QSORT_R void diff --git a/src/utils.c b/src/utils.c index be39c4e62..850e28de8 100644 --- a/src/utils.c +++ b/src/utils.c @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -774,3 +775,26 @@ gcdU32(uint32_t a, uint32_t b) return b; } } + +htsmsg_t *network_interfaces_enum(void *obj, const char *lang) +{ +#if ENABLE_IFNAMES + htsmsg_t *list = htsmsg_create_list(); + struct if_nameindex *ifnames = if_nameindex(); + + if (ifnames) { + struct if_nameindex *ifname; + for (ifname = ifnames; ifname->if_name; ifname++) { + htsmsg_t *entry = htsmsg_create_map(); + htsmsg_add_str(entry, "key", ifname->if_name); + htsmsg_add_str(entry, "val", ifname->if_name); + htsmsg_add_msg(list, NULL, entry); + } + if_freenameindex(ifnames); + } + + return list; +#else + return NULL; +#endif +} -- 2.47.3