示例#1
0
文件: core.py 项目: stlcours/emesene
    def create_request(self,
                       code,
                       to_uri,
                       uri=None,
                       tag=None,
                       call_id=None,
                       cseq=None):
        """ Create a request outside of a dialog """
        # 8.1.1 Generating the Request (UAC Behavior)

        if uri is None:
            uri = to_uri
        if tag is None:
            tag = self._generate_tag()
        if call_id is None:
            call_id = self._generate_call_id()
        if cseq is None:
            cseq = self._generate_cseq()

        request = SIPRequest(code, uri)
        request.add_header("To", SIPContact("0", to_uri))
        request.add_header("From", SIPContact("0", self.self_uri, tag))
        request.add_header("Call-Id", call_id)
        request.add_header("CSeq", SIPCSeq(cseq, code))
        return request
示例#2
0
    def _create_request(self, code, cseq=None):
        # 12.2.1 UAC Behavior (Requests within a Dialog)
        route = self._route_set
        if not route:
            uri = self._remote_target
        elif ';lr' in route[0]:
            uri = self._remote_target
        else:
            uri = route.pop(0)
            route.append(self._remote_target)

        if not self._local_cseq:
            self._local_cseq = 1 # FIXME 8.1.1.5
        if not cseq:
            self._local_cseq += 1
            cseq = self._local_cseq

        request = SIPRequest(code, self._remote_target)
        if route:
            request.add_header("Route", SIPRoute(route))
        request.add_header("To", SIPContact(None, self._remote_uri, self._remote_tag))
        request.add_header("From", SIPContact(None, self._local_uri, self._local_tag))
        request.add_header("Call-ID", self._call_id)
        request.add_header("CSeq", SIPCSeq(cseq, code))
        return request
示例#3
0
    def create_request(self, code, to_uri, uri=None, tag=None, call_id=None,
            cseq=None):
        """ Create a request outside of a dialog """
        # 8.1.1 Generating the Request (UAC Behavior)

        if uri is None:
            uri = to_uri
        if tag is None:
            tag = self._generate_tag()
        if call_id is None:
            call_id = self._generate_call_id()
        if cseq is None:
            cseq = self._generate_cseq()

        request = SIPRequest(code, uri)
        request.add_header("To", SIPContact("0", to_uri))
        request.add_header("From", SIPContact("0", self.self_uri, tag))
        request.add_header("Call-Id", call_id)
        request.add_header("CSeq", SIPCSeq(cseq, code))
        return request
示例#4
0
文件: call.py 项目: lppedd/papyon
 def build_request(self, code, uri, to, name="0", incr=False):
     request = SIPRequest(code, uri)
     request.add_header("Via", "SIP/2.0/%s %s:%s" %
         (self._transport_protocol, self._ip, self._port))
     request.add_header("Max-Forwards", 70)
     request.add_header("Call-ID", self.id)
     request.add_header("CSeq", "%i %s" % (self.get_cseq(incr), code))
     request.add_header("To", to)
     request.add_header("From", self.build_from_header(name))
     request.add_header("User-Agent", USER_AGENT)
     return request
示例#5
0
文件: core.py 项目: stlcours/emesene
 def _create_cancel_request(self, original_request):
     # 9.1 Client Behavior (Canceling a request)
     request = SIPRequest("CANCEL", original_request.uri)
     request.clone_headers("Route", original_request)
     request.clone_headers("To", original_request)
     request.clone_headers("From", original_request)
     request.clone_headers("Call-ID", original_request)
     cseq = original_request.cseq.number
     request.add_header("CSeq", SIPCSeq(cseq, "CANCEL"))
     return request
示例#6
0
    def _create_request(self, code, cseq=None):
        # 12.2.1 UAC Behavior (Requests within a Dialog)
        route = self._route_set
        if not route:
            uri = self._remote_target
        elif ';lr' in route[0]:
            uri = self._remote_target
        else:
            uri = route.pop(0)
            route.append(self._remote_target)

        if not self._local_cseq:
            self._local_cseq = 1  # FIXME 8.1.1.5
        if not cseq:
            self._local_cseq += 1
            cseq = self._local_cseq

        request = SIPRequest(code, self._remote_target)
        if route:
            request.add_header("Route", SIPRoute(route))
        request.add_header(
            "To", SIPContact(None, self._remote_uri, self._remote_tag))
        request.add_header("From",
                           SIPContact(None, self._local_uri, self._local_tag))
        request.add_header("Call-ID", self._call_id)
        request.add_header("CSeq", SIPCSeq(cseq, code))
        return request
示例#7
0
 def _create_ack_request(self, response):
     # 17.1.1.3 Construction of the ACK Request
     request = SIPRequest("ACK", self._request.uri)
     request.clone_headers("Route", self._request)
     request.clone_headers("To", response)
     request.clone_headers("From", self._request)
     request.clone_headers("Call-ID", self._request)
     request.clone_headers("Via", self._request)  #FIXME single via
     request.add_header("CSeq", SIPCSeq(self._request.cseq.number, "ACK"))
     return request
示例#8
0
 def _create_ack_request(self, response):
     # 17.1.1.3 Construction of the ACK Request
     request = SIPRequest("ACK", self._request.uri)
     request.clone_headers("Route", self._request)
     request.clone_headers("To", response)
     request.clone_headers("From", self._request)
     request.clone_headers("Call-ID", self._request)
     request.clone_headers("Via", self._request) #FIXME single via
     request.add_header("CSeq", SIPCSeq(self._request.cseq.number, "ACK"))
     return request
示例#9
0
 def _create_cancel_request(self, original_request):
     # 9.1 Client Behavior (Canceling a request)
     request = SIPRequest("CANCEL", original_request.uri)
     request.clone_headers("Route", original_request)
     request.clone_headers("To", original_request)
     request.clone_headers("From", original_request)
     request.clone_headers("Call-ID", original_request)
     cseq = original_request.cseq.number
     request.add_header("CSeq", SIPCSeq(cseq, "CANCEL"))
     return request