Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
dbus: SAT>IP allow to block the server by IP address
  • Loading branch information
perexg committed Aug 11, 2014
1 parent 9d6ab33 commit 840a0ae
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/dbus.c
Expand Up @@ -227,6 +227,9 @@ dbus_reply_to_rpc(dbus_rpc_t *rpc, DBusMessage *msg, DBusConnection *conn)
path = dbus_message_get_path(msg);
if (path == NULL)
return;
if (strncmp(path, "/org/tvheadend/", 15))
return;
path += 14;
if (!dbus_message_iter_init(msg, &args))
return;
if (rpc->rpc_s64) {
Expand Down
41 changes: 41 additions & 0 deletions src/input/mpegts/satip/satip.c
Expand Up @@ -55,6 +55,46 @@ satip_device_dbus_notify( satip_device_t *sd, const char *sig_name )
#endif
}

static void
satip_device_block( const char *addr, int block )
{
extern const idclass_t satip_device_class;
tvh_hardware_t *th;
satip_device_t *sd;
satip_frontend_t *lfe;

pthread_mutex_lock(&global_lock);
TVH_HARDWARE_FOREACH(th) {
if (!idnode_is_instance(&th->th_id, &satip_device_class))
continue;
sd = (satip_device_t *)th;
if (strcmp(sd->sd_info.addr, addr) == 0) {
sd->sd_dbus_block = block < 0 ? 0 : block;
if (block < 0) {
TAILQ_FOREACH(lfe, &sd->sd_frontends, sf_link)
mpegts_input_stop_all((mpegts_input_t *)lfe);
}
}
}
pthread_mutex_unlock(&global_lock);
}

static char *
satip_device_addr( void *aux, const char *path, char *value )
{
if (strcmp(path, "/stop") == 0) {
satip_device_block(value, -1);
return strdup("ok");
} else if (strcmp(path, "/disable") == 0) {
satip_device_block(value, 0);
return strdup("ok");
} else if (strcmp(path, "/allow") == 0) {
satip_device_block(value, 1);
return strdup("ok");
}
return strdup("err");
}

/*
* SAT-IP client
*/
Expand Down Expand Up @@ -978,6 +1018,7 @@ void satip_init ( str_list_t *clients )
{
TAILQ_INIT(&satip_discoveries);
satip_static_clients = clients;
dbus_register_rpc_str("satip_addr", NULL, satip_device_addr);
satip_device_discovery_start();
}

Expand Down
1 change: 1 addition & 0 deletions src/input/mpegts/satip/satip_frontend.c
Expand Up @@ -376,6 +376,7 @@ satip_frontend_is_enabled ( mpegts_input_t *mi, mpegts_mux_t *mm,
lock_assert(&global_lock);

if (!mpegts_input_is_enabled(mi, mm, reason)) return 0;
if (lfe->sf_device->sd_dbus_block) return 0;
if (lfe->sf_type != DVB_TYPE_S) return 1;
/* check if the position is enabled */
position = satip_satconf_get_position(lfe, mm);
Expand Down
1 change: 1 addition & 0 deletions src/input/mpegts/satip/satip_private.h
Expand Up @@ -81,6 +81,7 @@ struct satip_device
int sd_sig_scale;
int sd_pids0;
int sd_pilot_on;
int sd_dbus_block;
pthread_mutex_t sd_tune_mutex;
};

Expand Down

0 comments on commit 840a0ae

Please sign in to comment.