Hello, I'm using SDP parser in openser (parser/sdp/sdp.*) for MSRP chat server. Thus I need the parser to support additional stream attributes as defined in RFC4975 (accept-types, accept-wrapped-types, path and max-size).
The patch attached extends sdp_stream_cell with the four attrs mentioned. I wonder a) if this is the right way to extend SDP parser in openser b) what needs to be done for this patch to be accepted thanks, Denis. Index: parser/sdp/sdp_helpr_funcs.c =================================================================== --- parser/sdp/sdp_helpr_funcs.c (revision 4057) +++ parser/sdp/sdp_helpr_funcs.c (working copy) @@ -35,10 +35,12 @@ static str sup_ptypes[] = { - { "udp", 3}, - { "udptl", 5}, - { "rtp/avp", 7}, - { "rtp/savpf", 9}, + str_init("udp"), + str_init("udptl"), + str_init("rtp/avp"), + str_init("rtp/savpf"), + str_init("TCP/MSRP"), + str_init("TCP/TLS/MSRP"), { NULL, 0} }; @@ -216,22 +218,54 @@ return 0; } - -int extract_ptime(str *body, str *ptime) +/* field must has format "a=attrname:" */ +int extract_field(str *body, str *value, str field) { - if (strncmp(body->s, "a=ptime:", 8) !=0) { - /*LM_DBG("We are not pointing to an a=rtpmap: attribute =>`%.*s'\n", body->len, body->s); */ + if (strncmp(body->s, field.s, field.len < body->len ? field.len : body->len) !=0) { + /*LM_DBG("We are not pointing to an %.* attribute =>`%.*s'\n", field.len, field.s, body->len, body->s); */ return -1; } - ptime->s = body->s + 8; /* skip `a=ptime:' */ - ptime->len = eat_line(ptime->s, body->s + body->len - - ptime->s) - ptime->s; - trim_len(ptime->len, ptime->s, *ptime); + value->s = body->s + field.len; /* skip `a=attrname:' */ + value->len = eat_line(value->s, body->s + body->len - + value->s) - value->s; + trim_len(value->len, value->s, *value); return 0; } +int extract_ptime(str *body, str *ptime) +{ + static const str field = str_init("a=ptime:"); + return extract_field(body, ptime, field); +} + +int extract_accept_types(str *body, str *accept_types) +{ + static const str field = str_init("a=accept-types:"); + return extract_field(body, accept_types, field); +} + +int extract_accept_wrapped_types(str *body, str *accept_wrapped_types) +{ + static const str field = str_init("a=accept-wrapped-types:"); + return extract_field(body, accept_wrapped_types, field); +} + +int extract_max_size(str *body, str *max_size) +{ + static const str field = str_init("a=max-size:"); + return extract_field(body, max_size, field); +} + +int extract_path(str *body, str *path) +{ + static const str field = str_init("a=path:"); + return extract_field(body, path, field); +} + +// also fix debug print functions + int extract_sendrecv_mode(str *body, str *sendrecv_mode) { char *cp1; Index: parser/sdp/sdp_helpr_funcs.h =================================================================== --- parser/sdp/sdp_helpr_funcs.h (revision 4057) +++ parser/sdp/sdp_helpr_funcs.h (working copy) @@ -49,6 +49,11 @@ int extract_mediaip(str *body, str *mediaip, int *pf, char *line); int extract_media_attr(str *body, str *mediamedia, str *mediaport, str *mediatransport, str *mediapayload); +int extract_accept_types(str *body, str *accept_types); +int extract_accept_wrapped_types(str *body, str *accept_wrapped_types); +int extract_max_size(str *body, str *max_size); +int extract_path(str *body, str *path); + char *find_sdp_line(char *p, char *plimit, char linechar); char *find_next_sdp_line(char *p, char *plimit, char linechar, char *defptr); Index: parser/sdp/sdp.c =================================================================== --- parser/sdp/sdp.c (revision 4057) +++ parser/sdp/sdp.c (working copy) @@ -534,6 +534,14 @@ } payload_attr = (sdp_payload_attr_t*)get_sdp_payload4payload(stream, &rtp_payload); set_sdp_payload_attr(payload_attr, &rtp_enc, &rtp_clock, &rtp_params); + } else if (extract_accept_types(&tmpstr1, &stream->accept_types) == 0) { + a1p = stream->accept_types.s + stream->accept_types.len; + } else if (extract_accept_wrapped_types(&tmpstr1, &stream->accept_wrapped_types) == 0) { + a1p = stream->accept_wrapped_types.s + stream->accept_wrapped_types.len; + } else if (extract_max_size(&tmpstr1, &stream->max_size) == 0) { + a1p = stream->max_size.s + stream->max_size.len; + } else if (extract_path(&tmpstr1, &stream->path) == 0) { + a1p = stream->path.s + stream->path.len; /*} else { */ /* LM_DBG("else: `%.*s'\n", tmpstr1.len, tmpstr1.s); */ } Index: parser/sdp/sdp.h =================================================================== --- parser/sdp/sdp.h (revision 4057) +++ parser/sdp/sdp.h (working copy) @@ -59,6 +59,12 @@ int payloads_num; /**< number of payloads inside a stream */ struct sdp_payload_attr **p_payload_attr; /**< fast access pointers to payloads */ struct sdp_payload_attr *payload_attr; + + /* these attributes are defined in RFC4975 */ + str path; + str max_size; + str accept_types; + str accept_wrapped_types; } sdp_stream_cell_t; typedef struct sdp_session_cell { _______________________________________________ Devel mailing list Devel@lists.openser.org http://lists.openser.org/cgi-bin/mailman/listinfo/devel