1sdp_parse(3CCOoMmMmPuUnTiIcLa)tion Protocol Parser Utilities LibrarysdFpu_npcatrisoen(s3COMMPUTIL)
2
3
4

NAME

6       sdp_parse - parse the SDP description
7

SYNOPSIS

9       cc [ flag...] file... -lcommputil [ library...]
10       #include <sdp.h>
11
12       int sdp_parse(const char *sdp_info, int len, int flags,
13            sdp_session_t **session, uint_t *p_error);
14
15

DESCRIPTION

17       The sdp_parse() function parses the SDP description present in sdp_info
18       and populates the sdp_session_t structure. The len  argument  specifies
19       the  length of the character buffer sdp_info. The flags argument is not
20       used, but must be set to 0, otherwise the call  fails  with  the  error
21       value  of  EINVAL  and *session set to NULL. The function allocates the
22       memory required for the sdp_session_t structure and hence the caller is
23       responsible  for  freeing  the parsed session structure (sdp_session_t)
24       using sdp_free_session(), described on the  sdp_new_session(3COMMPUTIL)
25       manual page.
26
27
28       The  p_error argument identifies any field that had a parsing error. It
29       cannot be NULL and can take any of the following values:
30
31
32
33
34       SDP_VERSION_ERROR             0x00000001
35       SDP_ORIGIN_ERROR              0x00000002
36       SDP_NAME_ERROR                0x00000004
37       SDP_INFO_ERROR                0x00000008
38       SDP_URI_ERROR                 0x00000010
39       SDP_EMAIL_ERROR               0x00000020
40       SDP_PHONE_ERROR               0x00000040
41       SDP_CONNECTION_ERROR          0x00000080
42       SDP_BANDWIDTH_ERROR           0x00000100
43       SDP_TIME_ERROR                0x00000200
44       SDP_REPEAT_TIME_ERROR         0x00000400
45       SDP_ZONE_ERROR                0x00000800
46       SDP_KEY_ERROR                 0x00001000
47       SDP_ATTRIBUTE_ERROR           0x00002000
48       SDP_MEDIA_ERROR               0x00004000
49       SDP_FIELDS_ORDER_ERROR        0x00008000
50       SDP_MISSING_FIELDS            0x00010000
51
52
53
54       RFC 4566 states that the fields in the SDP description need to be in  a
55       strict  order. If the fields are not in the order specified in the RFC,
56       SDP_FIELDS_ORDER_ERROR will be set.
57
58
59       RFC 4566 mandates certain fields to be present in SDP  description.  If
60       those fields are missing then SDP_MISSING_FIELDS will be set.
61
62
63       Applications can check for presence of parsing error using the bit-wise
64       operators.
65
66
67       If there was an error on a particular  field,  that  field  information
68       will  not  be  in  the sdp_session_t structure. Also, parsing continues
69       even if there was a field with a parsing error.
70
71
72       The sdp_session_t structure is defined in the header file  <sdp.h>  and
73       contains the following members:
74
75         typedef    struct sdp_session {
76             int              sdp_session_version;  /* SDP session verstion */
77             int              s_version;            /* SDP version field */
78             sdp_origin_t     *s_origin;            /* SDP origin field */
79             char             *s_name;              /* SDP name field */
80             char             *s_info;              /* SDP info field */
81             char             *s_uri;               /* SDP uri field */
82             sdp_list_t       *s_email;             /* SDP email field */
83             sdp_list_t       *s_phone;             /* SDP phone field */
84             sdp_conn_t       *s_conn;              /* SDP connection field */
85             sdp_bandwidth_t  *s_bw;                /* SDP bandwidth field */
86             sdp_time_t       *s_time;              /* SDP time field */
87             sdp_zone_t       *s_zone;              /* SDP zone field */
88             sdp_key_t        *s_key;               /* SDP key field */
89             sdp_attr_t       *s_attr;              /* SDP attribute field */
90             sdp_media_t      *s_media;             /* SDP media field */
91         } sdp_session_t;
92
93
94
95       The  sdp_session_version  member  is  used  to track the version of the
96       structure. Initially it is set to SDP_SESSION_VERSION_1 (= 1).
97
98
99       The sdp_origin_t structure contains the following members:
100
101         typedef struct sdp_origin {
102             char        *o_username;  /* username of the originating host */
103             uint64_t    o_id;         /* session id */
104             uint64_t    o_version;    /* version number of this session */
105                                       /* description */
106             char        *o_nettype;   /* type of network */
107             char        *o_addrtype;  /* type of the address */
108             char        *o_address;   /* address of the machine from which */
109                                       /* session was created */
110         } sdp_origin_t;
111
112
113
114       The sdp_conn_t structure contains the following members:
115
116         typedef struct sdp_conn {
117             char            *c_nettype;  /* type of network */
118             char            *c_addrtype; /* type of the address */
119             char            *c_address;  /* unicast-address or multicast */
120                                          /* address */
121             int             c_addrcount; /* number of addresses (case of */
122                                          /* multicast address with layered */
123                                          /* encodings */
124             struct sdp_conn *c_next;     /* pointer to next connection */
125                                          /* structure; there could be several */
126                                          /* connection fields in SDP description */
127             uint8_t         c_ttl;       /* TTL value for IPV4 multicast address */
128         } sdp_conn_t;
129
130
131
132       The sdp_bandwidth_t structure contains the following members:
133
134         typedef struct sdp_bandwidth {
135             char                  *b_type; /* info needed to interpret b_value */
136             uint64_t              b_value; /* bandwidth value */
137             struct sdp_bandwidth  *b_next; /* pointer to next bandwidth structure*/
138                                            /* (there could be several bandwidth */
139                                            /* fields in SDP description */
140         } sdp_bandwidth_t;
141
142
143
144       The sdp_list_t structure is a linked list of void pointers. This struc‐
145       ture  holds  SDP  fields  like  email and phone, in which case the void
146       pointers point to character buffers.  It to hold information  in  cases
147       where the number of elements is not predefined (for example, offset (in
148       repeat field) where void pointer holds integer  values  or  format  (in
149       media  field)  where  void  pointers  point  to character buffers). The
150       sdp_list_t structure is defined as:
151
152         typedef struct sdp_list {
153             void            *value; /* string values in case of email, phone and */
154                                     /* format (in media field) or integer values */
155                                     /* in case of offset (in repeat field) */
156             struct sdp_list *next;  /* pointer to the next node in the list */
157         } sdp_list_t;
158
159
160
161       The sdp_repeat_t structure contains the following members:
162
163         typedef struct sdp_repeat {
164             uint64_t          r_interval; /* repeat interval, e.g. 86400 seconds */
165                                           /* (1 day) */
166             uint64_t          r_duration; /* duration of session, e.g. 3600 */
167                                           /* seconds (1 hour) */
168             sdp_list_t        *r_offset;  /* linked list of offset values; each */
169                                           /* represents offset from start-time */
170                                           /* in SDP time field */
171             struct sdp_repeat *r_next;    /* pointer to next repeat structure; */
172                                           /* there could be several repeat */
173                                           /* fields in SDP description */
174
175
176
177       The sdp_repeat_t structure will always be part of  the  time  structure
178       sdp_time_t,  since  the  repeat  field  does  not  appear  alone in SDP
179       description and is always associated with the time field.
180
181
182       The sdp_time_t structure contains the following members:
183
184         typedef struct sdp_time {
185             uint64_t         t_start;   /* start-time for a session */
186             uint64_t         t_stop;    /* end-time for a session */
187             sdp_repeat_t     *t_repeat; /* points to the SDP repeat field */
188             struct sdp_time  *t_next;   /* pointer to next time field; there */
189                                         /* could there could be several time */
190                                         /* fields in SDP description */
191         } sdp_time_t;
192
193
194
195       The sdp_zone_t structure contains the following members:
196
197         typedef struct sdp_zone {
198             uint64_t        z_time;    /* base time */
199             char            *z_offset; /* offset added to z_time to determine */
200                                        /* session time; mainly used for daylight */
201                                        /* saving time conversions */
202             struct sdp_zone *z_next;   /* pointer to next zone field; there */
203                                        /* could be several <adjustment-time> */
204                                        /* <offset> pairs within a zone field */
205         } sdp_zone_t;
206
207
208
209       The sdp_key_t structure contains the following members:
210
211         typedef struct sdp_key {
212             char   *k_method;   /* key type */
213             char   *k_enckey;   /* encryption key */
214         } sdp_key_t;
215
216
217
218       The sdp_attr_t structure contains the following members:
219
220         typedef struct sdp_attr {
221             char            *a_name;  /* name of the attribute */
222             char            *a_value; /* value of the attribute */
223             struct sdp_attr *a_next;  /* pointer to the next attribute */
224                                       /* structure; there could be several */
225                                       /* attribute fields within SDP description */
226         } sdp_attr_t;
227
228
229
230       The sdp_media_t structure contains the following members:
231
232         typedef struct sdp_media {
233             char              *m_name;     /* name of the media such as "audio", */
234                                            /* "video", "message" */
235             uint_t            m_port;      /* transport layer port information */
236             int               m_portcount; /* number of ports in case of */
237                                            /* hierarchically encoded streams */
238             char              *m_proto;    /* transport protocol */
239             sdp_list_t        *m_format;   /* media format description */
240             char              *m_info;     /* media info field */
241             sdp_conn_t        *m_conn;     /* media connection field */
242             sdp_bandwidth_t   *m_bw;       /* media bandwidth field */
243             sdp_key_t         *m_key;      /* media key field */
244             sdp_attr_t        *m_attr;     /* media attribute field */
245             struct sdp_media  *m_next;     /* pointer to next media structure; */
246                                            /* there could be several media */
247                                            /* sections in SDP description */
248             sdp_session_t     *m_session;  /* pointer to the session structure */
249         } sdp_media_t;
250
251

RETURN VALUES

253       The sdp_parse() function returns 0 on success and the appropriate error
254       value  on  failure. The value of errno is not changed by these calls in
255       the event of an error.
256

ERRORS

258       The sdp_parse() function will fail if:
259
260       EINVAL    Arguments to the function were invalid.
261
262
263       ENOMEM    Memory allocation failed while parsing sdp_info.
264
265

EXAMPLES

267       Example 1 sdp_parse() example
268
269
270       If the SDP description was
271
272
273         v=0\r\n
274         o=jdoe 23423423 234234234 IN IP4 192.168.1.1\r\n
275         s=SDP seminar\r\n
276         i=A seminar on the session description protocol\r\n
277         e=test@host.com
278         c=IN IP4 156.78.90.1\r\n
279         t=2873397496 2873404696\r\n
280
281
282
283       then after call to sdp_parse()  function  the  sdp_session_t  structure
284       would be
285
286
287         session {
288                 sdp_session_version = 1
289                 s_version = 0
290                 s_origin {
291                         o_username = "jdoe"
292                         o_id = 23423423ULL
293                         o_version = 234234234ULL
294                         o_nettype = "IN"
295                         o_addrtype = "IP4"
296                         o_address = "192.168.1.1"
297                 }
298                 s_name = "SDP seminar"
299                 s_info = "A seminar on the session description protocol"
300                 s_uri =  (nil)
301                 s_email {
302                         value = "test@host.com"
303                         next = (nil)
304                 }
305                 s_phone = (nil)
306                 s_conn {
307                         c_nettype = "IN"
308                         c_addrtype = "IP4"
309                         c_address = "156.78.90.1"
310                         c_addrcount = 0
311                         c_ttl = 0
312                         c_next = (nil)
313                 }
314                 s_bw = (nil)
315                 s_time {
316                         t_start = 2873397496ULL
317                         t_stop = 2873404696ULL
318                         t_repeat = (nil)
319                         t_next = (nil)
320                 }
321                 s_zone = (nil)
322                 s_key = (nil)
323                 s_attr = (nil)
324                 s_media = (nil)
325         }
326
327

ATTRIBUTES

329       See attributes(5) for descriptions of the following attributes:
330
331
332
333
334       ┌─────────────────────────────┬─────────────────────────────┐
335       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
336       ├─────────────────────────────┼─────────────────────────────┤
337       │Interface Stability          │Committed                    │
338       ├─────────────────────────────┼─────────────────────────────┤
339       │MT-Level                     │Safe                         │
340       └─────────────────────────────┴─────────────────────────────┘
341

SEE ALSO

343       libcommputil(3LIB), sdp_new_session(3COMMPUTIL), attributes(5)
344
345
346
347SunOS 5.11                        12 Oct 2007            sdp_parse(3COMMPUTIL)
Impressum