Changeset 56 for trunk/tool
- Timestamp:
- 09/12/07 14:21:34 (16 years ago)
- Files:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/tool/renetcolGUI.py
r55 r56 47 47 IPversion = 4 48 48 localAddr = '' 49 localAddr6 = ' 2001:660:3001:4012:30ec:9207:2a75:1583'49 localAddr6 = '0::' 50 50 localPort = 2222 51 collectorAddr = "1 93.51.183.225"52 collectorAddr6 = " 2001:660:3000:1011:10::"51 collectorAddr = "127.0.0.1" 52 collectorAddr6 = "0::" 53 53 collectorPort = 52571 # if you change it, apply the modification on 54 54 # the renetcolSender.h file and recompil the collector … … 149 149 self.flow = [ data[0], data[1] ] 150 150 151 # flow selection 151 152 def enable(self): 152 global firstParseValue, checkUpValues, tpl_def 153 global firstParseValue, checkUpValues, tpl_def, fromRouter 153 154 res = 1 155 resS = 1 156 resD = 1 154 157 for i in range (0, len(tpl_def[self.flow[0]])): 155 158 f = tpl_def[self.flow[0]][i][0] 156 if ( f==8 or f==12 or f==15 or f==18 or f==47) and ( checkUpValues[f]==1 ): 157 res = res & ( ((struct.unpack('>L',(socket.inet_aton(self.flow[1][i])))[0] & mask[1-1]) == firstParseValue[f])| ((struct.unpack('>L',(socket.inet_aton(self.flow[1][i])))[0] & mask[1-1]) == firstParseValue[f]) ) 159 # or f==15 or f==18 or f==47 160 if ( f==8 ) and ( checkUpValues[f]==1 ): 161 resS = resS & ( ((struct.unpack('>L',(socket.inet_aton(self.flow[1][i])))[0] & mask[1-1]) == firstParseValue[f]) ) 162 elif ( f==12 ) and ( checkUpValues[f]==1 ): 163 resD = resD & ( ((struct.unpack('>L',(socket.inet_aton(self.flow[1][i])))[0] & mask[1-1]) == firstParseValue[f]) ) 158 164 elif ( i==27 or i==28 ): 159 165 pass 166 elif ( (f==1) and (checkUpValues[f]==1) ): 167 res = res & ( (self.flow[1][i] <= ((firstParseValue[f])+((firstParseValue[f])*5/100))) and ((self.flow[1][i] >= ((firstParseValue[f])-((firstParseValue[f])*5/100)))) ) 160 168 elif (checkUpValues[f]==1): 161 169 res = res & (self.flow[1][i] == firstParseValue[f]) 170 if ( checkUpValues[69]==1 ): 171 res = res & ( (fromRouter == firstParseValue[69]) ) 172 res = res & (resS or resD) 162 173 return res 163 174 175 # flow print 164 176 def print_flow2(self): 165 177 global printValue, tpl_def, flowCpt, fieldsName, oldTpl, os_type, fromRouter … … 258 270 oldTpl = self.flow[0] 259 271 272 # flow record 260 273 def write_flow2(self): 261 274 global printValue, record_file, tpl_def … … 713 726 s.close() 714 727 728 # dialog box to collector control 715 729 def prefix_callback( widget, entry, id): 716 730 global collPrefix, coll_window, router, localPort … … 738 752 is_good = 0 739 753 else: 754 value = value+"/32" 740 755 mask[1] = 0xffffffffL 741 756 is_good = 1 … … 791 806 check_dialog( widget, None, "Internal program error ;) !") 792 807 808 # collector control button 793 809 def prefix_entry(maxLen, tooltip_Text, parent, lab, id): 794 810 global mainTT … … 822 838 gtk.main_quit() 823 839 840 # Flow Selection 824 841 def enter_callback( widget, entry, id): 825 842 global firstParseValue … … 906 923 checkUpValues[1] = 0 907 924 else: 908 size_list = string.split(entry_text) 909 if (len(size_list)!=2)or((re.search('\D',size_list[0]))or(int(size_list[0])>999999999)or(int(size_list[0])<=0) or (re.search('\D',size_list[1]))or(int(size_list[1])>999999999)or(int(size_list[1])<=0)): 910 check_dialog( widget, None, "Wrong value !") 911 else: 912 firstParseValue[1] = int(size_list[0]) 913 if ( int(size_list[1]) == 999999999 ): 914 firstParseValue[1] = 100000000000 925 if (re.search('\D',entry_text)) or (int(entry_text) > 999999999) or (int(entry_text) <= 0): 926 check_dialog( widget, None, "Wrong value !") 927 else: 928 firstParseValue[1] = int(entry_text) 929 if ( int(entry_text) == 0 ): 930 firstParseValue[1] = 1000000000 915 931 else: 916 firstParseValue[1] = int( size_list[1])932 firstParseValue[1] = int(entry_text) 917 933 checkUpValues[1] = 1 918 934 if id == 7: ## pkts … … 994 1010 checkUpValues[69] = 0 995 1011 else: 996 if (re.match('^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}?$',entry_text)): 997 adip = struct.unpack('>L',socket.inet_aton(entry_text))[0] 998 firstParseValue[69] = adip 1012 if (re.match('^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(/\d{1,2})?$',entry_text)): 1013 splitter = entry_text.split('/') 1014 adip = struct.unpack('>L',socket.inet_aton(splitter[0]))[0] 1015 if len(splitter)>1: 1016 bits = int(splitter[1]) 1017 if bits <= 32 and bits > 0: 1018 mask[0] = 0xffffffffL << (32 - bits) 1019 else: 1020 check_dialog( widget, None, "Wrong value in mask!") 1021 else: 1022 mask[0] = 0xffffffffL 1023 firstParseValue[69] = splitter[0] 999 1024 checkUpValues[69] = 1 1000 1025 else: … … 1015 1040 print "---------------------------------------------------------------" 1016 1041 print "In this version 0.0.7, you can apply rules on the collector based on the following fields:" 1042 print "IN_BYTES: 1," 1017 1043 print "L4_SRC_PORT: 7," 1018 1044 print "IPV4_SRC_ADDR: 8," … … 1161 1187 create_entry(5, "Required Format : a number less than 65535", dbbox, "SNMP Index In|Out :", 4) 1162 1188 create_entry(4, "Required Format : a number less than 9999", dbbox, "Packet NB :", 7) 1163 create_entry(17, "Required Format : a range, each number less than 999999999 and space as separator: \"48 54\"", dbbox, "Bytes :", 6)1189 create_entry(17, "Required Format : a number less than 999999999, each flow who the size equal this number +/- 5%", dbbox, "Bytes :", 6) 1164 1190 tbbox = gtk.HButtonBox() 1165 1191 hbox.pack_start(tbbox, False, True, 5) … … 1176 1202 kbbox = gtk.HButtonBox() 1177 1203 hbox.pack_start(kbbox, False, True, 5) 1178 create_entry(18, "Required Format : \n an IP address like x.x.x.x ", kbbox, "The flows fromthis Router :", 18)1204 create_entry(18, "Required Format : \n an IP address like x.x.x.x or x.x.x.x/x", kbbox, "The flows sending by this Router :", 18) 1179 1205 1180 1206 ## Show