From 13ad0428e648a56b4f68c42d11f63f90d4256022 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Fri, 12 Jul 2013 11:08:52 -0400 Subject: [PATCH] rename some keys in the ng protocol (replace dash with space) but retain compatibility --- README.md | 16 ++++++++-------- daemon/call.c | 14 +++++++++++--- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 6ad6edc1c..569d0f0a0 100644 --- a/README.md +++ b/README.md @@ -516,10 +516,10 @@ Optionally included keys are: The value of the `flags` key is a list. The list contains zero or more of the following strings: - - `trust-address` + - `trust address` If given, the media addresses from the SDP body are trusted as correct endpoints. Otherwise, the - address is taken from the `received-from` key. Corresponds to the *rtpproxy* `r` flag. + address is taken from the `received from` key. Corresponds to the *rtpproxy* `r` flag. - `symmetric` @@ -539,7 +539,7 @@ Optionally included keys are: Replace the address found in the *origin* (o=) line of the SDP body. Corresponds to *rtpproxy* `o` flag. - - `session-connection` + - `session connection` Replace the address found in the *session-level connection* (c=) line of the SDP body. Corresponds to *rtpproxy* `c` flag. @@ -556,11 +556,11 @@ Optionally included keys are: *Mediaproxy-ng* uses the direction to implement bridging between IPv4 and IPv6: internal is seen as IPv4 and external as IPv6. -* `received-from` +* `received from` Contains a list of exactly two elements. The first element denotes the address family and the second element is the SIP message's source address itself. The address family can be one of `IP4` or `IP6`. - Used if the `trust-address` flag isn't present. + Used if the `trust address` flag isn't present. * `ICE` @@ -573,7 +573,7 @@ Optionally included keys are: This flag operates independently of the `replace` flags. -* `transport-protocol` +* `transport protocol` The transport protocol specified in the SDP body is to be rewritten to the string value given here. The media @@ -586,9 +586,9 @@ An example of a complete `offer` request dictionary could be (SDP body abbreviat { "command": "offer", "call-id": "cfBXzDSZqhYNcXM", "from-tag": "mS9rSAn0Cr", "sdp": "v=0\r\no=...", "via-branch": "5KiTRPZHH1nL6", - "flags": [ "trust-address" ], "replace": [ "origin", "session-connection" ], + "flags": [ "trust address" ], "replace": [ "origin", "session connection" ], "direction": [ "external", "external" ], "received-from": [ "IP4", "10.65.31.43" ], - "ICE": "force", "transport-protocol": "RTP/SAVPF" } + "ICE": "force", "transport protocol": "RTP/SAVPF" } The response message only contains the key `sdp` in addition to `result`, which contains the re-written SDP body that the SIP proxy should insert into the SIP message. diff --git a/daemon/call.c b/daemon/call.c index bd0913616..ccac45816 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -2564,12 +2564,14 @@ static void call_ng_process_flags(struct sdp_ng_flags *out, bencode_item_t *inpu if ((list = bencode_dictionary_get_expect(input, "flags", BENCODE_LIST))) { for (it = list->child; it; it = it->sibling) { - if (!bencode_strcmp(it, "trust-address")) + if (!bencode_strcmp(it, "trust address")) out->trust_address = 1; else if (!bencode_strcmp(it, "symmetric")) out->symmetric = 1; else if (!bencode_strcmp(it, "asymmetric")) out->asymmetric = 1; + else if (!bencode_strcmp(it, "trust-address")) + out->trust_address = 1; } } @@ -2577,6 +2579,8 @@ static void call_ng_process_flags(struct sdp_ng_flags *out, bencode_item_t *inpu for (it = list->child; it; it = it->sibling) { if (!bencode_strcmp(it, "origin")) out->replace_origin = 1; + else if (!bencode_strcmp(it, "session connection")) + out->replace_sess_conn = 1; else if (!bencode_strcmp(it, "session-connection")) out->replace_sess_conn = 1; } @@ -2593,7 +2597,9 @@ static void call_ng_process_flags(struct sdp_ng_flags *out, bencode_item_t *inpu } } - list = bencode_dictionary_get_expect(input, "received-from", BENCODE_LIST); + list = bencode_dictionary_get_expect(input, "received from", BENCODE_LIST); + if (!list) + list = bencode_dictionary_get_expect(input, "received-from", BENCODE_LIST); if (list && (it = list->child)) { bencode_get_str(it, &out->received_from_family); bencode_get_str(it->sibling, &out->received_from_address); @@ -2606,7 +2612,9 @@ static void call_ng_process_flags(struct sdp_ng_flags *out, bencode_item_t *inpu out->ice_force = 1; } - bencode_dictionary_get_str(input, "transport-protocol", &out->transport_protocol_str); + bencode_dictionary_get_str(input, "transport protocol", &out->transport_protocol_str); + if (!out->transport_protocol_str.s) + bencode_dictionary_get_str(input, "transport-protocol", &out->transport_protocol_str); out->transport_protocol = transport_protocol(&out->transport_protocol_str); }