* @param local_tag tag in FromHeader
* @param remote_tag tag in ToHeader (if null, no tag is added)
* @param branch branch value (if null, a random value is picked)
* @param body body (if null, no body is added) */
public static Message createRequest(String method, SipURL request_uri, NameAddress to, NameAddress from, NameAddress contact, String proto, String via_addr, int host_port, boolean rport, String call_id, long cseq, String local_tag, String remote_tag, String branch, String body)
{ Message req=new Message();
//mandatory headers first (To, From, Via, Max-Forwards, Call-ID, CSeq):
req.setRequestLine(new RequestLine(method,request_uri));
ViaHeader via=new ViaHeader(proto,via_addr,host_port);
if (rport) via.setRport();
if (branch==null) branch=SipProvider.pickBranch();
via.setBranch(branch);
req.addViaHeader(via);
req.setMaxForwardsHeader(new MaxForwardsHeader(70));
if (remote_tag==null) req.setToHeader(new ToHeader(to));
else req.setToHeader(new ToHeader(to,remote_tag));
req.setFromHeader(new FromHeader(from,local_tag));
req.setCallIdHeader(new CallIdHeader(call_id));
req.setCSeqHeader(new CSeqHeader(cseq,method));
//optional headers:
if (contact!=null)
{ MultipleHeader contacts=new MultipleHeader(SipHeaders.Contact);
contacts.addBottom(new ContactHeader(contact));
//System.out.println("DEBUG: Contact: "+contact.toString());
req.setContacts(contacts);
}
req.setExpiresHeader(new ExpiresHeader(String.valueOf(SipStack.default_expires)));
// add User-Agent header field
if (SipStack.ua_info!=null) req.setUserAgentHeader(new UserAgentHeader(SipStack.ua_info));
//if (body!=null) req.setBody(body); else req.setBody("");
req.setBody(body);
//System.out.println("DEBUG: MessageFactory: request:\n"+req);
return req;
}