00001 # Copyright (C) 2008-2009 Mark Hanegraaff 00002 # 00003 # This program is free software: you can redistribute it and/or modify 00004 # it under the terms of the GNU General Public License as published by 00005 # the Free Software Foundation, either version 3 of the License, or 00006 # (at your option) any later version. 00007 # 00008 # This program is distributed in the hope that it will be useful, 00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 # GNU General Public License for more details. 00012 # 00013 # You should have received a copy of the GNU General Public License 00014 # along with this program. If not, see <http://www.gnu.org/licenses/>. 00015 00016 from objects.logic.common.exception import exception 00017 00018 00019 00020 ## Generic interface to a Short Lived Database of TCP/IP data. 00021 # Note that since Python does not really support interfaces, this is really just an 00022 # experiment. Note how all functions simply raise a "not implemented" exception. 00023 class storageInterface(): 00024 00025 def __init__(self): 00026 self.notifyCallbackObject = None 00027 00028 # error call back function, should take 1 string parameter 00029 # representing the actual error 00030 self.errorCallBackFunc = None 00031 00032 00033 ## Creates an empty database file. 00034 def createStorage(self): raise exception("not implemented", True) 00035 00036 00037 ## Deletes the database file. 00038 def deleteStorage(self): raise exception("not implemented", True) 00039 00040 00041 ## Opens the database file. 00042 def open(self): raise exception("not implemented", True) 00043 00044 00045 ## Closes the database file. 00046 def close(self): raise exception("not implemented", True) 00047 00048 00049 ## Returns a RecordEet given the supplied parameters 00050 # @param dstIP Destination IP Address String 00051 # @param srcPort Source Port Integer 00052 # @param dstPort Destination Port Integer 00053 def query(self, dstIP, srcPort, dstPort): raise exception("not implemented", True) 00054 00055 00056 ## Saves a single decodedPacketDict Object to the database. 00057 # @param decodedPacketDict Dictionary 00058 def store(self, decodedPacketDict): raise exception("not implemented", True) 00059 00060 00061 ## Performs a commit on the database. 00062 def commit(self): raise exception("not implemented", True) 00063 00064 00065 ## Deletes all data from the database. 00066 def clear(self): raise exception("not implemented", True) 00067 00068 00069 ## Returns the size of the database file in KB 00070 def getStorageSizeBytes(self): raise exception("not implemented", True) 00071 00072 00073 00074 # def notify(self, packetDict, header, data): 00075 # if self.notifyCallbackObject != None and packetDict != None: 00076 # self.notifyCallbackObject.newPacketNotification(packetDict, header, data) 00077 # 00078 00079 # def registerNotifyCallBack(self, callbackObject): 00080 # self.notifyCallbackObject = callbackObject 00081 00082 # callback function for errors 00083 # def registerErrorCallBackFunc(self, callbackFunc): 00084 # self.errorCallBackFunc = callbackFunc 00085 00086 00087 00088 00089
1.5.8