aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libesg/bootstrap
diff options
context:
space:
mode:
authorMark Purcell <msp@debian.org>2008-06-22 11:00:40 +1000
committeretobi <git@e-tobi.net>2013-09-03 09:48:42 +0200
commit891c51ff368ed700dec6025eeb47ce4d96f76418 (patch)
tree3729664829e4faa691d403274f38eb10890b533c /lib/libesg/bootstrap
parent1c6e1f28f54ec2606c23936c1d8689f2be55a86c (diff)
parentab959d7b4194715870128e616b8e29d4a101e488 (diff)
downloadlinux-dvb-apps-a966623153d5c69ef1565422644280751ce04112.tar.gz
Imported Debian patch 1.1.1+rev1207-1debian/1.1.1+rev1207-1
Diffstat (limited to 'lib/libesg/bootstrap')
-rw-r--r--lib/libesg/bootstrap/Makefile24
-rw-r--r--lib/libesg/bootstrap/access_descriptor.c115
-rw-r--r--lib/libesg/bootstrap/access_descriptor.h86
-rw-r--r--lib/libesg/bootstrap/provider_discovery_descriptor.c50
-rw-r--r--lib/libesg/bootstrap/provider_discovery_descriptor.h59
5 files changed, 334 insertions, 0 deletions
diff --git a/lib/libesg/bootstrap/Makefile b/lib/libesg/bootstrap/Makefile
new file mode 100644
index 0000000..16a2457
--- /dev/null
+++ b/lib/libesg/bootstrap/Makefile
@@ -0,0 +1,24 @@
+# Makefile for linuxtv.org dvb-apps/lib/libesg/bootstrap
+
+.PHONY: sub-error-bootstrap
+
+sub-error-bootstrap:
+ $(error You can't use this makefile directly.)
+
+ifneq ($(lib_name),)
+
+objects += bootstrap/access_descriptor.o \
+ bootstrap/provider_discovery_descriptor.o
+
+sub-install += bootstrap
+
+else
+
+includes = access_descriptor.h \
+ provider_discovery_descriptor.h
+
+include ../../../Make.rules
+
+lib_name = libesg/bootstrap
+
+endif
diff --git a/lib/libesg/bootstrap/access_descriptor.c b/lib/libesg/bootstrap/access_descriptor.c
new file mode 100644
index 0000000..e8f89a3
--- /dev/null
+++ b/lib/libesg/bootstrap/access_descriptor.c
@@ -0,0 +1,115 @@
+/*
+ * ESG parser
+ *
+ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <libesg/bootstrap/access_descriptor.h>
+
+struct esg_access_descriptor *esg_access_descriptor_decode(uint8_t *buffer, uint32_t size) {
+ uint32_t pos;
+ struct esg_access_descriptor *access_descriptor;
+ struct esg_entry *entry;
+ struct esg_entry *last_entry;
+ uint32_t entry_length;
+ uint16_t entry_index;
+ uint8_t ip_index;
+
+ if ((buffer == NULL) || (size <= 2)) {
+ return NULL;
+ }
+
+ pos = 0;
+
+ access_descriptor = (struct esg_access_descriptor *) malloc(sizeof(struct esg_access_descriptor));
+ memset(access_descriptor, 0, sizeof(struct esg_access_descriptor));
+ access_descriptor->entry_list = NULL;
+
+ access_descriptor->n_o_entries = (buffer[pos] << 8) | buffer[pos+1];
+ pos += 2;
+
+ last_entry = NULL;
+ for (entry_index = 0; entry_index < access_descriptor->n_o_entries; entry_index++) {
+ entry = (struct esg_entry *) malloc(sizeof(struct esg_entry));
+ memset(entry, 0, sizeof(struct esg_entry));
+ entry->_next = NULL;
+
+ if (last_entry == NULL) {
+ access_descriptor->entry_list = entry;
+ } else {
+ last_entry->_next = entry;
+ }
+ last_entry = entry;
+
+ entry->version = buffer[pos];
+ pos += 1;
+
+ pos += vluimsbf8(buffer + pos, size - pos, &entry_length);
+
+ if (size < pos + entry_length) {
+ esg_access_descriptor_free(access_descriptor);
+ return NULL;
+ }
+
+ entry->multiple_stream_transport = (buffer[pos] & 0x80) ? 1 : 0;
+ entry->ip_version_6 = (buffer[pos] & 0x40) ? 1 : 0;
+ pos += 1;
+
+ entry->provider_id = (buffer[pos] << 8) | buffer[pos+1];
+ pos += 2;
+
+ if (entry->ip_version_6) {
+ for (ip_index = 0; ip_index < 16; ip_index++) {
+ entry->source_ip.ipv6[ip_index] = buffer[pos+ip_index];
+ entry->destination_ip.ipv6[ip_index] = buffer[pos+16+ip_index];
+ }
+ pos += 32;
+ } else {
+ for (ip_index = 0; ip_index < 4; ip_index++) {
+ entry->source_ip.ipv4[ip_index] = buffer[pos+ip_index];
+ entry->destination_ip.ipv4[ip_index] = buffer[pos+4+ip_index];
+ }
+ pos += 8;
+ }
+ entry->port = (buffer[pos] << 8) | buffer[pos+1];
+ pos += 2;
+
+ entry->tsi = (buffer[pos] << 8) | buffer[pos+1];
+ pos += 2;
+ }
+
+ return access_descriptor;
+}
+
+void esg_access_descriptor_free(struct esg_access_descriptor *access_descriptor) {
+ struct esg_entry *entry;
+ struct esg_entry *next_entry;
+
+ if (access_descriptor == NULL) {
+ return;
+ }
+
+ for(entry = access_descriptor->entry_list; entry; entry = next_entry) {
+ next_entry = entry->_next;
+ free(entry);
+ }
+
+ free(access_descriptor);
+}
diff --git a/lib/libesg/bootstrap/access_descriptor.h b/lib/libesg/bootstrap/access_descriptor.h
new file mode 100644
index 0000000..49aec46
--- /dev/null
+++ b/lib/libesg/bootstrap/access_descriptor.h
@@ -0,0 +1,86 @@
+/*
+ * ESG parser
+ *
+ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef _ESG_BOOTSTRAP_ACCESS_DESCRIPTOR_H
+#define _ESG_BOOTSTRAP_ACCESS_DESCRIPTOR_H 1
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <libesg/types.h>
+
+/**
+ * esg_entry structure.
+ */
+struct esg_entry {
+ uint8_t version;
+ uint8_t multiple_stream_transport;
+ uint8_t ip_version_6;
+ uint16_t provider_id;
+ union esg_ip_address source_ip;
+ union esg_ip_address destination_ip;
+ uint16_t port;
+ uint16_t tsi;
+
+ struct esg_entry *_next;
+};
+
+/**
+ * esg_access_descriptor structure.
+ */
+struct esg_access_descriptor {
+ uint16_t n_o_entries;
+ struct esg_entry *entry_list;
+};
+
+/**
+ * Process an esg_access_descriptor.
+ *
+ * @param buffer Binary buffer to decode.
+ * @param size Binary buffer size.
+ * @return Pointer to an esg_access_descriptor structure, or NULL on error.
+ */
+extern struct esg_access_descriptor *esg_access_descriptor_decode(uint8_t *buffer, uint32_t size);
+
+/**
+ * Free an esg_access_descriptor.
+ *
+ * @param esg Pointer to an esg_access_descriptor structure.
+ */
+extern void esg_access_descriptor_free(struct esg_access_descriptor *access_descriptor);
+
+/**
+ * Convenience iterator for esg_entry_list field of an esg_access_descriptor.
+ *
+ * @param access_descriptor The esg_access_descriptor pointer.
+ * @param entry Variable holding a pointer to the current esg_entry.
+ */
+#define esg_access_descriptor_entry_list_for_each(access_descriptor, entry) \
+ for ((entry) = (access_descriptor)->entry_list; \
+ (entry); \
+ (entry) = (entry)->_next)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lib/libesg/bootstrap/provider_discovery_descriptor.c b/lib/libesg/bootstrap/provider_discovery_descriptor.c
new file mode 100644
index 0000000..833a038
--- /dev/null
+++ b/lib/libesg/bootstrap/provider_discovery_descriptor.c
@@ -0,0 +1,50 @@
+/*
+ * ESG parser
+ *
+ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <libesg/bootstrap/provider_discovery_descriptor.h>
+
+struct esg_provider_discovery_descriptor *esg_esg_provider_discovery_descriptor_decode(uint8_t *buffer, uint32_t size) {
+ struct esg_provider_discovery_descriptor *provider;
+
+ provider = (struct esg_provider_discovery_descriptor *) malloc(sizeof(struct esg_provider_discovery_descriptor));
+ memset(provider, 0, sizeof(struct esg_provider_discovery_descriptor));
+
+ provider->xml = (uint8_t *) malloc(size);
+ memcpy(provider->xml, buffer, size);
+
+ provider->size = size;
+
+ return provider;
+}
+
+void esg_provider_discovery_descriptor_free(struct esg_provider_discovery_descriptor *provider) {
+ if (provider == NULL) {
+ return;
+ }
+
+ if (provider->xml) {
+ free(provider->xml);
+ }
+
+ free(provider);
+}
diff --git a/lib/libesg/bootstrap/provider_discovery_descriptor.h b/lib/libesg/bootstrap/provider_discovery_descriptor.h
new file mode 100644
index 0000000..36065ec
--- /dev/null
+++ b/lib/libesg/bootstrap/provider_discovery_descriptor.h
@@ -0,0 +1,59 @@
+/*
+ * ESG parser
+ *
+ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef _ESG_BOOTSTRAP_PROVIDER_DISCOVERY_DESCRIPTOR_H
+#define _ESG_BOOTSTRAP_PROVIDER_DISCOVERY_DESCRIPTOR_H 1
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <stdint.h>
+
+/**
+ * esg_provider_discovery_descriptor structure.
+ */
+struct esg_provider_discovery_descriptor {
+ uint8_t *xml;
+ uint32_t size;
+};
+
+/**
+ * Process an esg_provider_discovery_descriptor.
+ *
+ * @param buffer Binary buffer to decode.
+ * @param size Binary buffer size.
+ * @return Pointer to an esg_provider_discovery_descriptor structure, or NULL on error.
+ */
+extern struct esg_provider_discovery_descriptor *esg_esg_provider_discovery_descriptor_decode(uint8_t *buffer, uint32_t size);
+
+/**
+ * Free an esg_provider_discovery_descriptor.
+ *
+ * @param esg Pointer to an esg_provider_discovery_descriptor structure.
+ */
+extern void esg_provider_discovery_descriptor_free(struct esg_provider_discovery_descriptor *provider);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif