Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
iptv: provide list of network interfaces
Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
  • Loading branch information
swegener authored and perexg committed Nov 14, 2015
1 parent 8921df2 commit aa55a90
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
10 changes: 10 additions & 0 deletions configure
Expand Up @@ -251,6 +251,16 @@ if enabled_or_auto dvben50221; then
fi
fi

check_cc_snippet ifnames '
#include <net/if.h>
int test(void)
{
struct if_nameindex *ifnames = if_nameindex();
if_freenameindex(ifnames);
return 0;
}
'

#
# Python
#
Expand Down
1 change: 1 addition & 0 deletions src/input/mpegts/iptv/iptv_mux.c
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/tvheadend.h
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions src/utils.c
Expand Up @@ -26,6 +26,7 @@
#include <dirent.h>
#include <unistd.h>
#include <ctype.h>
#include <net/if.h>

#include <openssl/sha.h>

Expand Down Expand Up @@ -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
}

0 comments on commit aa55a90

Please sign in to comment.