Example #1
0
    def verify(self):
        """This function will be called to check if header field is completely
		correct. It should return a list of test results if anything is not
		correct.
		"""
        raise SCNotImplemented("HeaderFieldHandler", "verify",
                               "not implemented")
Example #2
0
    def parse(self, value):
        """This function will be called with the value of the header field
		as parameter. It should try its best to parse the value and fill
		the attributes of this instance. If an unhandlable error occurse
		a HFHException should be raised.
		"""
        raise SCNotImplemented("HeaderFieldHandler", "parse",
                               "not implemented")
Example #3
0
    def create(self):
        """This function will be called to create the value part of the
		header field instance. The function should only return the value part
		with carriage return and line feed, but without the leading header
		field name and the collon.
		"""
        raise SCNotImplemented("HeaderFieldHandler", "create",
                               "not implemented")
Example #4
0
    def setTransport(self, _transp):
        """Sets the transport of the instance if it is not allready set.
		"""
        if (_transp == socket.SOCK_DGRAM) or (_transp == socket.SOCK_STREAM):
            return
        elif hasattr(_transp, "lower") and (_transp.lower() == "udp"):
            self.transp = socket.SOCK_DGRAM
        elif hasattr(_transp, "lower") and (_transp.lower() == "tcp"):
            self.transp = socket.SOCK_STREAM
        else:
            raise SCNotImplemented("NetworkEvent", "createSock",
                                   "unsupported transport")
Example #5
0
    def createFirstLine(self):
        """Generates the first line of a message. Not implemented in this 
		class.
		"""
        raise SCNotImplemented("SipMessage", "createFirstLine",
                               "not implemented")
Example #6
0
 def verify(self):
     raise SCNotImplemented("Expires", "verify", "not implemented")
Example #7
0
 def verify(self):
     raise SCNotImplemented("RemotePartyID", "verify", "not implemented")
Example #8
0
 def verify(self):
     raise SCNotImplemented("ContentType", "verify", "not implemented")
Example #9
0
 def verify(self):
     raise SCNotImplemented("ContentDisposition", "verify",
                            "not implemented")
Example #10
0
 def create(self):
     raise SCNotImplemented("UserAgent", "create", "not implemented")
Example #11
0
 def __str__(self):
     """To make debuging easier this function should be implemented."""
     raise SCNotImplemented("HeaderFieldHandler", "__str__",
                            "not implemented")
Example #12
0
 def verify(self):
     raise SCNotImplemented("Supported", "verify", "not implemented")
Example #13
0
	def verify(self):
		raise SCNotImplemented("Accept", "verify", "not implemented")
Example #14
0
 def verify(self):
     raise SCNotImplemented("CallID", "verify", "not implemented")
Example #15
0
	def create(self):
		raise SCNotImplemented("Server", "create", "not implemented")
Example #16
0
	def verify(self):
		raise SCNotImplemented("ContentLength", "verify", "not implemented")
Example #17
0
	def verify(self):
		raise SCNotImplemented("Server", "verify", "not implemented")
Example #18
0
 def verify(self):
     raise SCNotImplemented("UserAgent", "verify", "not implemented")
Example #19
0
    def readEvent(self):
        """This function will be called to get a SIP event as return value.
		"""
        raise SCNotImplemented("EventHandler", "readEvent", "not implemented")
Example #20
0
 def verify(self):
     raise SCNotImplemented("Allow", "verify", "not implemented")
Example #21
0
    def writeEvent(self, event):
        """This function will be called to write the given SIP event to the
		destination.
		"""
        raise SCNotImplemented("EventHandler", "writeEvent", "not implemented")
Example #22
0
 def verify(self):
     raise SCNotImplemented("Referto", "verify", "not implemented")
Example #23
0
 def verify(self):
     raise SCNotImplemented("ProxyAuthenticate", "verify",
                            "not implemented")
Example #24
0
	def verify(self):
		raise SCNotImplemented("From", "verify", "not implemented")
Example #25
0
 def create(self):
     raise SCNotImplemented("Route", "create", "not implemented")
Example #26
0
                self.state = NetworkEventHandler.NEH_HALF_CLOSED
                return None
            event.srcAddress = (srcAddr[0], srcAddr[1], self.transp)
            event.received = True
            self.old_data, parsed = event.parseData(self.old_data, self.data)
            if parsed:
                if Config.LOG_NETWORK_PACKETS:
                    Log.logDebug("received:\n" + str(self.data),
                                 Config.LOG_NETWORK_PACKETS_LEVEL)
                event.rawEvent = self
                return event
            else:
                #FIXME a loop to read more data?!
                pass
        else:
            raise SCNotImplemented("NetworkEventHandler", "readEvent",
                                   "unsupported transport")

    def writeEvent(self, event):
        """Writes the given SIP event through the socket to the destination
		given in the SIP event. Returns True is everything was written 
		successfull, False otherwise.
		"""
        if (self.sock is None):
            if (self.transp is None):
                raise SCException("NetworkEventHandler", "writeEvent",
                                  "no socket and transport given")
            else:
                self.createSock(self.transp, Config.LOCAL_IP,
                                Config.LOCAL_PORT)
        else:
            #SOL_SOCKET = getattr(socket, "SOL_SOCKET")
Example #27
0
 def verify(self):
     raise SCNotImplemented("Route", "verify", "not implemented")
Example #28
0
    def writeEvent(self, event):
        """Writes the given SIP event through the socket to the destination
		given in the SIP event. Returns True is everything was written 
		successfull, False otherwise.
		"""
        if (self.sock is None):
            if (self.transp is None):
                raise SCException("NetworkEventHandler", "writeEvent",
                                  "no socket and transport given")
            else:
                self.createSock(self.transp, Config.LOCAL_IP,
                                Config.LOCAL_PORT)
        else:
            #SOL_SOCKET = getattr(socket, "SOL_SOCKET")
            #SO_TYPE = getattr(socket, "SO_TYPE")
            self.transp = self.sock.getsockopt(socket.SOL_SOCKET,
                                               socket.SO_TYPE)
            sn = self.sock.getsockname()
            self.ip = sn[0]
            perc = self.ip.find("%")
            if (perc != -1):
                self.ip = self.ip[:perc]
            col = self.ip.find(":")
            if (col != -1):
                if not self.ip.startswith("["):
                    self.ip = "[" + self.ip
                if not self.ip.endswith("]"):
                    self.ip = self.ip + "]"
            self.port = sn[1]
        # to prevent conversion at other places
        if isinstance(event.srcAddress[2], str):
            if event.srcAddress[2].lower() == "udp":
                event.srcAddress = (event.srcAddress[0], event.srcAddress[1],
                                    socket.SOCK_DGRAM)
            elif event.srcAddress[2].lower() == "tcp":
                event.srcAddress = (event.srcAddress[0], event.srcAddress[1],
                                    socket.SOCK_STREAM)
        if (event.srcAddress[0] != "file") and (event.srcAddress[2] !=
                                                self.transp):
            raise SCException("NetworkEventHandler", "writeEvent",
                              "event transport != socket type")
        self.data, bytes = event.genDataString()
        if ((self.ip is None) and (event.dstAddress is None)):
            raise SCException("NetworkEventHandler", "writeEvent",
                              "missing destination")
        elif (self.ip is None and (event.srcAddress is not None)):
            self.ip = event.srcAddress[0]
            self.port = event.srcAddress[1]
        if Config.ipv6:
            dstip = event.dstAddress[0]
            if dstip.startswith("["):
                dstip = dstip[1:]
            if dstip.endswith("]"):
                dstip = dstip[:len(dstip) - 1]
            #FIXME no clue about flowinfo and scopeid
            dstAddr = (dstip, event.dstAddress[1], 0, 1)
        else:
            dstAddr = (event.dstAddress[0], event.dstAddress[1])
        if (self.transp == socket.SOCK_DGRAM):
            Log.logDebug(
                "Sending UDP message from " + str(self.ip) + ":" +
                str(self.port) + " to " + str(dstAddr[0]) + ":" +
                str(dstAddr[1]) + " ...", 1)
            bytessent = self.sock.sendto(self.data, dstAddr)
        elif (self.transp == socket.SOCK_STREAM):
            if self.state != NetworkEventHandler.NEH_CONNECTED:
                self.sock.connect(dstAddr)
                self.state = NetworkEventHandler.NEH_CONNECTED
                self.remoteip = dstAddr[0]
                self.remoteport = dstAddr[1]
            Log.logDebug(
                "Sending TCP message from " + str(self.ip) + ":" +
                str(self.port) + " to " + str(self.remoteip) + ":" +
                str(self.remoteport) + " ...", 1)
            bytessent = self.sock.send(self.data)
        else:
            raise SCNotImplemented("NetworkEventHandler", "writeEvent",
                                   "unsupport transport")
        event.time = time.time()
        event.rawEvent = self
        Log.logDebug(
            "message length = " + str(bytes) + " bytes, sent " +
            str(bytessent) + " bytes", 4)
        if (bytessent == bytes):
            if Config.LOG_NETWORK_PACKETS:
                Log.logDebug("sent:\n" + str(self.data),
                             Config.LOG_NETWORK_PACKETS_LEVEL)
            return True
        else:
            # FIXME retry?
            return False
Example #29
0
    def parseFirstLine(self, fLine):
        """Trys to parse the first line of the message. Not implemented in
		this class.
		"""
        raise SCNotImplemented("SipMessage", "parseFirstLine",
                               "not implemented")