~ubuntu-branches/ubuntu/precise/me-tv/precise-proposed

« back to all changes in this revision

Viewing changes to src/libucsi/dvb/target_ip_source_slash_descriptor.h

  • Committer: Bazaar Package Importer
  • Author(s): Philipp Kern
  • Date: 2008-07-23 14:03:56 UTC
  • mfrom: (1.1.3 upstream) (3.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080723140356-m6ze7fbkydes42c7
Tags: 0.5.33-3
Fix xine-lib ffmpeg dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * section and descriptor parser
3
 
 *
4
 
 * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org)
5
 
 * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net)
6
 
 * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr)
7
 
 *
8
 
 * This library is free software; you can redistribute it and/or
9
 
 * modify it under the terms of the GNU Lesser General Public
10
 
 * License as published by the Free Software Foundation; either
11
 
 * version 2.1 of the License, or (at your option) any later version.
12
 
 *
13
 
 * This library is distributed in the hope that it will be useful,
14
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 
 * Lesser General Public License for more details.
17
 
 *
18
 
 * You should have received a copy of the GNU Lesser General Public
19
 
 * License along with this library; if not, write to the Free Software
20
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
21
 
 */
22
 
 
23
 
#ifndef _UCSI_DVB_TARGET_IP_SOURCE_SLASH_DESCRIPTOR
24
 
#define _UCSI_DVB_TARGET_IP_SOURCE_SLASH_DESCRIPTOR 1
25
 
 
26
 
#ifdef __cplusplus
27
 
extern "C"
28
 
{
29
 
#endif
30
 
 
31
 
#include <libucsi/descriptor.h>
32
 
#include <libucsi/types.h>
33
 
 
34
 
/**
35
 
 * dvb_target_ip_source_slash_descriptor structure.
36
 
 */
37
 
struct dvb_target_ip_source_slash_descriptor {
38
 
        struct descriptor d;
39
 
 
40
 
        /* struct dvb_ipv4_source_slash ipv4_source_slash[] */
41
 
} __ucsi_packed;
42
 
 
43
 
/**
44
 
 * An entry in the ipv4_source_slash field of a dvb_target_ip_source_slash_descriptor.
45
 
 */
46
 
struct dvb_ipv4_source_slash {
47
 
        uint8_t ipv4_source_addr[4];
48
 
        uint8_t ipv4_source_slash;
49
 
        uint8_t ipv4_dest_addr[4];
50
 
        uint8_t ipv4_dest_slash;
51
 
} __ucsi_packed;
52
 
 
53
 
/**
54
 
 * Process a dvb_target_ip_source_slash_descriptor.
55
 
 *
56
 
 * @param d Generic descriptor structure pointer.
57
 
 * @return dvb_target_ip_source_slash_descriptor pointer, or NULL on error.
58
 
 */
59
 
static inline struct dvb_target_ip_source_slash_descriptor*
60
 
        dvb_target_ip_source_slash_descriptor_codec(struct descriptor* d)
61
 
{
62
 
        uint32_t len = d->len;
63
 
 
64
 
        if (len % sizeof(struct dvb_ipv4_source_slash))
65
 
                return NULL;
66
 
 
67
 
        return (struct dvb_target_ip_source_slash_descriptor*) d;
68
 
}
69
 
 
70
 
/**
71
 
 * Iterator for entries in the ipv4_source_slash field of a dvb_target_ip_source_slash_descriptor.
72
 
 *
73
 
 * @param d dvb_target_ip_source_slash_descriptor pointer.
74
 
 * @param pos Variable containing a pointer to the current dvb_ipv4_source_slash.
75
 
 */
76
 
#define dvb_target_ip_source_slash_descriptor_ipv4_source_slash_for_each(d, pos) \
77
 
        for ((pos) = dvb_target_ip_source_slash_descriptor_ipv4_source_slash_first(d); \
78
 
             (pos); \
79
 
             (pos) = dvb_target_ip_source_slash_descriptor_ipv4_source_slash_next(d, pos))
80
 
 
81
 
 
82
 
 
83
 
 
84
 
 
85
 
 
86
 
 
87
 
 
88
 
 
89
 
 
90
 
/******************************** PRIVATE CODE ********************************/
91
 
static inline struct dvb_ipv4_source_slash*
92
 
        dvb_target_ip_source_slash_descriptor_ipv4_source_slash_first(struct dvb_target_ip_source_slash_descriptor *d)
93
 
{
94
 
        if (d->d.len == 0)
95
 
                return NULL;
96
 
 
97
 
        return (struct dvb_ipv4_source_slash *)
98
 
                ((uint8_t*) d + sizeof(struct dvb_target_ip_source_slash_descriptor));
99
 
}
100
 
 
101
 
static inline struct dvb_ipv4_source_slash*
102
 
        dvb_target_ip_source_slash_descriptor_ipv4_source_slash_next(struct dvb_target_ip_source_slash_descriptor *d,
103
 
                                                    struct dvb_ipv4_source_slash *pos)
104
 
{
105
 
        uint8_t *end = (uint8_t*) d + 2 + d->d.len;
106
 
        uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_ipv4_source_slash);
107
 
 
108
 
        if (next >= end)
109
 
                return NULL;
110
 
 
111
 
        return (struct dvb_ipv4_source_slash *) next;
112
 
}
113
 
 
114
 
#ifdef __cplusplus
115
 
}
116
 
#endif
117
 
 
118
 
#endif