#! /usr/bin/perl # # Purpose: # FlowViewer_UI.pm holds utility functions that are called # by FlowViewer, FlowGrapher, and FlowTracker scripts to create # the version 4.0 User Interface. # # Description: # Various user interface utility functions. # # Input arguments: # Name Description # ----------------------------------------------------------------------- # None # # Modification history: # Author Date Vers. Description # ----------------------------------------------------------------------- # J. Loiacono 05/08/2012 4.0 Original Version. # #$Author$ #$Date$ #$Header$ # ########################################################################### # # BEGIN EXECUTABLE STATEMENTS # use File::stat; use Time::Local; use Time::HiRes qw( usleep ualarm gettimeofday tv_interval ); sub create_UI_top { my ($called_by) = @_; # Create the top FlowViewer title and Local Information print "Content-type:text/html\n\n"; print "\n\n"; print "\n"; print "\n"; print "\n"; print "FlowViewer - Maintaining Network Traffic Situational Awareness\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "
\n"; print "\n"; print "
\n"; print "
\n"; print " $left_title\n"; print "
\n"; print "
\n"; print " $right_title\n"; print "
\n"; print "
\n"; print " FlowViewer\n"; print "

\n"; print " Powered by flow-tools and SiLK\n"; print "

\n"; print "\n"; } sub create_UI_service { my ($called_by,$service_location,$filter_hash) = @_; # Create the left-side Active Trackings pulldown print "
\n"; print " \n"; if ($called_by =~ /FlowViewer/) { print " \n"; if (($called_by =~ /Main/) && ($service_location eq "service_bottom")) { print "
\n"; print " \n"; } else { print " \n"; print " \n"; } print "
\n"; print " \n"; print "
\n"; print " \n"; print "
\n"; print " \n"; if (($called_by =~ /Main/) && ($service_location eq "service_bottom")) { print "
\n"; print " \n"; } else { print " \n"; print " \n"; } print "
\n"; } elsif ($called_by =~ /FlowGrapher/) { print " \n"; if (($called_by =~ /Main/) && ($service_location eq "service_bottom")) { print "
\n"; print " \n"; } else { print " \n"; print " \n"; } print "
\n"; print " \n"; print "
\n"; print " \n"; print "
\n"; print " \n"; if (($called_by =~ /Main/) && ($service_location eq "service_bottom")) { print "
\n"; print " \n"; } else { print " \n"; print " \n"; } print "
\n"; } elsif ($called_by =~ /FlowTracker/) { print " \n"; if (($called_by =~ /Display/) && ($service_location eq "service_bottom")) { print "
\n"; print " \n"; } else { print " \n"; print " \n"; } print "
\n"; print " \n"; print "
\n"; print " \n"; print "
\n"; print " \n"; if (($called_by =~ /Display/) && ($service_location eq "service_bottom")) { print "
\n"; print " \n"; } else { print " \n"; print " \n"; } print "
\n"; } # Create the right-side Saved Reports pulldown print " \n"; print "
\n"; } sub create_UI_sides { my ($called_by) = @_; while ($dashboard_file = <$dashboard_directory/*>) { ($directory,$thumbnail_file) = $dashboard_file =~ m/(.*\/)(.*)$/; ($th_filter_hash,$suffix) = split(/\./,$thumbnail_file); $last_underscore = rindex($th_filter_hash,"_"); $th_filter_hash = substr($th_filter_hash,0,$last_underscore); $last_underscore = rindex($th_filter_hash,"_"); $th_filter_hash = substr($th_filter_hash,0,$last_underscore); $th_filter_hash = "TR_" . $th_filter_hash; $thumbnail_file = "$dashboard_short/$thumbnail_file"; if ($dashboard_file =~ "_1.png") { $side_thumbnails{pos_1} = $thumbnail_file; $side_hash{pos_1} = $th_filter_hash; } if ($dashboard_file =~ "_2.png") { $side_thumbnails{pos_2} = $thumbnail_file; $side_hash{pos_2} = $th_filter_hash; } if ($dashboard_file =~ "_3.png") { $side_thumbnails{pos_3} = $thumbnail_file; $side_hash{pos_3} = $th_filter_hash; } if ($dashboard_file =~ "_4.png") { $side_thumbnails{pos_4} = $thumbnail_file; $side_hash{pos_4} = $th_filter_hash; } if ($dashboard_file =~ "_5.png") { $side_thumbnails{pos_5} = $thumbnail_file; $side_hash{pos_5} = $th_filter_hash; } if ($dashboard_file =~ "_6.png") { $side_thumbnails{pos_6} = $thumbnail_file; $side_hash{pos_6} = $th_filter_hash; } if ($dashboard_file =~ "_7.png") { $side_thumbnails{pos_7} = $thumbnail_file; $side_hash{pos_7} = $th_filter_hash; } if ($dashboard_file =~ "_8.png") { $side_thumbnails{pos_8} = $thumbnail_file; $side_hash{pos_8} = $th_filter_hash; } } # Create the left side with Dashboard FlowTracker Thumbnails print "
\n"; if ($side_thumbnails{pos_1} ne "") { print " \n"; print " \n"; } if ($side_thumbnails{pos_3} ne "") { print " \n"; print " \n"; } if ($side_thumbnails{pos_5} ne "") { print " \n"; print " \n"; } if ($side_thumbnails{pos_7} ne "") { print " \n"; print " \n"; } print "
\n"; # Create the right side with Dashboard FlowTracker Thumbnails print "
\n"; if ($side_thumbnails{pos_2} ne "") { print " \n"; print " \n"; } if ($side_thumbnails{pos_4} ne "") { print " \n"; print " \n"; } if ($side_thumbnails{pos_6} ne "") { print " \n"; print " \n"; } if ($side_thumbnails{pos_8} ne "") { print " \n"; print " \n"; } print "
\n"; } sub finish_the_page { my ($called_by) = @_; # Finish the web page print "
\n"; print "\n"; print "\n"; } sub create_filtering_form { ($called_by,$filter_hash) = @_; if ($called_by eq "FlowViewer") { print "
\n"; } if ($called_by eq "FlowGrapher") { print " \n"; } if ($called_by eq "FlowTracker") { print " \n"; } if ($called_by eq "FlowTracker_Sol") { print " \n"; $skip_date = "Y";} load_filtering_parameters($called_by,$filter_hash); if ($new_device ne "") { $form_device_name = $new_device; } if ($new_exporter ne "") { $form_exporter = $new_exporter; } print "
\n"; if ($called_by eq "FlowViewer" ) { print "  Create a FlowViewer Report\n"; } if ($called_by eq "FlowGrapher") { print "  Create a FlowGrapher Report\n"; } if ($called_by eq "FlowTracker") { print "  Create a FlowTracking\n"; } if ($called_by =~ "FlowTracker_Sol") { $tracking_hash = $form_tracking_label; $tracking_hash =~ s/ /~/g; print "  Revise FlowTracking: $form_tracking_label\n"; } print "\n"; # List the saved filters in the pulldown print "
\n"; print " Saved Filters\n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; print "\n"; # Prepare the Device and Exporter pulldowns print "
\n"; print " Netflow Source\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; print "\n"; # Prepare the Period Start and End times (calculate if not saved.) if ($called_by =~ "FlowTracker") { if ($skip_date ne "Y") { ($sec,$min,$hr,$date,$mnth,$yr,$day,$yr_date,$DST) = localtime(time-$start_offset); $mnth += 1; $yr += 1900; $min_delta = $min % 5; $min = $min - $min_delta; if (length $min < 2) { $min = "0" . $min; } $start_date_out = $mnth ."/". $date ."/". $yr; if ($use_even_hours eq "Y") { $start_time_out = $hr .":00:00"; } else { $start_time_out = $hr .":". $min .":00"; } print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; print "\n"; } else { $skip_date = ""; } } else { $start_date_out = $form_start_date; $start_time_out = $form_start_time; $end_date_out = $form_end_date; $end_time_out = $form_end_time; if ($start_date_out eq "") { ($sec,$min,$hr,$date,$mnth,$yr,$day,$yr_date,$DST) = localtime(time-$start_offset); $mnth += 1; $yr += 1900; $min_delta = $min % 5; $min = $min - $min_delta; if (length $min < 2) { $min = "0" . $min; } $start_date_out = $mnth ."/". $date ."/". $yr; if ($use_even_hours eq "Y") { $start_time_out = $hr .":00:00"; } else { $start_time_out = $hr .":". $min .":00"; } ($sec,$min,$hr,$date,$mnth,$yr,$day,$yr_date,$DST) = localtime(time-$end_offset); $mnth += 1; $yr += 1900; $min_delta = $min % 5; $min = $min - $min_delta; if (length $min < 2) { $min = "0" . $min; } $end_date_out = $mnth ."/". $date ."/". $yr; if ($use_even_hours eq "Y") { $end_time_out = $hr .":00:00"; } else { $end_time_out = $hr .":". $min .":00"; } } print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; print "\n"; } # Prepare the Source related fields print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print "

\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; print "\n"; # Prepare the Destination related fields print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print "

\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; print "\n"; # Prepare the Additional Fields print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; } sub create_reporting_form { print "
\n"; print " Reporting Parameters\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "


\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; if ($form_cutoff_lines eq "") { $form_cutoff_lines = $default_lines; } print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "


\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; } sub create_graphing_form { print "
\n"; print " Graphing Parameters\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "

\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; if ($form_detail_lines eq "") { $form_detail_lines = $detail_lines; } print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; } sub create_tracking_form { print "
\n"; print " Tracking Parameters\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "

\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "

\n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; } sub create_revision_form { print "
\n"; print " Revision Notes\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; } sub create_SiLK_form { # If using IPFIX, prepare the SiLK Sources foreach $ipfix_device (@ipfix_devices) { if ($form_device_name eq $ipfix_device) { $IPFIX = 1; } } if (($IPFIX) && ($silk_all_only ne "Y")) { print "
\n"; print " SiLK Sources\n"; print " \n"; print " \n"; if ((substr($form_silk_field,0,1) eq "1") || (($form_silk_field == 0) && ($form_silk_other eq ""))) { print " \n"; } else { print " \n"; } print " \n"; print " \n"; print " \n"; if (substr($form_silk_field,1,1) eq "1") { print " \n"; } else { print " \n"; } print " \n"; print " \n"; print " \n"; if (substr($form_silk_field,2,1) eq "1") { print " \n"; } else { print " \n"; } print " \n"; print " \n"; print " \n"; if (substr($form_silk_field,3,1) eq "1") { print " \n"; } else { print " \n"; } print " \n"; print " \n"; print " \n"; if (substr($form_silk_field,4,1) eq "1") { print " \n"; } else { print " \n"; } print " \n"; print " \n"; print " \n"; if (substr($form_silk_field,5,1) eq "1") { print " \n"; } else { print " \n"; } print " \n"; print " \n"; print " \n"; if (substr($form_silk_field,6,1) eq "1") { print " \n"; } else { print " \n"; } print " \n"; print " \n"; print " \n"; if ($form_silk_other ne "") { print " \n"; } else { print " \n"; } print " \n"; print "
\n"; } } sub create_submit_buttons { my ($called_by) = @_; if ($called_by ne "FlowTracker_Sol") { print "
\n"; } print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; if ($called_by eq "FlowViewer") { print " \n"; } if ($called_by eq "FlowGrapher") { print " \n"; } if ($called_by eq "FlowTracker") { print " \n"; } if ($called_by eq "FlowTracker_Sol") { print " \n"; $called_by = "FlowTracker"; } print "                     \n"; print " \n"; print " \n"; print " \n"; print "
\n"; if ($called_by ne "FlowTracker_Sol") { print "
\n"; } print "
\n"; print "
\n"; } sub create_filter_output { my ($called_by,$filter_hash) = @_; load_filtering_parameters($called_by,$filter_hash); if ($called_by =~ "FlowTracker_Replay") { print "
\n"; print " $form_Description\n"; print "
\n"; } if ($called_by =~ "FlowTracker") { print "
\n"; print " $form_tracking_label\n"; print "
\n"; } if ($form_tracking_type eq "Group") { if ($form_general_comment ne "") { print "
\n"; print " $form_general_comment\n"; } return; } if ($time_zone eq "") { open(DATE,"date 2>&1|"); while () { ($d_tz,$m_tz,$dt_tz,$t_tz,$time_zone,$y_tz) = split(/\s+/,$_); } } print " \n"; if (($called_by =~ "FlowViewer") || ($called_by =~ "FlowGrapher")) { print " \n"; if ($called_by =~ "FlowViewer") { if ($stat_report == 99) { $report_title = "Summary"; } if ($stat_report == 5) { $report_title = "UDP/TCP Destination Port"; } if ($stat_report == 6) { $report_title = "UDP/TCP Source Port"; } if ($stat_report == 7) { $report_title = "UDP/TCP Port"; } if ($stat_report == 8) { $report_title = "Destination IP"; } if ($stat_report == 9) { $report_title = "Source IP"; } if ($stat_report == 10) { $report_title = "Source/Destination IP"; } if ($stat_report == 11) { $report_title = "Source or Destination IP"; } if ($stat_report == 12) { $report_title = "IP Protocol"; } if ($stat_report == 17) { $report_title = "Input Interface"; } if ($stat_report == 18) { $report_title = "Output Interface"; } if ($stat_report == 19) { $report_title = "Source AS"; } if ($stat_report == 20) { $report_title = "Destination AS"; } if ($stat_report == 21) { $report_title = "Source/Destination AS"; } if ($stat_report == 22) { $report_title = "IP ToS"; } if ($stat_report == 23) { $report_title = "Input/Output Interface"; } if ($stat_report == 24) { $report_title = "Source Prefix"; } if ($stat_report == 25) { $report_title = "Destination Prefix"; } if ($stat_report == 26) { $report_title = "Source/Destination Prefix"; } if ($stat_report == 27) { $report_title = "Exporter IP"; } if ($print_report == 1) { $report_title = "Flow Times"; } if ($print_report == 4) { $report_title = "AS Numbers"; } if ($print_report == 5) { $report_title = "132 Columns"; } if ($print_report == 9) { $report_title = "1 Line with Tags"; } if ($print_report == 10) { $report_title = "AS Aggregation"; } if ($print_report == 11) { $report_title = "Protocol Port Aggregation"; } if ($print_report == 12) { $report_title = "Source Prefix Aggregation"; } if ($print_report == 13) { $report_title = "Destination Prefix Aggregation"; } if ($print_report == 14) { $report_title = "Prefix Aggregation"; } if ($print_report == 15) { $report_title = "Source Prefix Aggregation v6"; } if ($print_report == 16) { $report_title = "Destination Prefix Aggregation v6"; } if ($print_report == 17) { $report_title = "Prefix Aggregation v6"; } if ($print_report == 24) { $report_title = "Full (Catalyst)"; } print " \n"; print " \n"; print " \n"; if ($form_sort_field == 1) { print " \n"; } if ($form_sort_field == 2) { print " \n"; } if ($form_sort_field == 3) { print " \n"; } } elsif ($called_by =~ "FlowGrapher") { print " \n"; print " \n"; print " \n"; print " \n"; } print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; } if ($form_exporter ne "") { foreach $exporter_pair (@exporters) { ($exporter_ip,$exporter_name) = split(/:/,$exporter_pair); if ($form_exporter eq $exporter_ip) { last; } } } print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; if ($form_sif_names ne "") { if ($form_device_name ne "") { $interfaces_file = "$cgi_bin_directory/NamedInterfaces_Devices"; } elsif ($form_exporter ne "") { $interfaces_file = "$cgi_bin_directory/NamedInterfaces_Exporters"; } open (NAMED,"<$interfaces_file"); chomp (@interfaces = ); close (NAMED); foreach $interface (@interfaces) { if (($interface eq "") || (substr($interface,0,1) eq "#")) { next; } ($device,$interface_index,$interface_name) = split(/:/,$interface); if (($device eq $form_device_name) || ($device eq $form_exporter)) { if ($interface_index eq $form_sif_names) { $sif_name_out = $interface_name; } } } print " \n"; } else { print " \n"; } print " \n"; if ($form_dif_names ne "") { if ($form_device_name ne "") { $interfaces_file = "$cgi_bin_directory/NamedInterfaces_Devices"; } elsif ($form_exporter ne "") { $interfaces_file = "$cgi_bin_directory/NamedInterfaces_Exporters"; } open (NAMED,"<$interfaces_file"); chomp (@interfaces = ); close (NAMED); foreach $interface (@interfaces) { if (($interface eq "") || (substr($interface,0,1) eq "#")) { next; } ($device,$interface_index,$interface_name) = split(/:/,$interface); if (($device eq $form_device_name) || ($device eq $form_exporter)) { if ($interface_index eq $form_dif_names) { $dif_name_out = $interface_name; } } } print " \n"; } else { print " \n"; } print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; if (($form_nexthop_ips ne "") || ($form_protocols ne "")) { print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; } if (($form_tos_fields ne "") || ($form_tcp_flags ne "")) { print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; } if ($called_by =~ "FlowGrapher") { print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; } if ($called_by =~ "FlowViewer") { print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; } if (($called_by =~ "FlowViewer") || ($called_by =~ "FlowGrapher")) { if ($form_flow_select == 1) { $flow_select_out = "Any Part in Specified Time Span"; } if ($form_flow_select == 2) { $flow_select_out = "End Time in Specified Time Span"; } if ($form_flow_select == 3) { $flow_select_out = "Start Time in Specified Time Span"; } if ($form_flow_select == 4) { $flow_select_out = "Entirely in Specified Time Span"; } print " \n"; print " \n"; print " \n"; print " \n"; } if ($form_IPFIX) { if (substr($form_silk_field,0,1) eq "1") { $silk_source_out = "all"; } else { if (substr($form_silk_field,1,1) eq "1") { $silk_source_out .= "in, "; } if (substr($form_silk_field,2,1) eq "1") { $silk_source_out .= "out, "; } if (substr($form_silk_field,3,1) eq "1") { $silk_source_out .= "inweb, "; } if (substr($form_silk_field,4,1) eq "1") { $silk_source_out .= "outweb, "; } if (substr($form_silk_field,5,1) eq "1") { $silk_source_out .= "int2int, "; } if (substr($form_silk_field,6,1) eq "1") { $silk_source_out .= "ext2ext"; } } if (substr($silk_source_out,-2,2) eq ", ") { $silk_source_out = substr($silk_source_out,0,-2); } if ($form_silk_other ne "") { $silk_source_out = $form_silk_other; } print " \n"; print " \n"; print " \n"; print " \n"; } if (($called_by =~ "FlowTracker") && ($form_general_comment ne "")) { print " \n"; print " \n"; print " \n"; print " \n"; } if (($form_sampling_multiplier > 1) && (!(($stat_report == 99) && ($IPFIX)))) { print " \n"; print " \n"; print " \n"; print " \n"; } if ((($form_print_report >= 12) && ($form_print_report <= 17)) && (($form_source_addresses eq "") && ($form_dest_addresses eq ""))) { print " \n"; print " \n"; print " \n"; print " \n"; } print "
Report:  $report_titleSort Field:  OctetsFlowsPacketsReport:  $form_graph_type/secBucket Size:  $form_bucket_size sec
Start Time:  $form_start_date $form_start_time $time_zoneEnd Time:  $form_end_date $form_end_time $time_zone
Device Name:  $form_device_nameExporter:  $exporter_name
Source IPs:  $form_source_addressesDestination IPs:  $form_dest_addresses
Source Ports:  $form_source_portsDestination Ports:  $form_dest_ports
Source I/Fs:  $sif_name_out$form_source_ifsDestination I/Fs:  $dif_name_out$form_dest_ifs
Source AS:  $form_source_asesDestination AS:  $form_dest_ases
NextHop IPs:  $form_nexthop_ipsProtocols:  $form_protocols
TOS Field:  $form_tos_fieldsTCP Flags:  $form_tcp_flags
Detail Lines:  $form_detail_linesGraph Width:  $form_graph_multiplier
Cutoff Lines:  $form_cutoff_linesCutoff Octets:  $form_cutoff_octets
Include If:  $flow_select_out
SiLK Sources:  $silk_source_out
Comments:  $form_general_comment
Note:  *all values have been multiplied by the Sampling Multiplier: $form_sampling_multiplier
Note:  You may change the mask using the Source or Dest IP: fields (e.g., /24)
\n"; } sub load_filtering_parameters { ($called_by,$filter_hash) = @_; if ($filter_hash eq "") { if ($called_by eq "FlowViewer") { $filter_hash = "FV_"; } if ($called_by eq "FlowGrapher") { $filter_hash = "FG_"; } if ($called_by eq "FlowTracker") { $filter_hash = "FT_"; } } else { $filter_source = substr($filter_hash,0,2); $filter_link = substr($filter_hash,3,255); if ($filter_link =~ /^/) { if (substr($filter_link,0,1) eq "^") { $new_device = substr($filter_link,1,255); $filter_link = ""; } else { ($filter_filename,$new_device) = split(/\^/,$filter_link); } if (substr($new_device,0,3) eq "DDD") { $new_device = substr($new_device,3,255); } if (substr($new_device,0,3) eq "EEE") { $new_exporter = substr($new_device,3,255); } $filter_hash = $filter_source ."_". $filter_filename; } if ($filter_source eq "FV") { $filter_source_file = "$work_directory/$filter_filename"; } if ($filter_source eq "FG") { $filter_source_file = "$work_directory/$filter_filename"; } if ($filter_source eq "FT") { $filter_source_file = "$work_directory/$filter_filename"; } if ($filter_source eq "PV") { $filter_source_file = "$work_directory/$filter_filename"; } if ($filter_source eq "FL") { $filter_source_file = "$save_directory/$filter_filename.svf"; } if ($filter_source eq "SV") { if ($filter_hash =~ /FlowTracker/) { $TR_saved_directory = substr($filter_link,0,25); $flowtracking = substr($filter_link,26,255); if ($flowtracking =~ /^/) { ($flowtracking,$new_device_extra) = split(/\^/,$flowtracking); } if (-e "$filter_directory/$flowtracking.grp") { $filter_suffix = ".grp"; } if (-e "$filter_directory/$flowtracking.fil") { $filter_suffix = ".fil"; } $filter_filename = $TR_saved_directory ."/". $flowtracking . $filter_suffix; } $filter_source_file = "$save_directory/$filter_filename"; } if ($filter_source eq "TR") { if (-e "$filter_directory/$filter_filename.archive") { $filter_filename .= ".archive"; } if (-e "$filter_directory/$filter_filename.grp") { $filter_filename .= ".grp"; } if (-e "$filter_directory/$filter_filename.fil") { $filter_filename .= ".fil"; } $filter_source_file = "$filter_directory/$filter_filename"; } } open(FILTER,"<$filter_source_file"); while () { chop; if (($filter_source eq "TR") || (($filter_source eq "SV") && ($filter_hash =~ /FlowTracker/))) { $key = substr($_,0,8); if ($key eq " input: ") { ($input,$field,$field_value) = split(/: /); if ($field eq "device_name") { $form_device_name = $field_value; } if ($field eq "Description") { $form_Description = $field_value; } if ($field eq "create_time") { $form_create_time = $field_value; } if ($field eq "start_date") { $form_start_date = $field_value; } if ($field eq "start_time") { $form_start_time = $field_value; } if ($field eq "end_date") { $form_end_date = $field_value; } if ($field eq "end_time") { $form_end_time = $field_value; } if ($field eq "source_addresses") { $form_source_addresses = $field_value; } if ($field eq "source_ports") { $form_source_ports = $field_value; } if ($field eq "source_ifs") { $form_source_ifs = $field_value; } if ($field eq "sif_names") { $form_sif_names = $field_value; } if ($field eq "source_ases") { $form_source_ases = $field_value; } if ($field eq "dest_addresses") { $form_dest_addresses = $field_value; } if ($field eq "dest_ports") { $form_dest_ports = $field_value; } if ($field eq "dest_ifs") { $form_dest_ifs = $field_value; } if ($field eq "dif_names") { $form_dif_names = $field_value; } if ($field eq "dest_ases") { $form_dest_ases = $field_value; } if ($field eq "protocols") { $form_protocols = $field_value; } if ($field eq "tcp_flags") { $form_tcp_flags = $field_value; } if ($field eq "tos_fields") { $form_tos_fields = $field_value; } if ($field eq "exporter") { $form_exporter = $field_value; } if ($field eq "nexthop_ips") { $form_nexthop_ips = $field_value; } if ($field eq "tracking_type") { $form_tracking_type = $field_value; } if ($field eq "tracking_label") { $form_tracking_label = $field_value; } if ($field eq "general_comment") { $form_general_comment = $field_value; } if ($field eq "alert_threshold") { $form_alert_threshold = $field_value; } if ($field eq "alert_frequency") { $form_alert_frequency = $field_value; } if ($field eq "alert_destination") { $form_alert_destination = $field_value; } if ($field eq "sampling_multiplier") { $form_sampling_multiplier = $field_value; } if ($field eq "IPFIX") { $form_IPFIX = $field_value; } if ($field eq "silk_field") { $form_silk_field = $field_value; } if ($field eq "silk_other") { $form_silk_other = $field_value; } } } else { ($field,$field_value) = split(/: /); if (/BEGIN FILTERING/) { $found_parameters = 1; next; } if ($found_parameters) { if (/END FILTERING/) { last; } if ($field eq "filter_title") { $filter_title = $field_value; } if ($field eq "device_name") { $form_device_name = $field_value; } if ($field eq "start_date") { $form_start_date = $field_value; } if ($field eq "start_time") { $form_start_time = $field_value; } if ($field eq "end_date") { $form_end_date = $field_value; } if ($field eq "end_time") { $form_end_time = $field_value; } if ($field eq "source_addresses") { $form_source_addresses = $field_value; } if ($field eq "source_ports") { $form_source_ports = $field_value; } if ($field eq "source_ifs") { $form_source_ifs = $field_value; } if ($field eq "sif_names") { $form_sif_names = $field_value; } if ($field eq "source_ases") { $form_source_ases = $field_value; } if ($field eq "dest_addresses") { $form_dest_addresses = $field_value; } if ($field eq "dest_ports") { $form_dest_ports = $field_value; } if ($field eq "dest_ifs") { $form_dest_ifs = $field_value; } if ($field eq "dif_names") { $form_dif_names = $field_value; } if ($field eq "dest_ases") { $form_dest_ases = $field_value; } if ($field eq "protocols") { $form_protocols = $field_value; } if ($field eq "tcp_flags") { $form_tcp_flags = $field_value; } if ($field eq "tos_fields") { $form_tos_fields = $field_value; } if ($field eq "exporter") { $form_exporter = $field_value; } if ($field eq "nexthop_ips") { $form_nexthop_ips = $field_value; } if ($field eq "tracking_type") { $form_tracking_type = $field_value; } if ($field eq "tracking_label") { $form_tracking_label = $field_value; } if ($field eq "tracking_status") { $form_tracking_status = $field_value; } if ($field eq "general_comment") { $form_general_comment = $field_value; } if ($field eq "sampling_multiplier") { $form_sampling_multiplier = $field_value; } if ($field eq "stat_report") { $form_stat_report = $field_value; } if ($field eq "print_report") { $form_print_report = $field_value; } if ($field eq "flow_select") { $form_flow_select = $field_value; } if ($field eq "sort_field") { $form_sort_field = $field_value; } if ($field eq "pie_charts") { $form_pie_charts= $field_value; } if ($field eq "cutoff_lines") { $form_cutoff_lines = $field_value; } if ($field eq "cutoff_octets") { $form_cutoff_octets = $field_value; } if ($field eq "unit_conversion") { $form_unit_conversion = $field_value; } if ($field eq "detail_lines") { $form_detail_lines = $field_value; } if ($field eq "bucket_size") { $form_bucket_size = $field_value; } if ($field eq "resolve_addresses") { $form_resolve_addresses = $field_value; } if ($field eq "graph_multiplier") { $form_graph_multiplier = $field_value; } if ($field eq "stats_method") { $form_stats_method = $field_value; } if ($field eq "graph_type") { $form_graph_type = $field_value; } if ($field eq "IPFIX") { $form_IPFIX = $field_value; } if ($field eq "silk_field") { $form_silk_field = $field_value; } if ($field eq "silk_other") { $form_silk_other = $field_value; } } } } close(FILTER); } sub get_tracking_title { my ($filter_filename,$suffix) = @_; $check_file = "$filter_directory/$filter_filename.fil"; if (-e $check_file) { $filter_source_file = "$filter_directory/$filter_filename.fil"; } $check_file = "$filter_directory/$filter_filename.grp"; if (-e $check_file) { $filter_source_file = "$filter_directory/$filter_filename.grp"; } $check_file = "$filter_directory/$filter_filename.archive"; if (-e $check_file) { $filter_source_file = "$filter_directory/$filter_filename.archive"; } open(FILTER,"<$filter_source_file"); while () { chop; $key = substr($_,0,8); if ($key eq " input: ") { ($input,$field,$field_value) = split(/: /); if ($field eq "tracking_label") { $tracking_title = $field_value; last; } } } close(FILTER); return $tracking_title; } sub start_saved_file { my ($saved_file) = @_; open (SAVED,">$saved_file"); print SAVED "\n"; close(SAVED); } return 1;