# Path: EventHandler.py
# class EventHandler:
# 	"""An abstract class for SIP event handling classes."""
# 
# 	def __init__(self):
# 		pass
# 
# 	def readEvent(self):
# 		"""This function will be called to get a SIP event as return value.
# 		"""
# 		raise SCNotImplemented("EventHandler", "readEvent", "not implemented")
# 
# 	def writeEvent(self, event):
# 		"""This function will be called to write the given SIP event to the
# 		destination.
# 		"""
# 		raise SCNotImplemented("EventHandler", "writeEvent", "not implemented")
# 
# Path: SCException.py
# class SCException(Exception):
# 	"""Generic internal exception class. Consits out of class name, function
# 	name and the reason phrase.
# 	"""
# 
# 	def __init__(self, cls, funct, reason):
# 		Exception.__init__(self)
# 		self.cls = cls
# 		self.funct = funct
# 		self.reason = reason
# 
# 	def __str__(self):
# 		return str(self.cls) + '.' + str(self.funct) + '(): ' + str(self.reason)
# 
# class SCNotImplemented (SCException):
# 	"""See SCException. Called if implementation is missing."""
# 
# 	def __init__(self, cls, function, reason):
# 		SCException.__init__(self, cls, function, reason)


from EventHandler import EventHandler
from SCException import SCException, SCNotImplemented
import Log, Config, socket, select, copy
import SipEvent as SE
import time
		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:

# Path: EventHandler.py
# class EventHandler:
# 	"""An abstract class for SIP event handling classes."""
# 
# 	def __init__(self):
# 		pass
# 
# 	def readEvent(self):
# 		"""This function will be called to get a SIP event as return value.
# 		"""
# 		raise SCNotImplemented("EventHandler", "readEvent", "not implemented")
# 
# 	def writeEvent(self, event):
# 		"""This function will be called to write the given SIP event to the
# 		destination.
# 		"""
# 		raise SCNotImplemented("EventHandler", "writeEvent", "not implemented")
# 
# Path: SCException.py
# class SCException(Exception):
# 	"""Generic internal exception class. Consits out of class name, function
# 	name and the reason phrase.
# 	"""
# 
# 	def __init__(self, cls, funct, reason):
# 		Exception.__init__(self)
# 		self.cls = cls
# 		self.funct = funct
# 		self.reason = reason
# 
# 	def __str__(self):
# 		return str(self.cls) + '.' + str(self.funct) + '(): ' + str(self.reason)
# 
# class SCNotImplemented (SCException):
# 	"""See SCException. Called if implementation is missing."""
# 
# 	def __init__(self, cls, function, reason):
# 		SCException.__init__(self, cls, function, reason)


# Path: NetworkEventHandler.py
from EventHandler import EventHandler
from SCException import SCException, SCNotImplemented
import Log, Config, socket, select, copy
import SipEvent as SE
import time

		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")