/** Creates a CANCEL request. */
 public static Message createCancelRequest(Message method, Dialog dialog) {
   ToHeader to = method.getToHeader();
   FromHeader from = method.getFromHeader();
   SipURL request_uri = method.getRequestLine().getAddress();
   NameAddress contact = method.getContactHeader().getNameAddress();
   ViaHeader via = method.getViaHeader();
   String host_addr = via.getHost();
   int host_port = via.getPort();
   boolean rport = via.hasRport();
   String proto = via.getProtocol();
   String branch = method.getViaHeader().getBranch();
   return createRequest(
       SipMethods.CANCEL,
       request_uri,
       to.getNameAddress(),
       from.getNameAddress(),
       contact,
       proto,
       host_addr,
       host_port,
       rport,
       method.getCallIdHeader().getCallId(),
       method.getCSeqHeader().getSequenceNumber(),
       from.getParameter("tag"),
       to.getParameter("tag"),
       branch,
       "",
       null,
       null); // modified by mandrajg
 }
 /** Creates an ACK request for a non-2xx response */
 public static Message createNon2xxAckRequest(
     SipProvider sip_provider, Message method, Message resp) {
   SipURL request_uri = method.getRequestLine().getAddress();
   FromHeader from = method.getFromHeader();
   ToHeader to = resp.getToHeader();
   String via_addr = sip_provider.getViaAddress();
   int host_port = sip_provider.getPort();
   boolean rport = sip_provider.isRportSet();
   String proto;
   if (request_uri.hasTransport()) proto = request_uri.getTransport();
   else proto = sip_provider.getDefaultTransport();
   String branch = method.getViaHeader().getBranch();
   NameAddress contact = null;
   Message ack =
       createRequest(
           SipMethods.ACK,
           request_uri,
           to.getNameAddress(),
           from.getNameAddress(),
           contact,
           proto,
           via_addr,
           host_port,
           rport,
           method.getCallIdHeader().getCallId(),
           method.getCSeqHeader().getSequenceNumber(),
           from.getParameter("tag"),
           to.getParameter("tag"),
           branch,
           null,
           null,
           null); // modified by mandrajg
   ack.removeExpiresHeader();
   if (method.hasRouteHeader()) ack.setRoutes(method.getRoutes());
   return ack;
 }