def start_new_dialog(self):
     """ Refresh the SIP dialog specific parameters """
     self.parameters.update({
         "callId": util.randomCallID(),
         "fromTag": util.randomTag(),
         "viaBranch": util.randomBranch(),
         "epid": lambda x=6: "SC" + util.randStr(x),
         "cseq": 1
     })
Exemplo n.º 2
0
 def make_response_to(self, other):
     """ RFC 3261 Section 8.2.6.2 Headers and Tags"""
     self.set_dialog_from(other)
     self.via_branch = other.via_branch
     self["From"] = other["From"]
     self["Call-ID"] = other["Call-ID"]
     self["Via"] = other["Via"]
     if other.to_tag:
         self["To"] = other["To"]
     else:
         self.to_tag = util.randomTag()
Exemplo n.º 3
0
 def start_new_dialog(self):
     """ Refresh the SIP dialog specific parameters """
     dialog = {
         "Call-ID": util.randomCallID(),
         "from_tag": util.randomTag(),
         "to_tag": ""
         # "epid": lambda x=6: "SC" + util.randStr(x),
     }
     self.current_dialog = dialog
     self.dialogs.append(dialog)
     self.requests.append([])
     return dialog
def notify_after_subscribe(sip_ep, notify_dialog):
    cd = dict(notify_dialog)
    subscribe = sip_ep.get_last_message_in(cd)
    cd["to_tag"] = util.randomTag()
    sip_ep.reply(message_string=message["200_OK_1"], dialog=cd)
    cd = sip_ep.current_dialog
    notify_dialog = {"Call-ID": cd["Call-ID"],
                     "from_tag": cd["to_tag"],
                     "to_tag": cd["from_tag"]}
    subscribe.set_dialog_from(notify_dialog)
    sip_ep.save_message(subscribe)
    sip_ep.send(message_string=message["Notify_terminated_1"], expected_response="200 OK", dialog=notify_dialog)
Exemplo n.º 5
0
 def make_response_to(self, other, dialog={}):
     """ RFC 3261 Section 8.2.6.2 Headers and Tags
     :dict dialog: The current sip dialog we are in, represented by
         a dictionary with keys as in the return type of self.get_dialog()
     """
     self.set_dialog_from(other)
     self.via_branch = other.via_branch
     self["From"] = other["From"]
     self["Call-ID"] = other["Call-ID"]
     self["Via"] = other["Via"]
     self["To"] = other["To"]
     if not other.to_tag:
         # This is useful when we make a response to an initial invite.
         # The invite has no to tag. But we made one for Trying
         # and now we must use it for Ringing as well.
         if "to_tag" in dialog and dialog["to_tag"]:
             self.to_tag = dialog["to_tag"]
         else:
             self.to_tag = util.randomTag()
     return self.get_dialog()
Exemplo n.º 6
0
import sys
sys.path.append("..")
from common.client import TCPClient
from sip.SipParser import parseBytes, prepareMessage
from sip.messages import message
from common import util

parameters = {
    "dest_ip": "10.2.0.22",
    "dest_port": 5060,
    "transport": "tcp",
    "callId": util.randomCallID(),
    "user": "******",
    "fromTag": util.randomTag(),
    "sourceIP": util.getLocalIP(),
    "sourcePort": 5080,
    "viaBranch": util.randomBranch(),
    "epid": "SC" + util.randHex(3),
    "expires": "360"
}

# Open the connection
C = TCPClient(parameters["sourceIP"], parameters["sourcePort"])
C.connect(parameters["dest_ip"], parameters["dest_port"])

# Register
m = prepareMessage(message["Register_1"], parameters)
print(m)

C.send(m)