code: public ViaHeader createViaHeader(String branch, boolean usePublicAddress) {
          try {
          	String host = getIpAddress(usePublicAddress);
              ViaHeader via = SipFactoryImpl.headerFactory.createViaHeader(host, port, transport, branch);
              return via;
          } catch (ParseException ex) {
          	logger.error ("Unexpected error while creating a via header",ex);
              throw new IllegalArgumentException("Unexpected exception when creating via header ", ex);
          } catch (InvalidArgumentException e) {
          	logger.error ("Unexpected error while creating a via header",e);
              throw new IllegalArgumentException("Unexpected exception when creating via header ", e);
  		}
      }
docs: Create a Via Header based on the host, port and transport of this listening point
  @param usePublicAddress if true, the host will be the global ip address found by STUN otherwise
  it will be the local network interface ipaddress
  @param branch the branch id to use
  @return the via header