Changeset 56 for trunk/tool

Show
Ignore:
Timestamp:
09/12/07 14:21:34 (16 years ago)
Author:
andreu
Message:

renetcolGUI.py removed, bugs correction

Files:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/tool/renetcolGUI.py

    r55 r56  
    4747IPversion = 4 
    4848localAddr = '' 
    49 localAddr6 = '2001:660:3001:4012:30ec:9207:2a75:1583' 
     49localAddr6 = '0::' 
    5050localPort = 2222 
    51 collectorAddr = "193.51.183.225" 
    52 collectorAddr6 = "2001:660:3000:1011:10::" 
     51collectorAddr = "127.0.0.1" 
     52collectorAddr6 = "0::" 
    5353collectorPort = 52571  # if you change it, apply the modification on 
    5454                       # the renetcolSender.h file and recompil the collector  
     
    149149        self.flow = [ data[0], data[1] ] 
    150150 
     151# flow selection 
    151152    def enable(self): 
    152         global firstParseValue, checkUpValues, tpl_def 
     153        global firstParseValue, checkUpValues, tpl_def, fromRouter 
    153154        res = 1 
     155        resS = 1 
     156        resD = 1 
    154157        for i in range (0, len(tpl_def[self.flow[0]])): 
    155158            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]) ) 
    158164            elif ( i==27 or i==28 ): 
    159165                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)))) ) 
    160168            elif (checkUpValues[f]==1): 
    161169                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) 
    162173        return res 
    163                  
     174 
     175# flow print 
    164176    def print_flow2(self): 
    165177        global printValue, tpl_def, flowCpt, fieldsName, oldTpl, os_type, fromRouter 
     
    258270        oldTpl = self.flow[0] 
    259271 
     272# flow record 
    260273    def write_flow2(self): 
    261274        global printValue, record_file, tpl_def 
     
    713726        s.close() 
    714727 
     728# dialog box to collector control 
    715729def prefix_callback( widget, entry, id): 
    716730    global collPrefix, coll_window, router, localPort 
     
    738752                            is_good = 0 
    739753                    else: 
     754                        value = value+"/32" 
    740755                        mask[1] = 0xffffffffL 
    741756                        is_good = 1 
     
    791806        check_dialog( widget, None, "Internal program error ;) !") 
    792807 
     808# collector control button 
    793809def prefix_entry(maxLen, tooltip_Text, parent, lab, id): 
    794810    global mainTT 
     
    822838    gtk.main_quit() 
    823839 
     840# Flow Selection 
    824841def enter_callback( widget, entry, id): 
    825842    global firstParseValue 
     
    906923            checkUpValues[1] = 0 
    907924        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 
    915931                else: 
    916                     firstParseValue[1] = int(size_list[1]) 
     932                    firstParseValue[1] = int(entry_text) 
    917933                checkUpValues[1] = 1 
    918934    if id == 7: ## pkts 
     
    9941010            checkUpValues[69] = 0 
    9951011        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] 
    9991024                checkUpValues[69] = 1 
    10001025            else: 
     
    10151040    print "---------------------------------------------------------------" 
    10161041    print "In this version 0.0.7, you can apply rules on the collector based on the following fields:" 
     1042    print "IN_BYTES: 1," 
    10171043    print "L4_SRC_PORT: 7," 
    10181044    print "IPV4_SRC_ADDR: 8," 
     
    11611187    create_entry(5, "Required Format : a number less than 65535", dbbox, "SNMP Index In|Out :", 4) 
    11621188    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) 
    11641190    tbbox = gtk.HButtonBox() 
    11651191    hbox.pack_start(tbbox, False, True, 5) 
     
    11761202    kbbox = gtk.HButtonBox() 
    11771203    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 from this 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) 
    11791205 
    11801206##  Show