// <name>Previous</name> void previous_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data) { g_debug ("previous_cb"); gupnp_service_action_return_error (action, 701, "Transition not available"); }
// Helper to check for valid instance ids gboolean check_instance_id (GUPnPServiceAction *action) { guint instance_id; gupnp_service_action_get (action, "InstanceID", G_TYPE_UINT, &instance_id, NULL); if (instance_id != 0) { gupnp_service_action_return_error (action, 718, "Invalid InstanceID"); return FALSE; } return TRUE; }
static void add_port_mapping_cb (GUPnPService *service, GUPnPServiceAction *action, gpointer user_data) { guint requested_external_port = GPOINTER_TO_UINT (user_data); gchar *remote_host = NULL; guint external_port = 0; gchar *proto = NULL; guint internal_port = 0; gchar *internal_client = NULL; gboolean enabled = -1; gchar *desc = NULL; guint lease = 0; gupnp_service_action_get (action, "NewRemoteHost", G_TYPE_STRING, &remote_host, "NewExternalPort", G_TYPE_UINT, &external_port, "NewProtocol", G_TYPE_STRING, &proto, "NewInternalPort", G_TYPE_UINT, &internal_port, "NewInternalClient", G_TYPE_STRING, &internal_client, "NewEnabled", G_TYPE_BOOLEAN, &enabled, "NewPortMappingDescription", G_TYPE_STRING, &desc, "NewLeaseDuration", G_TYPE_UINT, &lease, NULL); g_assert (external_port); g_assert (remote_host && !strcmp (remote_host, "")); g_assert (proto && (!strcmp (proto, "UDP") || !strcmp (proto, "TCP"))); g_assert (internal_port == INTERNAL_PORT); g_assert (internal_client && !strcmp (internal_client, "192.168.4.22")); g_assert (enabled == TRUE); g_assert (desc != NULL); g_assert (lease == 10); g_free (remote_host); g_free (proto); g_free (internal_client); g_free (desc); if (requested_external_port) g_assert (external_port == requested_external_port); if (return_conflict && external_port == INTERNAL_PORT) gupnp_service_action_return_error (action, 718, "ConflictInMappingEntry"); else gupnp_service_action_return (action); }