Header, MediaMainType, MediaType, MediaFullType, MediaParameter, MediaRange,
GenericParam, AcceptParam, AcceptRange, Coding, Encoding, LanguageTag, LanguageRange,
Language, AlertParam, Qop, AuthenticationInfo, AuthParam, Algorithm, DigestResponse,
- Credentials, CallId, Purpose, InfoParam, Info, NameAddr, ContactParam, ContactTarget,
+ Credentials, CallId, Purpose, InfoParam, Info, NameAddr, ContactParam, Target,
Contact, DispositionType, Handling, DispositionParam, ContentCoding, Day, Month, Date,
- Time, DateTime, ErrorUri};
+ Time, DateTime, ErrorUri, FromParam, From};
fn is_mark(c: u8) -> bool {
c == b'-' || c == b'_' || c == b'.' || c == b'!' || c == b'~' || c == b'*' || c == b'\'' ||
opt!(uri_headers)
)));
+type _SipUriNp = (Option<UserInfo>, HostPort);
+
+named!(sip_uri_np<&[u8], _SipUriNp>, preceded!(
+ tag!("sip:"),
+ tuple!(
+ opt!(userinfo),
+ hostport
+ )));
+
+named!(sips_uri_np<&[u8], _SipUriNp>, preceded!(
+ tag!("sips:"),
+ tuple!(
+ opt!(userinfo),
+ hostport
+ )));
+
fn is_scheme_unreserved(c: u8) -> bool {
nom::is_alphanumeric(c) || c == b'+' || c == b'-' || c == b'.'
}
path: p } }
));
+// Variant without URI parameters or header parameters
+named!(uri_np<&[u8], Uri>, alt!(
+ sip_uri_np => { |(u, hp)| Uri::Sip(SipUri {
+ user_info: u,
+ host_port: hp,
+ params: vec![],
+ headers: None }) } |
+ sips_uri_np => { |(u, hp)| Uri::Sips(SipUri {
+ user_info: u,
+ host_port: hp,
+ params: vec![],
+ headers: None }) } |
+ absolute_uri => { |(s, p)| Uri::Generic {
+ scheme: s,
+ path: p } }
+));
+
named!(sip_version<&[u8], Version>, preceded!(
tag!("SIP/"),
dbg_dmp!(separated_pair!(
expires => {|e| ContactParam::Expires(e) } |
generic_param => {|g| ContactParam::Generic(g) }));
-named!(contact_target<(ContactTarget, Vec<ContactParam>)>, tuple!(
+named!(target<Target>,
alt!(
- name_addr => { |(n, u)| ContactTarget::Name(n, u) } |
- uri => { |u| ContactTarget::Uri(u) }),
+ name_addr => { |(n, u)| Target::Name(n, u) } |
+// With this target variant, parameters conflict - so they aren't allowed
+// See RFC 3261 Section 20.10
+ uri_np => { |u| Target::Uri(u) }));
+
+named!(contact_target<(Target, Vec<ContactParam>)>, tuple!(
+ target,
many0!(preceded!(
tag!(b";"),
contact_param
tag!(b"Expires:"),
number));
+named!(from_param<FromParam>, alt!(
+ preceded!(tag!("tag="), token) => { |t| FromParam::Tag(t) } |
+ generic_param => { |g| FromParam::Generic(g) }));
+
+named!(from_header<From>, preceded!(
+ alt!(tag!(b"From:") | tag!("f:")),
+ tuple!(
+ target,
+ many0!(preceded!(
+ tag!(b";"),
+ from_param)))));
+
named!(pub header<Header>, alt!(
// RFC 3261 Headers
accept_header => { |a| Header::Accept(a) } |
cseq_header => { |(c, m)| Header::CSeq(c, m) } |
date_header => { |d| Header::Date(d) } |
error_info_header => { |e| Header::ErrorInfo(e) } |
- expires_header => { |e| Header::Expires(e) }
+ expires_header => { |e| Header::Expires(e) } |
+ from_header => { |f| Header::From(f) }
));