Communication Protocol Parser Utilities Library Functions
sdpparse(3COMPUTIL)
NAME
sdpparse - parse the SDP description
SYNOPSIS
cc [ flag...] file... -lcommputil [ library...]
#include
int sdpparse(const char *sdpinfo, int len, int flags,
sdpsessiont **session, uintt *perror);
DESCRIPTION
The sdpparse() function parses the SDP description present
in sdpinfo and populates the sdpsessiont structure. The
len argument specifies the length of the character buffer
sdpinfo. The flags argument is not used, but must be set to
0, otherwise the call fails with the error value of EINVAL
and *session set to NUL. The function allocates the memory
required for the sdpsessiont structure and hence the
caller is responsible for freeing the parsed session struc-
ture (sdpsessiont) using sdpfreesession(), described on
the sdpnewsession(3COMPUTIL) manual page.
The perror argument identifies any field that had a parsing
error. It cannot be NUL and can take any of the following
values:
SDPVERSIONEROR 0x00000001
SDPORIGINEROR 0x00000002
SDPNAMEROR 0x00000004
SDPINFOEROR 0x00000008
SDPURIEROR 0x00000010
SDPEMAILEROR 0x00000020
SDPHONEROR 0x00000040
SDPCONECTIONEROR 0x00000080
SDPBANDWIDTHEROR 0x00000100
SDPTIMEROR 0x00000200
SDPREPEATIMEROR 0x00000400
SDPZONEROR 0x00000800
SDPKEYEROR 0x00001000
SDPATRIBUTEROR 0x00002000
SDPMEDIAEROR 0x00004000
SDPFIELDSORDEREROR 0x00008000
SDPMISINGFIELDS 0x00010000
SunOS 5.11 Last change: 12 Oct 2007 1
Communication Protocol Parser Utilities Library Functions
sdpparse(3COMPUTIL)
RFC 4566 states that the fields in the SDP description need
to be in a strict order. If the fields are not in the order
specified in the RFC, SDPFIELDSORDEREROR will be set.
RFC 4566 mandates certain fields to be present in SDP
description. If those fields are missing then
SDPMISINGFIELDS will be set.
Applications can check for presence of parsing error using
the bit-wise operators.
If there was an error on a particular field, that field
information will not be in the sdpsessiont structure.
Also, parsing continues even if there was a field with a
parsing error.
The sdpsessiont structure is defined in the header file
and contains the following members:
typedef struct sdpsession {
int sdpsessionversion; /* SDP session verstion */
int sversion; /* SDP version field */
sdporigint *sorigin; /* SDP origin field */
char *sname; /* SDP name field */
char *sinfo; /* SDP info field */
char *suri; /* SDP uri field */
sdplistt *semail; /* SDP email field */
sdplistt *sphone; /* SDP phone field */
sdpconnt *sconn; /* SDP connection field */
sdpbandwidtht *sbw; /* SDP bandwidth field */
sdptimet *stime; /* SDP time field */
sdpzonet *szone; /* SDP zone field */
sdpkeyt *skey; /* SDP key field */
sdpattrt *sattr; /* SDP attribute field */
sdpmediat *smedia; /* SDP media field */
} sdpsessiont;
The sdpsessionversion member is used to track the version
of the structure. Initially it is set to
SDPSESIONVERSION1 (= 1).
The sdporigint structure contains the following members:
typedef struct sdporigin {
SunOS 5.11 Last change: 12 Oct 2007 2
Communication Protocol Parser Utilities Library Functions
sdpparse(3COMPUTIL)
char *ousername; /* username of the originating host */
uint64t oid; /* session id */
uint64t oversion; /* version number of this session */
/* description */
char *onettype; /* type of network */
char *oaddrtype; /* type of the address */
char *oaddress; /* address of the machine from which */
/* session was created */
} sdporigint;
The sdpconnt structure contains the following members:
typedef struct sdpconn {
char *cnettype; /* type of network */
char *caddrtype; /* type of the address */
char *caddress; /* unicast-address or multicast */
/* address */
int caddrcount; /* number of addresses (case of */
/* multicast address with layered */
/* encodings */
struct sdpconn *cnext; /* pointer to next connection */
/* structure; there could be several */
/* connection fields in SDP description */
uint8t cttl; /* TL value for IPV4 multicast address */
} sdpconnt;
The sdpbandwidtht structure contains the following
members:
typedef struct sdpbandwidth {
char *btype; /* info needed to interpret bvalue */
uint64t bvalue; /* bandwidth value */
struct sdpbandwidth *bnext; /* pointer to next bandwidth structure*/
/* (there could be several bandwidth */
/* fields in SDP description */
} sdpbandwidtht;
The sdplistt structure is a linked list of void pointers.
This structure holds SDP fields like email and phone, in
which case the void pointers point to character buffers. It
to hold information in cases where the number of elements is
not predefined (for example, offset (in repeat field) where
void pointer holds integer values or format (in media field)
where void pointers point to character buffers). The
sdplistt structure is defined as:
SunOS 5.11 Last change: 12 Oct 2007 3
Communication Protocol Parser Utilities Library Functions
sdpparse(3COMPUTIL)
typedef struct sdplist {
void *value; /* string values in case of email, phone and */
/* format (in media field) or integer values */
/* in case of offset (in repeat field) */
struct sdplist *next; /* pointer to the next node in the list */
} sdplistt;
The sdprepeatt structure contains the following members:
typedef struct sdprepeat {
uint64t rinterval; /* repeat interval, e.g. 86400 seconds */
/* (1 day) */
uint64t rduration; /* duration of session, e.g. 3600 */
/* seconds (1 hour) */
sdplistt *roffset; /* linked list of offset values; each */
/* represents offset from start-time */
/* in SDP time field */
struct sdprepeat *rnext; /* pointer to next repeat structure; */
/* there could be several repeat */
/* fields in SDP description */
The sdprepeatt structure will always be part of the time
structure sdptimet, since the repeat field does not appear
alone in SDP description and is always associated with the
time field.
The sdptimet structure contains the following members:
typedef struct sdptime {
uint64t tstart; /* start-time for a session */
uint64t tstop; /* end-time for a session */
sdprepeatt *trepeat; /* points to the SDP repeat field */
struct sdptime *tnext; /* pointer to next time field; there */
/* could there could be several time */
/* fields in SDP description */
} sdptimet;
The sdpzonet structure contains the following members:
typedef struct sdpzone {
uint64t ztime; /* base time */
char *zoffset; /* offset added to ztime to determine */
/* session time; mainly used for daylight */
/* saving time conversions */
SunOS 5.11 Last change: 12 Oct 2007 4
Communication Protocol Parser Utilities Library Functions
sdpparse(3COMPUTIL)
struct sdpzone *znext; /* pointer to next zone field; there */
/* could be several */
/* pairs within a zone field */
} sdpzonet;
The sdpkeyt structure contains the following members:
typedef struct sdpkey {
char *kmethod; /* key type */
char *kenckey; /* encryption key */
} sdpkeyt;
The sdpattrt structure contains the following members:
typedef struct sdpattr {
char *aname; /* name of the attribute */
char *avalue; /* value of the attribute */
struct sdpattr *anext; /* pointer to the next attribute */
/* structure; there could be several */
/* attribute fields within SDP description */
} sdpattrt;
The sdpmediat structure contains the following members:
typedef struct sdpmedia {
char *mname; /* name of the media such as "audio", */
/* "video", "message" */
uintt mport; /* transport layer port information */
int mportcount; /* number of ports in case of */
/* hierarchically encoded streams */
char *mproto; /* transport protocol */
sdplistt *mformat; /* media format description */
char *minfo; /* media info field */
sdpconnt *mconn; /* media connection field */
sdpbandwidtht *mbw; /* media bandwidth field */
sdpkeyt *mkey; /* media key field */
sdpattrt *mattr; /* media attribute field */
struct sdpmedia *mnext; /* pointer to next media structure; */
/* there could be several media */
/* sections in SDP description */
sdpsessiont *msession; /* pointer to the session structure */
} sdpmediat;
SunOS 5.11 Last change: 12 Oct 2007 5
Communication Protocol Parser Utilities Library Functions
sdpparse(3COMPUTIL)
RETURN VALUES
The sdpparse() function returns 0 on success and the
appropriate error value on failure. The value of errno is
not changed by these calls in the event of an error.
ERORS
The sdpparse() function will fail if:
EINVAL Arguments to the function were invalid.
ENOMEM Memory allocation failed while parsing sdpinfo.
EXAMPLES
Example 1 sdpparse() example
If the SDP description was
v=0\r\n
o=jdoe 23423423 234234234 IN IP4 192.168.1.1\r\n
s=SDP seminar\r\n
i=A seminar on the session description protocol\r\n
e=test@host.com
c=IN IP4 156.78.90.1\r\n
t=2873397496 2873404696\r\n
then after call to sdpparse() function the sdpsessiont
structure would be
session {
sdpsessionversion = 1
sversion = 0
sorigin {
ousername = "jdoe"
oid = 23423423UL
oversion = 234234234UL
onettype = "IN"
oaddrtype = "IP4"
oaddress = "192.168.1.1"
}
sname = "SDP seminar"
sinfo = "A seminar on the session description protocol"
suri = (nil)
semail {
value = "test@host.com"
SunOS 5.11 Last change: 12 Oct 2007 6
Communication Protocol Parser Utilities Library Functions
sdpparse(3COMPUTIL)
next = (nil)
}
sphone = (nil)
sconn {
cnettype = "IN"
caddrtype = "IP4"
caddress = "156.78.90.1"
caddrcount = 0
cttl = 0
cnext = (nil)
}
sbw = (nil)
stime {
tstart = 2873397496UL
tstop = 2873404696UL
trepeat = (nil)
tnext = (nil)
}
szone = (nil)
skey = (nil)
sattr = (nil)
smedia = (nil)
}
ATRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
ATRIBUTE TYPE ATRIBUTE VALUE
Interface Stability Committed
MT-Level Safe
SEE ALSO
libcommputil(3LIB), sdpnewsession(3COMPUTIL), attri-
butes(5)
SunOS 5.11 Last change: 12 Oct 2007 7
Communication Protocol Parser Utilities Library Functions
sdpparse(3COMPUTIL)
SunOS 5.11 Last change: 12 Oct 2007 8
|