implement and document ng "media address"

git.mgm/mediaproxy-ng/github/master
Richard Fuchs 13 years ago
parent 13ad0428e6
commit bbc53398f8

@ -520,6 +520,7 @@ Optionally included keys are:
If given, the media addresses from the SDP body are trusted as correct endpoints. Otherwise, the 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.
Can be overridden through the `media address` key.
- `symmetric` - `symmetric`
@ -560,7 +561,7 @@ Optionally included keys are:
Contains a list of exactly two elements. The first element denotes the address family and the second 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`. 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 neither the `trust address` flag nor the `media address` key is present.
* `ICE` * `ICE`
@ -582,13 +583,20 @@ Optionally included keys are:
Valid values are: `RTP/AVP`, `RTP/AVPF`, `RTP/SAVP`, `RTP/SAVPF`. Valid values are: `RTP/AVP`, `RTP/AVPF`, `RTP/SAVP`, `RTP/SAVPF`.
* `media address`
This can be used to override both the addresses present in the SDP body
and the `received from` address. Contains either an IPv4 or an IPv6 address, expressed as a simple
string. The format must be dotted-quad notation for IPv4 or RFC 5952 notation for IPv6.
It's up to the RTP proxy to determine the address family type.
An example of a complete `offer` request dictionary could be (SDP body abbreviated): An example of a complete `offer` request dictionary could be (SDP body abbreviated):
{ "command": "offer", "call-id": "cfBXzDSZqhYNcXM", "from-tag": "mS9rSAn0Cr", { "command": "offer", "call-id": "cfBXzDSZqhYNcXM", "from-tag": "mS9rSAn0Cr",
"sdp": "v=0\r\no=...", "via-branch": "5KiTRPZHH1nL6", "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" ], "direction": [ "external", "external" ], "received-from": [ "IP4", "10.65.31.43" ],
"ICE": "force", "transport protocol": "RTP/SAVPF" } "ICE": "force", "transport protocol": "RTP/SAVPF", "media address": "2001:d8::6f24:65b" }
The response message only contains the key `sdp` in addition to `result`, which contains the re-written 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. SDP body that the SIP proxy should insert into the SIP message.

@ -2616,6 +2616,7 @@ static void call_ng_process_flags(struct sdp_ng_flags *out, bencode_item_t *inpu
if (!out->transport_protocol_str.s) if (!out->transport_protocol_str.s)
bencode_dictionary_get_str(input, "transport-protocol", &out->transport_protocol_str); bencode_dictionary_get_str(input, "transport-protocol", &out->transport_protocol_str);
out->transport_protocol = transport_protocol(&out->transport_protocol_str); out->transport_protocol = transport_protocol(&out->transport_protocol_str);
bencode_dictionary_get_str(input, "media address", &out->media_address);
} }
static unsigned int stream_hash(struct stream_input *s) { static unsigned int stream_hash(struct stream_input *s) {

@ -172,7 +172,7 @@ static inline int inet_pton_str(int af, str *src, void *dst) {
int ret; int ret;
p = s[src->len]; p = s[src->len];
s[src->len] = '\0'; s[src->len] = '\0';
ret = inet_pton(af, src->s, dst); ret = smart_pton(af, src->s, dst);
s[src->len] = p; s[src->len] = p;
return ret; return ret;
} }
@ -187,12 +187,22 @@ static int __parse_address(struct in6_addr *out, str *network_type, str *address
&& memcmp(network_type->s, "in", 2)) && memcmp(network_type->s, "in", 2))
return -1; return -1;
} }
if (!address_type) {
if (inet_pton_str(AF_INET, address, &in4) == 1)
goto ip4;
if (inet_pton_str(AF_INET6, address, out) == 1)
return 0;
return -1;
}
if (address_type->len != 3) if (address_type->len != 3)
return -1; return -1;
if (!memcmp(address_type->s, "IP4", 3) if (!memcmp(address_type->s, "IP4", 3)
|| !memcmp(address_type->s, "ip4", 3)) { || !memcmp(address_type->s, "ip4", 3)) {
if (inet_pton_str(AF_INET, address, &in4) != 1) if (inet_pton_str(AF_INET, address, &in4) != 1)
return -1; return -1;
ip4:
in4_to_6(out, in4.s_addr); in4_to_6(out, in4.s_addr);
} }
else if (!memcmp(address_type->s, "IP6", 3) else if (!memcmp(address_type->s, "IP6", 3)
@ -748,13 +758,21 @@ void sdp_free(GQueue *sessions) {
static int fill_stream_address(struct stream_input *si, struct sdp_media *media, struct sdp_ng_flags *flags) { static int fill_stream_address(struct stream_input *si, struct sdp_media *media, struct sdp_ng_flags *flags) {
struct sdp_session *session = media->session; struct sdp_session *session = media->session;
if (!flags->trust_address) { if (flags->media_address.s) {
if (is_addr_unspecified(&flags->parsed_address)) { if (is_addr_unspecified(&flags->parsed_media_address)) {
if (__parse_address(&flags->parsed_address, NULL, &flags->received_from_family, if (__parse_address(&flags->parsed_media_address, NULL, NULL,
&flags->media_address))
return -1;
}
si->stream.ip46 = flags->parsed_media_address;
}
else if (!flags->trust_address) {
if (is_addr_unspecified(&flags->parsed_received_from)) {
if (__parse_address(&flags->parsed_received_from, NULL, &flags->received_from_family,
&flags->received_from_address)) &flags->received_from_address))
return -1; return -1;
} }
si->stream.ip46 = flags->parsed_address; si->stream.ip46 = flags->parsed_received_from;
} }
else if (media->connection.parsed) else if (media->connection.parsed)
si->stream.ip46 = media->connection.address.parsed; si->stream.ip46 = media->connection.address.parsed;

@ -10,9 +10,11 @@ struct sdp_ng_flags {
int desired_family[2]; int desired_family[2];
str received_from_family; str received_from_family;
str received_from_address; str received_from_address;
str media_address;
str transport_protocol_str; str transport_protocol_str;
enum transport_protocol transport_protocol; enum transport_protocol transport_protocol;
struct in6_addr parsed_address; struct in6_addr parsed_received_from;
struct in6_addr parsed_media_address;
enum stream_direction directions[2]; enum stream_direction directions[2];
int asymmetric:1, int asymmetric:1,
symmetric:1, symmetric:1,

Loading…
Cancel
Save