From: Richard Whitehouse Date: Sun, 29 Oct 2017 19:37:39 +0000 (+0000) Subject: Support Priority header X-Git-Url: https://git.richardwhiuk.com/?a=commitdiff_plain;h=1ab6c514d8c84844b6a11bb85f2762459941e95d;p=rust-sip.git Support Priority header --- diff --git a/src/codec.rs b/src/codec.rs index 42afee1..31f9a49 100644 --- a/src/codec.rs +++ b/src/codec.rs @@ -440,7 +440,7 @@ mod tests { com>\r\nExpires:30\r\nFrom:sip:+12125551212@server.phone2net.com;\ tag=887s\r\nIn-Reply-To:70710@saturn.bell-tel.com,17320@saturn.\ bell-tel.com\r\nMax-Forwards:32\r\nMIME-Version:2.0\r\nMin-Expires:\ - 30\r\nOrganization:Foobar\r\nVia: localhost\r\n\r\n") + 30\r\nOrganization:Foobar\r\nPriority:normal\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 daccfea..59aed8e 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -16,7 +16,7 @@ use types::{PathSegment, HostPort, Host, Hostname, UriParameter, UriHeader, UriH Language, AlertParam, Qop, AuthenticationInfo, AuthParam, Algorithm, DigestResponse, Credentials, CallId, Purpose, InfoParam, Info, NameAddr, ContactParam, Target, Contact, DispositionType, Handling, DispositionParam, ContentCoding, Day, Month, Date, - Time, DateTime, ErrorUri, FromParam, From}; + Time, DateTime, ErrorUri, FromParam, From, Priority}; fn is_mark(c: u8) -> bool { c == b'-' || c == b'_' || c == b'.' || c == b'!' || c == b'~' || c == b'*' || c == b'\'' || @@ -979,6 +979,15 @@ named!(organization_header>, preceded!( tag!(b"Organization:"), word)); +named!(priority_header, preceded!( + tag!(b"Priority:"), + alt!( + tag!(b"emergency") => { |_| Priority::Emergency } | + tag!(b"urgent") => { |_| Priority::Urgent } | + tag!(b"normal") => { |_| Priority::Normal } | + tag!(b"non-urgent") => { |_| Priority::NonUrgent } | + token => { |t| Priority::Other(t) }))); + named!(pub header
, alt!( // RFC 3261 Headers accept_header => { |a| Header::Accept(a) } | @@ -1005,5 +1014,6 @@ named!(pub header
, alt!( max_forwards_header => { |m| Header::MaxForwards(m) } | mime_version_header => { |(m, v)| Header::MimeVersion(m, v) } | min_expires_header => { |m| Header::MinExpires(m) } | - organization_header => { |o| Header::Organization(o) } + organization_header => { |o| Header::Organization(o) } | + priority_header => { |p| Header::Priority(p) } )); diff --git a/src/types.rs b/src/types.rs index 72ac56d..6a546d2 100644 --- a/src/types.rs +++ b/src/types.rs @@ -341,6 +341,15 @@ pub enum FromParam { pub type From = (Target, Vec); +#[derive(Debug)] +pub enum Priority { + Emergency, + Urgent, + Normal, + NonUrgent, + Other(Vec) +} + #[derive(Debug)] pub enum Header { Accept(Vec), @@ -368,6 +377,7 @@ pub enum Header { MimeVersion(u32, u32), MinExpires(u32), Organization(Vec), + Priority(Priority), To(Uri), Extension { name: String, value: String }, }