Jagged array comparisons

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • robbinz
    New Member
    • Mar 2008
    • 1

    #1

    Jagged array comparisons

    Ive got another querie though. Im not sure how to say - if several elements are all the same, and theres another line that has the exact same except one specific feild, deleate that line.

    In other words take a look at my data:

    access-list 1 permit tcp 192.168.1.2 0.0.0.0 168.111.2.1 255.255.255.0 = 23
    access-list 2 deny udp 0.0.0.0 255.255.255.255 0.0.0.0 255.255.255.255 = 23
    access-list 3 permit ospf 192.168.2.3 255.255.255.0 0.0.0.0 255.255.255.255 = 179
    acess-list 2 deny ospf 192.168.2.3 255.255.255.0 0.0.0.0 255.255.255.255 = 179
    access-lst 3 permit 0.0.0.0 255.255.255.255 0.0.0.0 255.255.255.255 = 21
    access-list 5 permit 192.168.0.1 255.255.255.0 0.0.0.0 255.255.255.255 = any
    access-list 14 deny 191.168.0.1 255.255.0.0 0.0.0.0 255.255.255.255 = any
    access-list 443 permit 192.163.0.1 255.255.0.0 0.0.0.0 255.255.255.255 = any
    access-list 77 permit 192.168.0.1 255.255.255.0 0.0.0.0 255.255.255.255 = any
    access-list 5 deny 192.168.34.4 255.255.255.0 0.0.0.0 255.255.255.255 = any
    access-list 5 permit 192.168.0.1 255.255.255.0 0.0.0.0 255.255.255.255 = any
    access-list 2 permit 192.168.1.13 255.0.0.0 0.0.0.0 255.255.255.255 = any
    access-list 77 deny 192.168.0.1 255.255.0.0 0.0.0.0 255.255.255.255 = any
    access-list 88 permit 192.168.0.1 255.255.255.0 0.0.0.0 255.255.255.255 = any
    access-list 1 deny 192.168.0.2 255.255.255.0 0.0.0.0 255.255.255.255 = any
    access-list 2 permit 192.168.0.4 255.255.255.0 0.0.0.0 255.255.255.255 = any

    Taking into consideration that [2] can be only permit or deny:

    Im trying to say if all the elements of each line were the exact same, apart from [2] The permit or deny element, then delete the lines that have opposing [2] rules. In other words if I had:

    access-list 1 permit 192.168.1.1 0.0.0.1 ...ect
    access-list 1 deny 192.168.1.1 0.0.0.1 ...ect
    access-list 1 permit 192.168.1.1 0.0.0.1 ...ect
    access-list 1 permit 192.163.1.1 0.0.0.1 ...ect
    access-list 1 deny 192.168.1.1 0.0.0.1 ...ect
    access-list 1 deny 192.168.1.1 0.0.0.1 ...ect
    access-list 1 permit 111.162.1.1 0.0.0.1 ...ect
    access-list 1 permit 195.168.4.1 0.0.0.1 ...ect

    Then by looking at the first rule and saying:

    For any line where:

    access-list 1 192.168.1.1 0.0.0.1

    was the same and only the permit feild is changed delete it and display the new file. Which would probebly look like this.

    access-list 1 permit 192.168.1.1 0.0.0.1 ...ect
    access-list 1 permit 192.168.1.1 0.0.0.1 ...ect
    access-list 1 permit 192.163.1.1 0.0.0.1 ...ect
    access-list 1 permit 111.162.1.1 0.0.0.1 ...ect
    access-list 1 permit 195.168.4.1 0.0.0.1 ...ect

    in other words if the rules is

    access-list 1 permit 192.168.1.1 0.0.0.1

    deleat all other rulles that look like this:

    access-list 1 deny 192.168.1.1 0.0.0.1


    I have a rule that deals with exact copys and would like to keep them differant so now im just trying to delete conflicting permit/deny feilds.

    I know this is pretty complicated so any help as to how it would be done would be excellent.

    Thanks in advance.
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    You want BOTH the rules to be wiped out, or just one? What if there were three rules (two of them were permit and one was deny say), would you keep one or do all three get deleted?
    (I understand as conflicting rules they are invalid)

    What if you took like a datatable with 3 columns.
    One column would be the key and would be the concatination of all the fields other then the permit field. The second column would BE the permit field and the third would be a count.
    You would keep adding into the table any new key values (and the permit field and a count of 1), if it already exists, just increment the count.
    Any records with a count over 1 would be deleted and then you can pull back your data?

    That seems like a lot of work now that I think about it, but it's the best I've come up with so far.

    Comment

    Working...