From: Richard Whitehouse Date: Sun, 29 Oct 2017 14:42:20 +0000 (+0000) Subject: Support Call-Info header X-Git-Url: https://git.richardwhiuk.com/?a=commitdiff_plain;h=e9c80740e986b2b9a71f31c97f21034d46abf2c4;p=rust-sip.git Support Call-Info header --- diff --git a/src/codec.rs b/src/codec.rs index a46ec3c..36eeff7 100644 --- a/src/codec.rs +++ b/src/codec.rs @@ -431,7 +431,8 @@ mod tests { en-gb\r\nAlert-Info:\r\nAllow:\ MESSAGE\r\nAuthentication-Info:qop=auth\r\nAuthorization:Digest \ username=\"Alice\"\r\nCall-ID:f81d4fae-7dec-11d0-a765-00a0c91e6bf6@foo.\ - bar.com\r\nVia: localhost\r\n\r\n") + bar.com\r\nCall-Info:;\ + purpose=icon\r\nVia: localhost\r\n\r\n") }); let finished = request.and_then(|(socket, _request)| { diff --git a/src/parser.rs b/src/parser.rs index e373b53..3e4b202 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -13,7 +13,8 @@ use types::{PathSegment, HostPort, Host, Hostname, UriParameter, UriHeader, UriH Scheme, Method, Transport, UserParam, Version, RequestLine, StatusLine, TopLine, Header, MediaType, MediaFullType, MediaParameter, MediaRange, GenericParam, AcceptParam, AcceptRange, Coding, Encoding, LanguageRange, Language, AlertParam, Qop, - AuthenticationInfo, AuthParam, Algorithm, DigestResponse, Credentials, CallId}; + AuthenticationInfo, AuthParam, Algorithm, DigestResponse, Credentials, CallId, + Purpose, InfoParam, Info}; fn is_mark(c: u8) -> bool { c == b'-' || c == b'_' || c == b'.' || c == b'!' || c == b'~' || c == b'*' || c == b'\'' || @@ -716,6 +717,34 @@ named!(call_id_header, preceded!( tag!(b"@"), word))))); +named!(purpose, alt!( + tag!(b"icon") => { |_| Purpose::Icon } | + tag!(b"info") => { |_| Purpose::Info } | + tag!(b"card") => { |_| Purpose::Card } | + token => { |t| Purpose::Token(t) })); + +named!(info_param, alt!( + preceded!( + tag!(b"purpose="), + purpose) => { |p| InfoParam::Purpose(p) } | + generic_param => { |g| InfoParam::Generic(g) })); + +named!(info, tuple!( + delimited!( + tag!(b"<"), + absolute_uri, + tag!(b">") + ), + many0!(preceded!( + tag!(b";"), + info_param)))); + +named!(call_info_header>, preceded!( + tag!(b"Call-Info:"), + separated_nonempty_list!( + tag!(","), + info))); + named!(pub header
, alt!( // RFC 3261 Headers accept_header => { |a| Header::Accept(a) } | @@ -725,5 +754,6 @@ named!(pub header
, alt!( allow_header => { |a| Header::Allow(a) } | authentication_info_header => { |a| Header::AuthenticationInfo(a) } | authorization_header => { |a| Header::Authorization(a) } | - call_id_header => { |c| Header::CallId(c) } + call_id_header => { |c| Header::CallId(c) } | + call_info_header => { |c| Header::CallInfo(c) } )); diff --git a/src/types.rs b/src/types.rs index e8c6f00..e05f4e4 100644 --- a/src/types.rs +++ b/src/types.rs @@ -233,6 +233,22 @@ pub enum Credentials { pub type CallId = (Vec, Option>); +#[derive(Debug)] +pub enum Purpose { + Icon, + Info, + Card, + Token(Vec), +} + +#[derive(Debug)] +pub enum InfoParam { + Purpose(Purpose), + Generic(GenericParam), +} + +pub type Info = (AbsoluteUri, Vec); + #[derive(Debug)] pub enum Header { Accept(Vec), @@ -243,6 +259,7 @@ pub enum Header { AuthenticationInfo(Vec), Authorization(Credentials), CallId(CallId), + CallInfo(Vec), From(Uri), To(Uri), Extension { name: String, value: String },