1#!/usr/local/bin/perl 2# 3# Purpose: 4# FlowViewer_UI.pm holds utility functions that are called 5# by FlowViewer, FlowGrapher, and FlowMonitor scripts to create 6# the version 4.0 User Interface. 7# 8# Description: 9# Various user interface utility functions. 10# 11# Input arguments: 12# Name Description 13# ----------------------------------------------------------------------- 14# None 15# 16# Modification history: 17# Author Date Vers. Description 18# ----------------------------------------------------------------------- 19# J. Loiacono 05/08/2012 4.0 Original Version. 20# J. Loiacono 08/07/2013 4.2 Fixed exporter NamedInterfaces [M. Donnelly] 21# J. Loiacono 09/11/2013 4.2.1 Mods to accomodate new Linear processing 22# Mods for international date formatting 23# J. Loiacono 01/26/2014 4.3 Introduced Detect Scanning 24# J. Loiacono 07/04/2014 4.4 Multiple dashboards and Analysis 25# J. Loiacono 11/02/2014 4.5 FlowTracker to FlowMonitor rename 26# Added option to eliminate bottom pulldowns 27# 28#$Author$ 29#$Date$ 30#$Header$ 31# 32########################################################################### 33# 34# BEGIN EXECUTABLE STATEMENTS 35# 36 37use File::stat; 38use Time::Local; 39use Time::HiRes qw( usleep ualarm gettimeofday tv_interval ); 40 41sub create_UI_top { 42 43 my ($active_dashboard) = @_; 44 $active_dashboard =~ s/\\//; 45 46 # Create the top FlowViewer title and Local Information 47 48 print "Content-type:text/html\n\n"; 49 print "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n"; 50 print "\"http://www.w3.org/TR/html4/strict.dtd\">\n\n"; 51 print "<html lang=en>\n"; 52 print "<head>\n"; 53 print "<meta http-equiv=Content-Type content=\"text/html; charset=utf-8\">\n"; 54 print "<title>FlowViewer - Maintaining Network Traffic Situational Awareness</title>\n"; 55 print "<link rel=\"stylesheet\" href=\"$reports_short/FlowViewer.css\" type=\"text/css\">\n"; 56 print "</head>\n"; 57 print "<body>\n"; 58 print "<center>\n"; 59 print "<br>\n"; 60 print "\n"; 61 62 print "<div id=container>\n"; 63 print " <div id=title_left>\n"; 64 if ($active_dashboard ne "Main_Only") { 65 foreach $dashboard_title (@dashboard_titles) { 66 $dashboard_name = $dashboard_title; 67 $dashboard_name =~ s/ /~/; 68 if ($dashboard_name eq $active_dashboard) { next; } 69 $dashboard_link = "$cgi_bin_short/FV.cgi?$dashboard_name"; 70 print " <a href=$dashboard_link><span class=link16>$dashboard_title   </span></a>\n"; 71 } 72 } else { 73 print " <a href=$left_title_link><span class=link16>$left_title</span></a>\n"; 74 } 75 print " </div>\n"; 76 print " <div id=title_right>\n"; 77 if ($active_dashboard ne "Main_Only") { 78 $dashboard_name = $active_dashboard; 79 $dashboard_name =~ s/\~/ /; 80 $dashboard_link = "$cgi_bin_short/FV.cgi?$active_dashboard"; 81 print " <a href=$dashboard_link><span class=link16>Active Dashboard: $dashboard_name</span></a>\n"; 82 } else { 83 print " <a href=$right_title_link><span class=link16>$right_title</span></a>\n"; 84 } 85 print " </div>\n"; 86 print " <div id=title_center>\n"; 87 print " <a href=$cgi_bin_short/FV.cgi><span class=text20>FlowViewer</span></a>\n"; 88 print " <p>\n"; 89 print " <a href=$cgi_bin_short/FV.cgi><span class=text12>Powered by flow-tools and SiLK</span></a>\n"; 90 print " </div>\n"; 91 print "\n"; 92} 93 94sub create_UI_service { 95 96 my ($called_by,$service_location,$active_directory,$filter_hash) = @_; 97 98 print " <div id=$service_location>\n"; 99 100 if ($service_location eq "service_top") { 101 102 @filters = (); @actives = (); @groups = (); @archives = (); 103 @filters = <$filter_directory/*>; 104 foreach $filter_file (@filters) { 105 if ($filter_file =~ /\.fil/) { push (@actives,$filter_file); } 106 elsif ($filter_file =~ /\.grp/) { push (@groups,$filter_file); } 107 elsif ($filter_file =~ /\.archive/) { push (@archives,$filter_file); } 108 } 109 110 @actives = sort(@actives); unshift (@actives,"start_actives"); 111 @groups = sort(@groups); unshift (@groups,"start_groups"); 112 @archives = sort(@archives); unshift (@archives,"start_archives"); 113 @filters = (@actives, @groups, @archives); 114 115 } 116 117 # Create the left-side Active Monitors pulldown 118 119 if (($service_location eq "service_top") || (($service_location eq "service_bottom") && ($use_bottom_pulldowns eq "Y"))) { 120 121 print " <select class=monitors_left name=monitors onchange=window.location.href=this[selectedIndex].value\;>\n"; 122 print " <option selected value=\"\">Select an Active or Archived FlowMonitor</option>\n"; 123 print " <option disabled> </option>\n"; 124 print " <option value=$cgi_bin_short/FlowMonitor_Management.cgi?$active_dashboard^List^> Manage All FlowMonitors</option>\n"; 125 126 foreach $filter_file (@filters) { 127 128 if ($filter_file eq "start_actives") { 129 print " <option disabled> </option>\n"; 130 print " <option disabled>--- Individuals</option>\n"; 131 print " <option disabled> </option>\n"; 132 next; 133 } elsif ($filter_file eq "start_groups") { 134 print " <option disabled> </option>\n"; 135 print " <option disabled>--- Groups</option>\n"; 136 print " <option disabled> </option>\n"; 137 next; 138 } elsif ($filter_file eq "start_archives") { 139 print " <option disabled> </option>\n"; 140 print " <option disabled>--- Archives</option>\n"; 141 print " <option disabled> </option>\n"; 142 next; 143 } 144 145 $monitor_file = $filter_file; 146 $monitor_file =~ s#.*/##; 147 open (FILTER,"<$filter_file"); 148 while (<FILTER>) { 149 chop; 150 $key = substr($_,0,8); 151 if ($key eq " input: ") { 152 ($input,$field,$field_value) = split(/: /); 153 if (($field eq "monitor_label") || ($field eq "tracking_label")) { 154 $ft_monitor_label = $field_value; 155 ($monitor_prefix,$monitor_suffix) = split(/\./,$monitor_file); 156 $ft_filter_hash = "MT_" . $monitor_prefix; 157 print " <option value=$cgi_bin_short/FlowMonitor_Display.cgi?$active_dashboard^filter_hash=$ft_filter_hash>$ft_monitor_label</option>\n"; 158 } 159 } 160 } 161 close(FILTER); 162 } 163 164 print " </select>\n"; 165 166 } else { 167 168 print " <span class=pulldown_spacer></span>\n"; 169 } 170 171 if ($called_by =~ /FlowViewer/) { 172 173 print " <span class=button_lead></span>\n"; 174 if (($called_by =~ /Main/) && ($service_location eq "service_bottom")) { 175 print " <form method=post action=\"$cgi_bin_short/FlowViewer_Save.cgi?$active_dashboard^name_filter^$filter_hash\">\n"; 176 print " <button class=links type=submit>Save Filter</button>\n"; 177 } else { 178 print " <form method=post action=\"$cgi_bin_short/FlowGrapher.cgi?$active_dashboard^filter_hash=$filter_hash\">\n"; 179 print " <button class=links type=submit>FlowGrapher</button>\n"; 180 } 181 print " </form>\n"; 182 print " <span class=button_spacer></span>\n"; 183 print " <form method=post action=\"$cgi_bin_short/FlowViewer.cgi?$active_dashboard^filter_hash=$filter_hash\">\n"; 184 print " <button class=active type=submit>FlowViewer</button>\n"; 185 print " </form>\n"; 186 print " <span class=button_spacer></span>\n"; 187 if (($called_by =~ /Main/) && ($service_location eq "service_bottom")) { 188 print " <form method=post action=\"$cgi_bin_short/FlowViewer_Save.cgi?$active_dashboard^name_report^$filter_hash\">\n"; 189 print " <button class=links type=submit>Save Report</button>\n"; 190 } else { 191 print " <form method=post action=\"$cgi_bin_short/FlowMonitor.cgi?$active_dashboard^filter_hash=$filter_hash\">\n"; 192 print " <button class=links type=submit>FlowMonitor</button>\n"; 193 } 194 print " </form>\n"; 195 196 } elsif ($called_by =~ /FlowGrapher/) { 197 198 print " <span class=button_lead></span>\n"; 199 if (($called_by =~ /Main/) && ($service_location eq "service_bottom")) { 200 print " <form method=post action=\"$cgi_bin_short/FlowViewer_Save.cgi?$active_dashboard^name_filter^$filter_hash\">\n"; 201 print " <button class=links type=submit>Save Filter</button>\n"; 202 } else { 203 print " <form method=post action=\"$cgi_bin_short/FlowViewer.cgi?$active_dashboard^filter_hash=$filter_hash\">\n"; 204 print " <button class=links type=submit>FlowViewer</button>\n"; 205 } 206 print " </form>\n"; 207 print " <span class=button_spacer></span>\n"; 208 print " <form method=post action=\"$cgi_bin_short/FlowGrapher.cgi?$active_dashboard^filter_hash=$filter_hash\">\n"; 209 print " <button class=active type=submit>FlowGrapher</button>\n"; 210 print " </form>\n"; 211 print " <span class=button_spacer></span>\n"; 212 if (($called_by =~ /Main/) && ($service_location eq "service_bottom")) { 213 print " <form method=post action=\"$cgi_bin_short/FlowViewer_Save.cgi?$active_dashboard^name_report^$filter_hash\">\n"; 214 print " <button class=links type=submit>Save Report</button>\n"; 215 } else { 216 print " <form method=post action=\"$cgi_bin_short/FlowMonitor.cgi?$active_dashboard^filter_hash=$filter_hash\">\n"; 217 print " <button class=links type=submit>FlowMonitor</button>\n"; 218 } 219 print " </form>\n"; 220 221 } elsif ($called_by =~ /FlowMonitor/) { 222 223 print " <span class=button_lead></span>\n"; 224 if (($called_by =~ /Display/) && ($service_location eq "service_bottom")) { 225 print " <form method=post action=\"$cgi_bin_short/FlowViewer_Save.cgi?$active_dashboard^name_filter^$filter_hash\">\n"; 226 print " <button class=links type=submit>Save Filter</button>\n"; 227 } else { 228 print " <form method=post action=\"$cgi_bin_short/FlowViewer.cgi?$active_dashboard^filter_hash=$filter_hash\">\n"; 229 print " <button class=links type=submit>FlowViewer</button>\n"; 230 } 231 print " </form>\n"; 232 print " <span class=button_spacer></span>\n"; 233 print " <form method=post action=\"$cgi_bin_short/FlowMonitor.cgi?$active_dashboard^filter_hash=$filter_hash\">\n"; 234 print " <button class=active type=submit>FlowMonitor</button>\n"; 235 print " </form>\n"; 236 print " <span class=button_spacer></span>\n"; 237 if (($called_by =~ /Display/) && ($service_location eq "service_bottom")) { 238 print " <form method=post action=\"$cgi_bin_short/FlowViewer_Save.cgi?$active_dashboard^name_report^$filter_hash\">\n"; 239 print " <button class=links type=submit>Save Report</button>\n"; 240 } else { 241 print " <form method=post action=\"$cgi_bin_short/FlowGrapher.cgi?$active_dashboard^filter_hash=$filter_hash\">\n"; 242 print " <button class=links type=submit>FlowGrapher</button>\n"; 243 } 244 print " </form>\n"; 245 } 246 247 # Create the right-side Saved Reports pulldown 248 249 if (($service_location eq "service_top") || (($service_location eq "service_bottom") && ($use_bottom_pulldowns eq "Y"))) { 250 251 print " <select class=monitors_right name=saved onchange=window.location.href=this[selectedIndex].value;>\n"; 252 print " <option selected value=\"\">Select a Saved Report</option>\n"; 253 print " <option disabled> </option>\n"; 254 print " <option value=$cgi_bin_short/FlowViewer_SaveManage.cgi?$active_dashboard^ListFiles> Manage All Saved Reports</option>\n"; 255 256 @saved_files = (); 257 while ($saved_file = <$save_directory/*>) { 258 259 $info_file = $saved_file; 260 ($directory,$saved_label) = $saved_file =~ m/(.*\/)(.*)$/; 261 $length_label = length($saved_label); 262 $start_suffix = $length_label - 4; 263 $label_suffix = substr($saved_label,$start_suffix,4); 264 if (($label_suffix eq ".svf") || ($label_suffix eq ".png")) { next; } 265 266 if ($saved_label =~ /FlowGrapher/) { 267 $created_initials = "FG"; 268 } elsif ($saved_label =~ /FlowViewer/) { 269 $created_initials = "FV"; 270 } elsif (($saved_label =~ /FlowMonitor/) || ($saved_label =~ /FlowTracker/)) { 271 $created_initials = "FM"; 272 $MT_saved_directory = $save_directory ."/". $saved_label; 273 open(LS,"ls $MT_saved_directory 2>&1|"); 274 while (<LS>) { 275 if ((/\.fil/) || (/\.grp/)) { 276 $info_file = $MT_saved_directory ."/". $_; 277 ($MT_label,$MT_suffix) = split(/\./); 278 $saved_label = $saved_label ."_". $MT_label; 279 } 280 } 281 } elsif ($saved_label =~ /graph/) { 282 $created_initials = "FG"; 283 } else { 284 $created_initials = "FV"; 285 } 286 287 $last_underscore = rindex($saved_label,"_"); $len_label = $last_underscore - 16; 288 $sv_report_name = substr($saved_label,16,$len_label); 289 290 open (SAVED_FILE,"<$info_file"); 291 while (<SAVED_FILE>) { 292 if (/Description/) { 293 chop $_; 294 ($label,$sv_report_name) = split(": ",$_); 295 if (($saved_file =~ /FlowMonitor/) || ($saved_file =~ /FlowTracker/)) { ($input_label,$label,$sv_report_name) = split(": ",$_); } 296 } 297 if (/create_time/) { 298 chop $_; 299 ($label,$create_time) = split(": ",$_); 300 if (($saved_file =~ /FlowMonitor/) || ($saved_file =~ /FlowTracker/)) { ($input_label,$label,$create_time) = split(": ",$_); } 301 } 302 if (/filter_hash/) { 303 chop $_; 304 ($label,$saved_filter_hash) = split(": ",$_); 305 if ($saved_filter_hash =~ /FA/) { $created_initials = "FA"; } 306 last; 307 } 308 } 309 close SAVED_FILE; 310 311 $label_key = substr($saved_label,0,2); 312 if ($label_key eq "20") { 313 $label_stamp = substr($saved_label,0,15); 314 ($label_date,$label_time) = split(/_/,$label_stamp); 315 $label_date = substr($label_date,4,2) ."/". substr($label_date,6,2) ."/". substr($label_date,0,4); 316 $label_time = substr($label_time,0,2) .":". substr($label_time,2,2) .":". substr($label_time,4,2); 317 $last_access = date_to_epoch($label_date,$label_time); 318 } else { 319 $last_access = $create_time; 320 } 321 $saved_listing = $last_access ."^". $saved_label ."^". $sv_report_name ."^". $created_initials; 322 push (@saved_files,$saved_listing); 323 } 324 325 @temp_saved_files = sort (@saved_files); 326 @sorted_saved_files = reverse (@temp_saved_files); 327 328 $last_mn = ""; 329 foreach $sorted_listing (@sorted_saved_files) { 330 ($last_access,$saved_label,$sv_report_name,$created_initials) = split(/\^/,$sorted_listing); 331 if (($saved_label =~ /html/) || (!($saved_label =~ /\./))) { 332 if (($saved_label =~ /index/) || ($sorted_listing eq "")) { next; } 333 $file_date = epoch_to_date($last_access); 334 $mn = substr($file_date,0,2); 335 336 if ($mn ne $last_mn) { print " <option disabled></option>\n"; } 337 338 $sv_report_title = "$file_date    $created_initials    $sv_report_name"; 339 340 if ($saved_label =~ /FlowGrapher/) { 341 print " <option value=$cgi_bin_short/FlowGrapher_Replay.cgi?$active_dashboard^filter_hash=FG_$saved_label>$sv_report_title</option>\n"; 342 } elsif ($saved_label =~ /FlowViewer/) { 343 print " <option value=$cgi_bin_short/FlowViewer_Replay.cgi?$active_dashboard^filter_hash=FV_$saved_label>$sv_report_title</option>\n"; 344 } elsif (($saved_label =~ /FlowMonitor/) || ($saved_label =~ /FlowTracker/)) { 345 print " <option value=$cgi_bin_short/FlowMonitor_Replay.cgi?$active_dashboard^filter_hash=SV_$saved_label>$sv_report_title</option>\n"; 346 } elsif ($saved_label =~ /graph/) { 347 print " <option value=$cgi_bin_short/FlowGrapher_Replay.cgi?$active_dashboard^filter_hash=PV_$saved_label>$sv_report_title</option>\n"; 348 } else { 349 print " <option value=$cgi_bin_short/FlowViewer_Replay.cgi?$active_dashboard^filter_hash=PV_$saved_label>$sv_report_title</option>\n"; 350 } 351 352 $last_mn = $mn; 353 } 354 } 355 356 print " </select>\n"; 357 } 358 359 print " </div>\n"; 360} 361 362sub create_UI_sides { 363 364 my ($active_dashboard) = @_; 365 366 $switch_dashboard = $active_dashboard; 367 $switch_dashboard =~ s/\~/ /; 368 $active_db_directory = $dashboard_directory; 369 for ($i=0;$i<=$#dashboard_titles;$i++) { 370 if (($dashboard_titles[$i] eq $switch_dashboard) && ($i > 0)) { $active_db_directory = $other_dashboards[$i-1]; } 371 } 372 373 while ($dashboard_file = <$active_db_directory/*>) { 374 375 ($directory,$thumbnail_file) = $dashboard_file =~ m/(.*\/)(.*)$/; 376 377 ($th_filter_hash,$suffix) = split(/\./,$thumbnail_file); 378 $last_underscore = rindex($th_filter_hash,"_"); $th_filter_hash = substr($th_filter_hash,0,$last_underscore); 379 $last_underscore = rindex($th_filter_hash,"_"); $th_filter_hash = substr($th_filter_hash,0,$last_underscore); 380 $th_filter_hash = "MT_" . $th_filter_hash; 381 382 $last_slash = rindex($active_db_directory,"/"); 383 $active_short = substr($active_db_directory,$last_slash+1,255); 384 $thumbnail_file = "/$active_short/$thumbnail_file"; 385 386 if ($dashboard_file =~ "_1.png") { 387 $side_thumbnails{pos_1} = $thumbnail_file; 388 $side_hash{pos_1} = $th_filter_hash; } 389 if ($dashboard_file =~ "_2.png") { 390 $side_thumbnails{pos_2} = $thumbnail_file; 391 $side_hash{pos_2} = $th_filter_hash; } 392 if ($dashboard_file =~ "_3.png") { 393 $side_thumbnails{pos_3} = $thumbnail_file; 394 $side_hash{pos_3} = $th_filter_hash; } 395 if ($dashboard_file =~ "_4.png") { 396 $side_thumbnails{pos_4} = $thumbnail_file; 397 $side_hash{pos_4} = $th_filter_hash; } 398 if ($dashboard_file =~ "_5.png") { 399 $side_thumbnails{pos_5} = $thumbnail_file; 400 $side_hash{pos_5} = $th_filter_hash; } 401 if ($dashboard_file =~ "_6.png") { 402 $side_thumbnails{pos_6} = $thumbnail_file; 403 $side_hash{pos_6} = $th_filter_hash; } 404 if ($dashboard_file =~ "_7.png") { 405 $side_thumbnails{pos_7} = $thumbnail_file; 406 $side_hash{pos_7} = $th_filter_hash; } 407 if ($dashboard_file =~ "_8.png") { 408 $side_thumbnails{pos_8} = $thumbnail_file; 409 $side_hash{pos_8} = $th_filter_hash; } 410 } 411 412 # Create the left side with Dashboard FlowMonitor Thumbnails 413 414 print " <div id=left_main>\n"; 415 if ($side_thumbnails{pos_1} ne "") { 416 print " <a href=$cgi_bin_short/FlowMonitor_Display.cgi?$active_dashboard^filter_hash=$side_hash{pos_1}>\n"; 417 print " <img class=linked src=$side_thumbnails{pos_1} border=0></a>\n"; 418 } else { 419 print "                 \n"; 420 print "                 \n"; 421 print "                 \n"; 422 print "                 \n"; 423 print "                 \n"; 424 } 425 if ($side_thumbnails{pos_3} ne "") { 426 print " <a href=$cgi_bin_short/FlowMonitor_Display.cgi?$active_dashboard^filter_hash=$side_hash{pos_3}>\n"; 427 print " <img class=linked src=$side_thumbnails{pos_3} border=0></a>\n"; } 428 if ($side_thumbnails{pos_5} ne "") { 429 print " <a href=$cgi_bin_short/FlowMonitor_Display.cgi?$active_dashboard^filter_hash=$side_hash{pos_5}>\n"; 430 print " <img class=linked src=$side_thumbnails{pos_5} border=0></a>\n"; } 431 if ($side_thumbnails{pos_7} ne "") { 432 print " <a href=$cgi_bin_short/FlowMonitor_Display.cgi?$active_dashboard^filter_hash=$side_hash{pos_7}>\n"; 433 print " <img class=linked src=$side_thumbnails{pos_7} border=0></a>\n"; } 434 print " </div>\n"; 435 436 # Create the right side with Dashboard FlowMonitor Thumbnails 437 438 print " <div id=right_main>\n"; 439 if ($side_thumbnails{pos_2} ne "") { 440 print " <a href=$cgi_bin_short/FlowMonitor_Display.cgi?$active_dashboard^filter_hash=$side_hash{pos_2}>\n"; 441 print " <img class=linked src=$side_thumbnails{pos_2} border=0></a>\n"; 442 } else { 443 print "                 \n"; 444 print "                 \n"; 445 print "                 \n"; 446 print "                 \n"; 447 print "                 \n"; 448 } 449 if ($side_thumbnails{pos_4} ne "") { 450 print " <a href=$cgi_bin_short/FlowMonitor_Display.cgi?$active_dashboard^filter_hash=$side_hash{pos_4}>\n"; 451 print " <img class=linked src=$side_thumbnails{pos_4} border=0></a>\n"; } 452 if ($side_thumbnails{pos_6} ne "") { 453 print " <a href=$cgi_bin_short/FlowMonitor_Display.cgi?$active_dashboard^filter_hash=$side_hash{pos_6}>\n"; 454 print " <img class=linked src=$side_thumbnails{pos_6} border=0></a>\n"; } 455 if ($side_thumbnails{pos_8} ne "") { 456 print " <a href=$cgi_bin_short/FlowMonitor_Display.cgi?$active_dashboard^filter_hash=$side_hash{pos_8}>\n"; 457 print " <img class=linked src=$side_thumbnails{pos_8} border=0></a>\n"; } 458 print " </div>\n"; 459} 460 461sub finish_the_page { 462 463 my ($called_by) = @_; 464 465 # Finish the web page 466 467 print "</div>\n"; 468 print "</body>\n"; 469 print "</html>\n"; 470} 471 472sub create_filtering_form { 473 474 ($called_by,$filter_hash) = @_; 475 476 if ($called_by eq "FlowViewer") { print " <form method=post action=$cgi_bin_short/FlowViewer_Main.cgi>\n"; } 477 if ($called_by eq "FlowGrapher") { print " <form method=post action=$cgi_bin_short/FlowGrapher_Main.cgi>\n"; } 478 if ($called_by eq "FlowMonitor") { print " <form method=post action=$cgi_bin_short/FlowMonitor_Main.cgi>\n"; } 479 if ($called_by eq "FlowMonitor_Sol") { print " <form method=post action=$cgi_bin_short/FlowMonitor_Main.cgi?$active_dashboard^Revise^$filter_hash>\n"; $skip_date = "Y";} 480 481 load_filtering_parameters($called_by,$filter_hash); 482 483 if ($new_device ne "") { $form_device_name = $new_device; } 484 if ($new_exporter ne "") { $form_exporter = $new_exporter; } 485 486 print " <fieldset class=level1>\n"; 487 if ($called_by eq "FlowViewer" ) { print " <legend class=level1> Create a FlowViewer Report</legend>\n"; } 488 if ($called_by eq "FlowGrapher") { print " <legend class=level1> Create a FlowGrapher Report</legend>\n"; } 489 if ($called_by eq "FlowMonitor") { print " <legend class=level1> Create a FlowMonitor</legend>\n"; } 490 if ($called_by =~ "FlowMonitor_Sol") { 491 $monitor_hash = $form_monitor_label; 492 $monitor_hash =~ s/ /~/g; 493 print " <legend class=level1> Revise FlowMonitor: $form_monitor_label</legend>\n"; 494 } 495 print "\n"; 496 497 # List the saved filters in the pulldown 498 499 print " <fieldset class=level2_float>\n"; 500 print " <legend class=level2>Saved Filters</legend>\n"; 501 print " <span class=select>\n"; 502 print " <select class=long name=saved_filter onchange=window.location.href=this[selectedIndex].value\;>\n"; 503 504 if (($filter_source eq "FL") && ($new_device eq "") && ($new_exporter eq "")) { 505 print " <option value=$cgi_bin_short/$called_by.cgi?$active_dashboard^>Select Saved Filter</option>\n"; 506 print " <option disabled> </option>\n"; 507 print " <option value=$cgi_bin_short/FlowViewer_SaveManage.cgi?$active_dashboard^ListFilters> Manage All Saved Filters</option>\n"; 508 print " <option disabled> </option>\n"; 509 } else { 510 print " <option selected>Select Saved Filter</option>\n"; 511 print " <option disabled> </option>\n"; 512 print " <option value=$cgi_bin_short/FlowViewer_SaveManage.cgi?$active_dashboard^ListFilters> Manage All Saved Filters</option>\n"; 513 print " <option disabled> </option>\n"; 514 } 515 516 open(GREP,"grep filter_title $save_directory/\*.svf 2>&1|"); 517 while (<GREP>) { 518 chop; 519 $num_colons = tr/://; 520 if ($num_colons == 1) { 521 ($filter_label,$saved_title) = split(/:/); 522 $filter_label = $saved_title; 523 $filter_label =~ s/^\s+//; 524 $filter_label =~ s/\s+$//; 525 $filter_label =~ s/\&/-/g; 526 $filter_label =~ s/\//-/g; 527 $filter_label =~ s/\(/-/g; 528 $filter_label =~ s/\)/-/g; 529 $filter_label =~ s/\./-/g; 530 $filter_label =~ s/\s+/_/g; 531 $filter_label =~ tr/[A-Z]/[a-z]/; 532 $saved_file = "$save_directory/$filter_label.svf"; 533 } else { 534 ($saved_file,$filter_label,$saved_title) = split(/:/); 535 } 536 $saved_title = substr($saved_title,1,255); 537 if ($saved_title eq "No such file or directory") { $saved_title = "No Filters saved yet"; } 538 ($directory,$file_name) = $saved_file =~ m/(.*\/)(.*)$/; 539 $file_name = substr($file_name,0,-4); 540 $saved_hash = "FL_" . $file_name; 541 if (($filter_source eq "FL") && ($saved_title eq $filter_title)) { 542 print " <option selected value=$cgi_bin_short/$called_by.cgi?$active_dashboard^filter_hash=$saved_hash>$saved_title</option>\n"; 543 } else { 544 print " <option value=$cgi_bin_short/$called_by.cgi?$active_dashboard^filter_hash=$saved_hash>$saved_title</option>\n"; 545 } 546 } 547 close(GREP); 548 549 print " </select>\n"; 550 print " </span>\n"; 551 print " <span class=saved_spacer></span>\n"; 552 print " </fieldset>\n"; 553 print "\n"; 554 555 # Prepare the Device and Exporter pulldowns 556 557 if (($form_device_name eq "") && ($ipfix_default_device ne "")) { $form_device_name = $ipfix_default_device; } 558 559 $IPFIX = 0; 560 foreach $ipfix_device (@ipfix_devices) { 561 if ($form_device_name eq $ipfix_device) { $IPFIX = 1; } 562 } 563 564 print " <fieldset class=level2>\n"; 565 print " <legend class=level2>Netflow Source</legend>\n"; 566 print " <span class=select>\n"; 567 568 if ($IPFIX) { 569 print " <select class=shortie name=device_name onchange=window.location.href=this[selectedIndex].value\;>\n"; 570 } else { 571 print " <select class=med name=device_name onchange=window.location.href=this[selectedIndex].value\;>\n"; 572 } 573 574 if ($form_device_name ne "") { 575 if ($called_by eq "FlowMonitor_Sol") { 576 print " <option value=$cgi_bin_short/FlowMonitor.cgi?$active_dashboard^>Select Device</option>\n"; 577 } else { 578 print " <option value=$cgi_bin_short/$called_by.cgi?$active_dashboard^>Select Device</option>\n"; 579 } 580 print " <option disabled> </option>\n"; 581 } else { 582 if ($called_by eq "FlowMonitor_Sol") { 583 print " <option selected value=$cgi_bin_short/FlowMonitor.cgi?$active_dashboard^>Select Device</option>\n"; 584 } else { 585 print " <option selected value=$cgi_bin_short/$called_by.cgi?$active_dashboard^>Select Device</option>\n"; 586 } 587 print " <option disabled> </option>\n"; 588 } 589 590 @all_devices = (@devices,@ipfix_devices); 591 if ($all_devices[0] ne "") { 592 foreach $all_device_name (@all_devices) { 593 if ($all_device_name eq $form_device_name) { 594 if ($called_by eq "FlowMonitor_Sol") { 595 $device_hash = $monitor_hash ."^DDD". $form_device_name; 596 $option_value = "$cgi_bin_short/FlowMonitor_Management.cgi?$active_dashboard^Solicit^$device_hash"; 597 } else { 598 $device_hash = $filter_hash ."^DDD". $form_device_name; 599 $option_value = "$cgi_bin_short/$called_by.cgi?$active_dashboard^filter_hash=$device_hash"; 600 } 601 print " <option selected value=$option_value>$form_device_name</option>\n"; 602 } else { 603 if ($called_by eq "FlowMonitor_Sol") { 604 $device_hash = $monitor_hash ."^DDD". $all_device_name; 605 $option_value = "$cgi_bin_short/FlowMonitor_Management.cgi?$active_dashboard^Solicit^$device_hash"; 606 } else { 607 $device_hash = $filter_hash ."^DDD". $all_device_name; 608 $option_value = "$cgi_bin_short/$called_by.cgi?$active_dashboard^filter_hash=$device_hash"; 609 } 610 print " <option value=$option_value>$all_device_name</option>\n"; 611 } 612 } 613 } 614 615 print " </select>\n"; 616 print " </span>\n"; 617 618 if ($IPFIX) { 619 620 if (($form_silk_rootdir eq "") || ($new_device ne "")) { 621 $grep_command = "grep path-format $silk_data_directory/silk.conf"; 622 open(GREP,"$grep_command 2>&1|"); 623 while (<GREP>) { 624 chop; 625 ($left_part,$path_format) = split(/path-format/); 626 if ($left_part =~ /\#/) { 627 $form_silk_rootdir = "$silk_data_directory/$form_device_name"; 628 } else { 629 $path_format =~ s/\s+//g; 630 $path_format =~ s/\///g; 631 $path_format =~ s/\"//g; 632 ($left_part,$dir1,$dir2,$dir3,$dir4,$dir5,$dir6,$dir7) = split(/\%/,$path_format); 633 if ($dir1 ne "T") { 634 $form_silk_rootdir = $silk_data_directory; 635 } else { 636 $form_silk_rootdir = "$silk_data_directory/$form_device_name"; 637 } 638 } 639 } 640 } 641 642 if ($form_device_name eq "Site") { $form_silk_rootdir = $silk_data_directory; } 643 644 print " <span class=rootdir_spacer></span>\n"; 645 print " <label class=textin for=silk_rootdir>Data Rootdir:</label>\n"; 646 print " <input class=right_dir type=text name=silk_rootdir value=\"$form_silk_rootdir\">\n"; 647 648 } else { 649 650 print " <span class=source_spacer></span>\n"; 651 print " <span class=select>\n"; 652 print " <select class=med name=exporter onchange=window.location.href=this[selectedIndex].value\;>\n"; 653 654 if ($form_exporter ne "") { 655 if ($called_by eq "FlowMonitor_Sol") { 656 print " <option value=$cgi_bin_short/FlowMonitor.cgi?$active_dashboard>Select Exporter</option>\n"; 657 } else { 658 print " <option value=$cgi_bin_short/$called_by.cgi?$active_dashboard>Select Exporter</option>\n"; 659 } 660 print " <option disabled> </option>\n"; 661 } else { 662 if ($called_by eq "FlowMonitor_Sol") { 663 print " <option selected value=$cgi_bin_short/FlowMonitor.cgi?$active_dashboard>Select Exporter</option>\n"; 664 } else { 665 print " <option selected value=$cgi_bin_short/$called_by.cgi?$active_dashboard>Select Exporter</option>\n"; 666 } 667 print " <option disabled> </option>\n"; 668 } 669 670 if ($exporters[0] ne "") { 671 foreach $exporter_pair (@exporters) { 672 ($exporter_ip,$exporter_name) = split(/:/,$exporter_pair); 673 if ($exporter_ip eq $form_exporter) { 674 if ($called_by eq "FlowMonitor_Sol") { 675 $exporter_hash = $monitor_hash ."^EEE". $form_exporter; 676 $option_value = "$cgi_bin_short/FlowMonitor_Management.cgi?$active_dashboard^Solicit^$exporter_hash"; 677 } else { 678 $exporter_hash = $filter_hash . "^EEE$exporter_ip"; 679 $option_value = "$cgi_bin_short/$called_by.cgi?$active_dashboard^filter_hash=$exporter_hash"; 680 } 681 print " <option selected value=$option_value>$exporter_name</option>\n"; 682 } else { 683 if ($called_by eq "FlowMonitor_Sol") { 684 $exporter_hash = $monitor_hash ."^EEE". $exporter_ip; 685 $option_value = "$cgi_bin_short/FlowMonitor_Management.cgi?$active_dashboard^Solicit^$exporter_hash"; 686 } else { 687 $exporter_hash = $filter_hash ."^EEE". $exporter_ip; 688 $option_value = "$cgi_bin_short/$called_by.cgi?$active_dashboard^filter_hash=$exporter_hash"; 689 } 690 print " <option value=$option_value>$exporter_name</option>\n"; 691 } 692 } 693 } 694 } 695 696 print " </select>\n"; 697 print " </span>\n"; 698 print " </fieldset>\n"; 699 print "\n"; 700 701 # Prepare the Period Start and End times (calculate if not saved.) 702 703 if ($called_by =~ "FlowMonitor") { 704 if ($skip_date ne "Y") { 705 ($sec,$min,$hr,$date,$mnth,$yr,$day,$yr_date,$DST) = localtime(time-$start_offset); 706 $mnth += 1; 707 $yr += 1900; 708 $min_delta = $min % 5; 709 $min = $min - $min_delta; 710 if (length $mnth < 2) { $mnth = "0" . $mnth; } 711 if (length $date < 2) { $date = "0" . $date; } 712 if (length $hr < 2) { $hr = "0" . $hr; } 713 if (length $min < 2) { $min = "0" . $min; } 714 if (length $sec < 2) { $sec = "0" . $sec; } 715 if ($date_format eq "DMY") { 716 $start_date_out = $date ."/". $mnth ."/". $yr; 717 } elsif ($date_format eq "DMY2") { 718 $start_date_out = $date .".". $mnth .".". $yr; 719 } elsif ($date_format eq "YMD") { 720 $start_date_out = $yr ."-". $mnth ."-". $date; 721 } else { 722 $start_date_out = $mnth ."/". $date ."/". $yr; 723 } 724 if ($use_even_hours eq "Y") { 725 $start_time_out = $hr .":00:00"; 726 } else { 727 $start_time_out = $hr .":". $min .":00"; 728 } 729 730 print " <fieldset class=level2>\n"; 731 print " <span class=input_text>\n"; 732 print " <label for=start_date>Start Date</label>\n"; 733 print " <input class=left_date type=text name=start_date value=\"$start_date_out\">\n"; 734 print " </span>\n"; 735 print " <span class=time_spacer></span>\n"; 736 print " <span class=input_text>\n"; 737 print " <label for=start_time>Start Time                    (Adjust this only if Recreating a FlowMonitor)</label>\n"; 738 print " <input class=left_date type=text name=start_time value=\"$start_time_out\">\n"; 739 print " </span>\n"; 740 print " </fieldset>\n"; 741 print "\n"; 742 } else { 743 $skip_date = ""; 744 } 745 746 } else { 747 748 $start_date_out = $form_start_date; 749 $start_time_out = $form_start_time; 750 $end_date_out = $form_end_date; 751 $end_time_out = $form_end_time; 752 753 if ($start_date_out eq "") { 754 755 ($sec,$min,$hr,$date,$mnth,$yr,$day,$yr_date,$DST) = localtime(time-$start_offset); 756 $mnth += 1; 757 $yr += 1900; 758 $min_delta = $min % 5; 759 $min = $min - $min_delta; 760 if (length $mnth < 2) { $mnth = "0" . $mnth; } 761 if (length $date < 2) { $date = "0" . $date; } 762 if (length $hr < 2) { $hr = "0" . $hr; } 763 if (length $min < 2) { $min = "0" . $min; } 764 if (length $sec < 2) { $sec = "0" . $sec; } 765 if ($date_format eq "DMY") { 766 $start_date_out = $date ."/". $mnth ."/". $yr; 767 } elsif ($date_format eq "DMY2") { 768 $start_date_out = $date .".". $mnth .".". $yr; 769 } elsif ($date_format eq "YMD") { 770 $start_date_out = $yr ."-". $mnth ."-". $date; 771 } else { 772 $start_date_out = $mnth ."/". $date ."/". $yr; 773 } 774 if ($use_even_hours eq "Y") { 775 $start_time_out = $hr .":00:00"; 776 } else { 777 $start_time_out = $hr .":". $min .":00"; 778 } 779 780 ($sec,$min,$hr,$date,$mnth,$yr,$day,$yr_date,$DST) = localtime(time-$end_offset); 781 $mnth += 1; 782 $yr += 1900; 783 $min_delta = $min % 5; 784 $min = $min - $min_delta; 785 if (length $mnth < 2) { $mnth = "0" . $mnth; } 786 if (length $date < 2) { $date = "0" . $date; } 787 if (length $hr < 2) { $hr = "0" . $hr; } 788 if (length $min < 2) { $min = "0" . $min; } 789 if (length $sec < 2) { $sec = "0" . $sec; } 790 if ($date_format eq "DMY") { 791 $end_date_out = $date ."/". $mnth ."/". $yr; 792 } elsif ($date_format eq "DMY2") { 793 $end_date_out = $date .".". $mnth .".". $yr; 794 } elsif ($date_format eq "YMD") { 795 $end_date_out = $yr ."-". $mnth ."-". $date; 796 } else { 797 $end_date_out = $mnth ."/". $date ."/". $yr; 798 } 799 if ($use_even_hours eq "Y") { 800 $end_time_out = $hr .":00:00"; 801 } else { 802 $end_time_out = $hr .":". $min .":00"; 803 } 804 } 805 806 print " <fieldset class=level2>\n"; 807 print " <span class=input_text>\n"; 808 print " <label for=start_date>Start Date</label>\n"; 809 print " <input class=left_date type=text name=start_date value=\"$start_date_out\">\n"; 810 print " </span>\n"; 811 print " <span class=time_spacer></span>\n"; 812 print " <span class=input_text>\n"; 813 print " <label for=start_time>Start Time</label>\n"; 814 print " <input class=left_date type=text name=start_time value=\"$start_time_out\">\n"; 815 print " </span>\n"; 816 print " <span class=date_spacer></span>\n"; 817 print " <span class=input_text>\n"; 818 print " <label for=end_date>End Date</label>\n"; 819 print " <input class=left_date type=text name=end_date value=\"$end_date_out\">\n"; 820 print " </span>\n"; 821 print " <span class=time_spacer></span>\n"; 822 print " <span class=input_text>\n"; 823 print " <label for=end_time>End Time</label>\n"; 824 print " <input class=left_date type=text name=end_time value=\"$end_time_out\">\n"; 825 print " </span>\n"; 826 print " </fieldset>\n"; 827 print "\n"; 828 } 829 830 # Prepare the Source related fields 831 832 print " <fieldset class=level2>\n"; 833 print " <span class=input_text_long>\n"; 834 print " <label for=source_address>Source IP Addresses</label>\n"; 835 print " <input class=left_addr type=text name=source_address value=\"$form_source_addresses\">\n"; 836 print " </span>\n"; 837 print " <br><br>\n"; 838 print " <span class=input_text>\n"; 839 print " <label for=source_port>Source Port</label>\n"; 840 print " <input class=left_port type=text name=source_port value=\"$form_source_ports\">\n"; 841 print " </span>\n"; 842 print " <span class=port_spacer></span>\n"; 843 print " <span class=input_text>\n"; 844 print " <label for=source_as>Source AS</label>\n"; 845 print " <input class=left_port type=text name=source_as value=\"$form_source_ases\">\n"; 846 print " </span>\n"; 847 print " <span class=port_spacer></span>\n"; 848 print " <span class=input_text>\n"; 849 print " <label for=source_if>Source I/F</label>\n"; 850 print " <input class=left_port type=text name=source_if value=\"$form_source_ifs\">\n"; 851 print " </span>\n"; 852 print " <span class=port_spacer></span>\n"; 853 854 print " <span class=select>\n"; 855 print " <label for=sif_name>Source IF Name</label>\n"; 856 print " <select class=long name=sif_name></b>\n"; 857 print " <option selected value=\"\">Interface Names\n"; 858 859 if ($form_device_name ne "") { 860 $interfaces_file = "$cgi_bin_directory/NamedInterfaces_Devices"; 861 } elsif ($form_exporter ne "") { 862 $interfaces_file = "$cgi_bin_directory/NamedInterfaces_Exporters"; 863 } 864 865 open (NAMED,"<$interfaces_file"); 866 chomp (@interfaces = <NAMED>); 867 close (NAMED); 868 869 print " <optgroup label=\"Include ...\"></option>\n"; 870 foreach $interface (@interfaces) { 871 if (($interface eq "") || (substr($interface,0,1) eq "#")) { next; } 872 ($device,$interface_index,$interface_name) = split(/:/,$interface); 873 if (($device eq $form_device_name) || ($device eq $form_exporter)) { 874 if ($interface_index eq $form_sif_names) { 875 print " <option selected value=$interface_index>$interface_index $interface_name</option>\n"; 876 } else { 877 print " <option value=$interface_index>$interface_index $interface_name</option>\n"; 878 } 879 } 880 } 881 882 print " <optgroup label=\"Exclude ...\"></option>\n"; 883 foreach $interface (@interfaces) { 884 if ($interface eq "") { next; } 885 ($device,$interface_index,$interface_name) = split(/:/,$interface); 886 $interface_index *= -1; 887 if (($device eq $form_device_name) || ($device eq $form_exporter)) { 888 if ($interface_index eq $form_sif_names) { 889 print " <option selected value=$interface_index>$interface_index $interface_name\n"; 890 } else { 891 print " <option value=$interface_index>$interface_index $interface_name\n"; 892 } 893 } 894 } 895 896 print " </select>\n"; 897 print " </span>\n"; 898 print " </fieldset>\n"; 899 print "\n"; 900 901 # Prepare the Destination related fields 902 903 print " <fieldset class=level2>\n"; 904 print " <span class=input_text_long>\n"; 905 print " <label for=dest_address>Destination IP Addresses</label>\n"; 906 print " <input class=left_addr type=text name=dest_address value=\"$form_dest_addresses\">\n"; 907 print " </span>\n"; 908 print " <br><br>\n"; 909 print " <span class=input_text>\n"; 910 print " <label for=dest_port>Dest Port</label>\n"; 911 print " <input class=left_port type=text name=dest_port value=\"$form_dest_ports\">\n"; 912 print " </span>\n"; 913 print " <span class=port_spacer></span>\n"; 914 print " <span class=input_text>\n"; 915 print " <label for=dest_as>Dest AS</label>\n"; 916 print " <input class=left_port type=text name=dest_as value=\"$form_dest_ases\">\n"; 917 print " </span>\n"; 918 print " <span class=port_spacer></span>\n"; 919 print " <span class=input_text>\n"; 920 print " <label for=dest_if>Dest I/F</label>\n"; 921 print " <input class=left_port type=text name=dest_if value=\"$form_dest_ifs\">\n"; 922 print " </span>\n"; 923 print " <span class=port_spacer></span>\n"; 924 925 print " <span class=select>\n"; 926 print " <label for=dif_name>Dest IF Name</label>\n"; 927 print " <select class=long name=dif_name></b>\n"; 928 print " <option selected value=\"\">Interface Names\n"; 929 930 print " <optgroup label=\"Include ...\"></option>\n"; 931 foreach $interface (@interfaces) { 932 if (($interface eq "") || (substr($interface,0,1) eq "#")) { next; } 933 ($device,$interface_index,$interface_name) = split(/:/,$interface); 934 if (($device eq $form_device_name) || ($device eq $form_exporter)) { 935 if ($interface_index eq $form_dif_names) { 936 print " <option selected value=$interface_index>$interface_index $interface_name</option>\n"; 937 } else { 938 print " <option value=$interface_index>$interface_index $interface_name</option>\n"; 939 } 940 } 941 } 942 943 print " <optgroup label=\"Exclude ...\"></option>\n"; 944 foreach $interface (@interfaces) { 945 if ($interface eq "") { next; } 946 ($device,$interface_index,$interface_name) = split(/:/,$interface); 947 $interface_index *= -1; 948 if (($device eq $form_device_name) || ($device eq $form_exporter)) { 949 if ($interface_index eq $form_dif_names) { 950 print " <option selected value=$interface_index>$interface_index $interface_name\n"; 951 } else { 952 print " <option value=$interface_index>$interface_index $interface_name\n"; 953 } 954 } 955 } 956 957 print " </select>\n"; 958 print " </span>\n"; 959 print " </fieldset>\n"; 960 print "\n"; 961 962 # Prepare the Additional Fields 963 964 print " <fieldset class=level2>\n"; 965 print " <span class=input_text>\n"; 966 print " <label for=tos_fields>TOS Field</label>\n"; 967 print " <input class=left_port type=text name=tos_fields value=\"$form_tos_fields\">\n"; 968 print " </span>\n"; 969 print " <span class=port_spacer></span>\n"; 970 print " <span class=input_text>\n"; 971 print " <label for=tcp_flags>TCP Flags</label>\n"; 972 print " <input class=left_port type=text name=tcp_flags value=\"$form_tcp_flags\">\n"; 973 print " </span>\n"; 974 print " <span class=port_spacer></span>\n"; 975 print " <span class=input_text>\n"; 976 print " <label for=protocols>Protocol</label>\n"; 977 print " <input class=left_port type=text name=protocols value=\"$form_protocols\">\n"; 978 print " </span>\n"; 979 print " <span class=port_spacer></span>\n"; 980 print " <span class=input_text>\n"; 981 print " <label for=nexthop_ip>NextHop IPs</label>\n"; 982 print " <input class=left_next type=text name=nexthop_ip value=\"$form_nexthop_ip\">\n"; 983 print " </span>\n"; 984 print " </fieldset>\n"; 985} 986 987sub create_reporting_form { 988 989 $IPFIX = 0; 990 foreach $ipfix_device (@ipfix_devices) { 991 if ($form_device_name eq $ipfix_device) { $IPFIX = 1; } 992 } 993 994 print " <fieldset class=level2>\n"; 995 print " <legend class=level2>Reporting Parameters</legend>\n"; 996 print " <span class=select>\n"; 997 print " <label for=stat_report>Statistics Reports</label>\n"; 998 print " <select class=long name=stat_report></b>\n"; 999 print " <option value=0>Select Statistics Report"; 1000 print " <option disabled> </option>\n"; 1001 1002 if ($form_stat_report eq "") { $form_stat_report = $default_report; } 1003 if ($form_stat_report == 99) { print " <option value=99 selected>Summary\n"; } 1004 else { print " <option value=99>Summary\n"; } 1005 if ($form_stat_report == 30) { print " <option value=30 selected>Detect Scanning\n"; } 1006 else { print " <option value=30>Detect Scanning\n"; } 1007 if ($form_stat_report == 6) { print " <option value=6 selected>UDP/TCP Source Port\n"; } 1008 else { print " <option value=6>UDP/TCP Source Port\n"; } 1009 if ($form_stat_report == 5) { print " <option value=5 selected>UDP/TCP Destination Port\n"; } 1010 else { print " <option value=5>UDP/TCP Destination Port\n"; } 1011 if ($form_stat_report == 7) { print " <option value=7 selected>UDP/TCP Port\n"; } 1012 else { print " <option value=7>UDP/TCP Port\n"; } 1013 if ($form_stat_report == 8) { print " <option value=8 selected>Destination IP\n"; } 1014 else { print " <option value=8>Destination IP\n"; } 1015 if ($form_stat_report == 9) { print " <option value=9 selected>Source IP\n"; } 1016 else { print " <option value=9>Source IP\n"; } 1017 if ($form_stat_report == 10) { print " <option value=10 selected>Source/Destination IP\n"; } 1018 else { print " <option value=10>Source/Destination IP\n"; } 1019 if ($form_stat_report == 11) { print " <option value=11 selected>Source or Destination IP\n"; } 1020 else { print " <option value=11>Source or Destination IP\n"; } 1021 if ($form_stat_report == 12) { print " <option value=12 selected>IP Protocol\n"; } 1022 else { print " <option value=12>IP Protocol\n"; } 1023 if ($form_stat_report == 17) { print " <option value=17 selected>Input Interface\n"; } 1024 else { print " <option value=17>Input Interface\n"; } 1025 if ($form_stat_report == 18) { print " <option value=18 selected>Output Interface\n"; } 1026 else { print " <option value=18>Output Interface\n"; } 1027 if ($form_stat_report == 23) { print " <option value=23 selected>Input/Output Interface\n"; } 1028 else { print " <option value=23>Input/Output Interface\n"; } 1029 if ($form_stat_report == 19) { print " <option value=19 selected>Source AS\n"; } 1030 else { print " <option value=19>Source AS\n"; } 1031 if ($form_stat_report == 20) { print " <option value=20 selected>Destination AS\n"; } 1032 else { print " <option value=20>Destination AS\n"; } 1033 if ($form_stat_report == 21) { print " <option value=21 selected>Source/Destination AS\n"; } 1034 else { print " <option value=21>Source/Destination AS\n"; } 1035 if ($form_stat_report == 22) { print " <option value=22 selected>IP ToS\n"; } 1036 else { print " <option value=22>IP ToS\n"; } 1037 if ($form_stat_report == 24) { print " <option value=24 selected>Source Prefix\n"; } 1038 else { print " <option value=24>Source Prefix\n"; } 1039 if ($form_stat_report == 25) { print " <option value=25 selected>Destination Prefix\n"; } 1040 else { print " <option value=25>Destination Prefix\n"; } 1041 if ($form_stat_report == 26) { print " <option value=26 selected>Source/Destination Prefix\n"; } 1042 else { print " <option value=26>Source/Destination Prefix\n"; } 1043 if ($form_stat_report == 27) { print " <option value=27 selected>Exporter IP\n"; } 1044 else { print " <option value=27>Exporter IP\n"; } 1045 1046 print " </select>\n"; 1047 print " </span>\n"; 1048 print " <span class=port_spacer></span>\n"; 1049 print " <span class=select>\n"; 1050 print " <label for=print_report>Printed Reports</label>\n"; 1051 print " <select class=long name=print_report></b>\n"; 1052 1053 if ($form_print_report ne "") { 1054 print " <option value=0 >Select Print Report"; 1055 print " <option disabled> </option>\n"; 1056 } else { 1057 print " <option value=0 selected>Select Print Report"; 1058 print " <option disabled> </option>\n"; 1059 } 1060 1061 if ($form_print_report == 1) { print " <option value=1 selected>Flow Times\n"; } 1062 else { print " <option value=1>Flow Times\n"; } 1063 if ($form_print_report == 4) { print " <option value=4 selected>AS Numbers\n"; } 1064 else { print " <option value=4>AS Numbers\n"; } 1065 if ($form_print_report == 5) { print " <option value=5 selected>132 Columns\n"; } 1066 else { print " <option value=5>132 Columns\n"; } 1067 if ($form_print_report == 9) { print " <option value=9 selected>1 Line with Tags\n"; } 1068 else { print " <option value=9>1 Line with Tags\n"; } 1069 if ($form_print_report == 10) { print " <option value=10 selected>AS Aggregation\n"; } 1070 else { print " <option value=10>AS Aggregation\n"; } 1071 if ($form_print_report == 11) { print " <option value=11 selected>Protocol Port Aggregation\n"; } 1072 else { print " <option value=11>Protocol Port Aggregation\n"; } 1073 if ($form_print_report == 12) { print " <option value=12 selected>Source Prefix Aggregation\n"; } 1074 else { print " <option value=12>Source Prefix Aggregation\n"; } 1075 if ($form_print_report == 13) { print " <option value=13 selected>Destination Prefix Aggregation\n"; } 1076 else { print " <option value=13>Destination Prefix Aggregation\n"; } 1077 if ($form_print_report == 14) { print " <option value=14 selected>Prefix Aggregation\n"; } 1078 else { print " <option value=14>Prefix Aggregation\n"; } 1079 if ($form_print_report == 15) { print " <option value=15 selected>Source Prefix Aggregation v6\n"; } 1080 else { print " <option value=15>Source Prefix Aggregation v6\n"; } 1081 if ($form_print_report == 16) { print " <option value=16 selected>Destination Prefix Aggregation v6\n"; } 1082 else { print " <option value=16>Destination Prefix Aggregation v6\n"; } 1083 if ($form_print_report == 17) { print " <option value=17 selected>Prefix Aggregation v6\n"; } 1084 else { print " <option value=17>Prefix Aggregation v6\n"; } 1085 if ($form_print_report == 24) { print " <option value=24 selected>Full Catalyst\n"; } 1086 else { print " <option value=24>Full Catalyst\n"; } 1087 1088 print " </select>\n"; 1089 print " </span>\n"; 1090 print " <span class=flow_spacer></span>\n"; 1091 1092 print " <span class=select>\n"; 1093 print " <label for=flow_analysis>Flow Analysis</label>\n"; 1094 print " <select class=shortie name=flow_analysis></b>\n"; 1095 1096 if ($form_flow_analysis eq "") { $form_flow_analysis = $default_flows; } 1097 if (($form_flow_analysis eq "") || ($form_flow_analysis == 0)) { print " <option value=0 selected>Off\n"; } 1098 else { print " <option value=0>Off\n"; } 1099 if ($form_flow_analysis == 1) { print " <option value=1 selected>On\n"; } 1100 else { print " <option value=1>On\n"; } 1101 1102 print " </select>\n"; 1103 print " </span>\n"; 1104 print " <br><br><br>\n"; 1105 1106 print " <span class=select>\n"; 1107 print " <label for=flow_select>Include Flow If:</label>\n"; 1108 print " <select class=long name=flow_select></b>\n"; 1109 1110 if (($form_flow_select eq "") || ($form_flow_select == 1)) { print " <option value=1 selected>Any Part in Specified Time Span\n"; } 1111 else { print " <option value=1>Any Part in Specified Time Span\n"; } 1112 if ($form_flow_select == 2) { print " <option value=1 selected>End Time in Specified Time Span\n"; } 1113 else { print " <option value=2>End Time in Specified Time Span\n"; } 1114 if ($form_flow_select == 3) { print " <option value=1 selected>Start Time in Specified Time Span\n"; } 1115 else { print " <option value=3>Start Time in Specified Time Span\n"; } 1116 if ($form_flow_select == 4) { print " <option value=1 selected>Entirely in Specified Time Span\n"; } 1117 else { print " <option value=4>Entirely in Specified Time Span\n"; } 1118 1119 print " </select>\n"; 1120 print " </span>\n"; 1121 print " <span class=port_spacer></span>\n"; 1122 1123 print " <span class=input_text>\n"; 1124 print " <label for=cutoff_lines>Cutoff Lines</label>\n"; 1125 if ($form_cutoff_lines eq "") { $form_cutoff_lines = $default_lines; } 1126 print " <input class=left_port type=text name=cutoff_lines value=\"$form_cutoff_lines\">\n"; 1127 print " </span>\n"; 1128 print " <span class=port_spacer></span>\n"; 1129 1130 print " <span class=input_text>\n"; 1131 print " <label for=cutoff_octets>Cutoff Octets</label>\n"; 1132 print " <input class=left_port type=text name=cutoff_octets value=\"$form_cutoff_octets\">\n"; 1133 print " </span>\n"; 1134 print " <span class=port_spacer></span>\n"; 1135 1136 print " <span class=input_text>\n"; 1137 print " <label for=sampling_multiplier>Sampling Multi</label>\n"; 1138 print " <input class=left_port type=text name=sampling_multiplier value=\"$form_sampling_multiplier\">\n"; 1139 print " </span>\n"; 1140 print " <br><br><br>\n"; 1141 1142 print " <span class=select>\n"; 1143 print " <label for=pie_charts>Pie Charts</label>\n"; 1144 print " <select class=short name=pie_charts></b>\n"; 1145 1146 if ($form_pie_charts eq "") { $form_pie_charts = $pie_chart_default; } 1147 if (($form_pie_charts eq "") || ($form_pie_charts == 0)) { print " <option value=0 selected>None\n"; } 1148 else { print " <option value=0>None\n"; } 1149 if ($form_pie_charts == 1) { print " <option value=1 selected>With Others\n"; } 1150 else { print " <option value=1>With Others\n"; } 1151 if ($form_pie_charts == 2) { print " <option value=2 selected>Without Others\n"; } 1152 else { print " <option value=2>Without Others\n"; } 1153 1154 print " </select>\n"; 1155 print " </span>\n"; 1156 print " <span class=port_spacer></span>\n"; 1157 1158 print " <span class=select>\n"; 1159 print " <label for=resolve_addresses>Resolve Addresses</label>\n"; 1160 print " <select class=short name=resolve_addresses></b>\n"; 1161 1162 if ($default_identifier eq "DNS") { 1163 if (($form_resolve_addresses eq "") || ($form_resolve_addresses eq "Y")) { print " <option value=Y selected>DNS Names\n"; } 1164 else { print " <option value=Y>DNS Names\n"; } 1165 if ($form_resolve_addresses eq "N") { print " <option value=N selected>IP Addresses\n"; } 1166 else { print " <option value=N>IP Addresses\n"; } 1167 } else { 1168 if (($form_resolve_addresses eq "") || ($form_resolve_addresses eq "N")) { print " <option value=N selected>IP Addresses\n"; } 1169 else { print " <option value=N>IP Addresses\n"; } 1170 if ($form_resolve_addresses eq "Y") { print " <option value=Y selected>DNS Names\n"; } 1171 else { print " <option value=Y>DNS Names\n"; } 1172 } 1173 1174 print " </select>\n"; 1175 print " </span>\n"; 1176 print " <span class=port_spacer></span>\n"; 1177 1178 print " <span class=select>\n"; 1179 print " <label for=unit_conversion>Octet Units</label>\n"; 1180 print " <select class=short name=unit_conversion></b>\n"; 1181 1182 if (($form_unit_conversion eq "") || ($form_unit_conversion eq "Y")) { print " <option value=Y selected>Use Units\n"; } 1183 else { print " <option value=Y>Use Units\n"; } 1184 if ($form_unit_conversion eq "N") { print " <option value=N selected>Numeric Only\n"; } 1185 else { print " <option value=N>Numeric Only\n"; } 1186 1187 print " </select>\n"; 1188 print " </span>\n"; 1189 print " <span class=port_spacer></span>\n"; 1190 1191 print " <span class=select>\n"; 1192 print " <label for=sort_field>Sort Field</label>\n"; 1193 print " <select class=short name=sort_field></b>\n"; 1194 1195 if (($form_sort_field eq "") || ($form_sort_field == 1)) { print " <option value=1 selected>Octets\n"; } 1196 else { print " <option value=1>Octets\n"; } 1197 if (($form_sort_field == 2) || ($form_monitor_type =~ /fps/)) { print " <option value=2 selected>Flows\n"; } 1198 else { print " <option value=2>Flows\n"; } 1199 if (($form_sort_field == 3) || ($form_monitor_type =~ /pps/)) { print " <option value=3 selected>Packets\n"; } 1200 else { print " <option value=3>Packets\n"; } 1201 1202 print " </select>\n"; 1203 print " </span>\n"; 1204 print " </fieldset>\n"; 1205} 1206 1207sub create_graphing_form { 1208 1209 $IPFIX = 0; 1210 foreach $ipfix_device (@ipfix_devices) { 1211 if ($form_device_name eq $ipfix_device) { $IPFIX = 1; } 1212 } 1213 1214 print " <fieldset class=level2>\n"; 1215 print " <legend class=level2>Graphing Parameters</legend>\n"; 1216 1217 print " <span class=select>\n"; 1218 print " <label for=flow_select>Include Flow If:</label>\n"; 1219 print " <select class=long name=flow_select></b>\n"; 1220 1221 if (($form_flow_select eq "") || ($form_flow_select == 1)) { print " <option value=1 selected>Any Part in Specified Time Span\n"; } 1222 else { print " <option value=1>Any Part in Specified Time Span\n"; } 1223 if ($form_flow_select == 2) { print " <option value=1 selected>End Time in Specified Time Span\n"; } 1224 else { print " <option value=2>End Time in Specified Time Span\n"; } 1225 if ($form_flow_select == 3) { print " <option value=1 selected>Start Time in Specified Time Span\n"; } 1226 else { print " <option value=3>Start Time in Specified Time Span\n"; } 1227 if ($form_flow_select == 4) { print " <option value=1 selected>Any Part in Specified Time Span\n"; } 1228 else { print " <option value=4>Entirely in Specified Time Span\n"; } 1229 1230 print " </select>\n"; 1231 print " </span>\n"; 1232 print " <span class=port_spacer></span>\n"; 1233 1234 print " <span class=select>\n"; 1235 print " <label for=graph_type>Graph Type</label>\n"; 1236 print " <select class=med name=graph_type></b>\n"; 1237 1238 if ($form_graph_type eq "") { $form_graph_type = $default_graph; } 1239 if (($form_graph_type eq "bps") || ($form_monitor_type =~ "bps")) { print " <option value=bps selected>Bits/Second\n"; } 1240 else { print " <option value=bps>Bits/Second\n"; } 1241 if (($form_graph_type eq "pps") || ($form_monitor_type =~ "pps")) { print " <option value=pps selected>Packets/Second\n"; } 1242 else { print " <option value=pps>Packets/Second\n"; } 1243 if (($form_graph_type eq "fpsi") || ($form_monitor_type eq "fpsi") || ($form_monitor_type eq "Individual-fps")) { print " <option value=fpsi selected>Flows Initiated/Second\n"; } 1244 else { print " <option value=fpsi>Flows Initiated/Second\n"; } 1245 if (($form_graph_type eq "fpsa") || ($form_monitor_type eq "fpsa") || ($form_monitor_type =~ "fps-prorated")) { print " <option value=fpsa selected>Flows Active/Second\n"; } 1246 else { print " <option value=fpsa>Flows Active/Second\n"; } 1247 if ($form_graph_type eq "bpsa") { print " <option value=bpsa selected>Bits/Second - Analysis\n"; } 1248 else { print " <option value=bpsa>Bits/Second - Analysis\n"; } 1249 if ($form_graph_type eq "ppsa") { print " <option value=ppsa selected>Packets/Second - Analysis\n"; } 1250 else { print " <option value=ppsa>Packets/Second - Analysis\n"; } 1251 if ($form_graph_type eq "fpsia") { print " <option value=fpsia selected>Flows Initiated/Second - Analysis\n"; } 1252 else { print " <option value=fpsia>Flows Initiated/Second - Analysis\n"; } 1253 if ($form_graph_type eq "fpsaa") { print " <option value=fpsaa selected>Flows Active/Second - Analysis\n"; } 1254 else { print " <option value=fpsaa>Flows Active/Second - Analysis\n"; } 1255 1256 print " </select>\n"; 1257 print " </span>\n"; 1258 print " <span class=port_spacer></span>\n"; 1259 1260 print " <span class=select>\n"; 1261 print " <label for=stats_method>Statistics From</label>\n"; 1262 print " <select class=med name=stats_method></b>\n"; 1263 1264 if (($form_stats_method eq "") || ($form_stats_method eq "Nonzeroes")) { print " <option value=Nonzeroes selected>Nonzero Values\n"; } 1265 else { print " <option value=Nonzeroes>Nonzero Values\n"; } 1266 if ($form_stats_method eq "All") { print " <option value=All selected>All Values\n"; } 1267 else { print " <option value=All>All Values\n"; } 1268 1269 print " </select>\n"; 1270 print " </span>\n"; 1271 print " <br><br>\n"; 1272 1273 print " <span class=select>\n"; 1274 print " <label for=resolve_addresses>Resolve Addresses</label>\n"; 1275 print " <select class=short name=resolve_addresses></b>\n"; 1276 1277 if ($default_identifier eq "DNS") { 1278 if (($form_resolve_addresses eq "") || ($form_resolve_addresses eq "Y")) { print " <option value=Y selected>DNS Names\n"; } 1279 else { print " <option value=Y>DNS Names\n"; } 1280 if ($form_resolve_addresses eq "N") { print " <option value=N selected>IP Addresses\n"; } 1281 else { print " <option value=N>IP Addresses\n"; } 1282 } else { 1283 if (($form_resolve_addresses eq "") || ($form_resolve_addresses eq "N")) { print " <option value=N selected>IP Addresses\n"; } 1284 else { print " <option value=N>IP Addresses\n"; } 1285 if ($form_resolve_addresses eq "Y") { print " <option value=Y selected>DNS Names\n"; } 1286 else { print " <option value=Y>DNS Names\n"; } 1287 } 1288 1289 print " </select>\n"; 1290 print " </span>\n"; 1291 print " <span class=port_spacer></span>\n"; 1292 1293 print " <span class=select>\n"; 1294 print " <label for=graph_multiplier>Graph Width</label>\n"; 1295 print " <select class=shorter name=graph_multiplier></b>\n"; 1296 1297 if (($form_graph_multiplier eq "") || ($form_graph_multiplier eq "1")) { print " <option value=1 selected>1\n"; } 1298 else { print " <option value=1>1\n"; } 1299 if ($form_graph_multiplier eq "2") { print " <option value=2 selected>2\n"; } 1300 else { print " <option value=2>2\n"; } 1301 if ($form_graph_multiplier eq "3") { print " <option value=3 selected>3\n"; } 1302 else { print " <option value=3>3\n"; } 1303 if ($form_graph_multiplier eq "4") { print " <option value=4 selected>4\n"; } 1304 else { print " <option value=4>4\n"; } 1305 1306 print " </select>\n"; 1307 print " </span>\n"; 1308 print " <span class=port_spacer></span>\n"; 1309 1310 print " <span class=select>\n"; 1311 print " <label for=bucket_size>Bucket Size</label>\n"; 1312 print " <select class=shorter name=bucket_size></b>\n"; 1313 1314 if ($form_bucket_size eq "1") { print " <option value=1 selected>1\n"; } 1315 else { print " <option value=1>1\n"; } 1316 if ($form_bucket_size eq "2") { print " <option value=2 selected>2\n"; } 1317 else { print " <option value=2>2\n"; } 1318 if ($form_bucket_size eq "3") { print " <option value=3 selected>3\n"; } 1319 else { print " <option value=3>3\n"; } 1320 if ($form_bucket_size eq "4") { print " <option value=4 selected>4\n"; } 1321 else { print " <option value=4>4\n"; } 1322 if (($form_bucket_size eq "5") || ($form_bucket_size eq "")) { print " <option value=5 selected>5\n"; } 1323 else { print " <option value=5>5\n"; } 1324 if ($form_bucket_size eq "10") { print " <option value=10 selected>10\n"; } 1325 else { print " <option value=10>10\n"; } 1326 if ($form_bucket_size eq "15") { print " <option value=15 selected>15\n"; } 1327 else { print " <option value=15>15\n"; } 1328 if ($form_bucket_size eq "30") { print " <option value=30 selected>30\n"; } 1329 else { print " <option value=30>30\n"; } 1330 if ($form_bucket_size eq "60") { print " <option value=60 selected>60\n"; } 1331 else { print " <option value=60>60\n"; } 1332 if ($form_bucket_size eq "300") { print " <option value=300 selected>300\n"; } 1333 else { print " <option value=300>300\n"; } 1334 if ($form_bucket_size eq "300E") { print " <option value=300E selected>300E\n"; } 1335 else { print " <option value=300E>300E\n"; } 1336 1337 print " </select>\n"; 1338 print " </span>\n"; 1339 print " <span class=port_spacer></span>\n"; 1340 1341 print " <span class=input_text>\n"; 1342 print " <label for=sampling_multiplier>Sampling Multi</label>\n"; 1343 print " <input class=left_graph type=text name=sampling_multiplier value=\"$form_sampling_multiplier\" id=sampling_multiplier>\n"; 1344 print " </span>\n"; 1345 1346 print " </select>\n"; 1347 print " </span>\n"; 1348 print " <span class=port_spacer></span>\n"; 1349 1350 print " <span class=input_text>\n"; 1351 print " <label for=detail_lines>Detail Lines</label>\n"; 1352 if ($form_detail_lines eq "") { $form_detail_lines = $detail_lines; } 1353 print " <input class=left_graph type=text align=right name=detail_lines value=\"$form_detail_lines\" id=detail_lines>\n"; 1354 print " </span>\n"; 1355 1356 print " </select>\n"; 1357 print " </span>\n"; 1358 print " </fieldset>\n"; 1359} 1360 1361sub create_monitor_form { 1362 1363 $IPFIX = 0; 1364 foreach $ipfix_device (@ipfix_devices) { 1365 if ($form_device_name eq $ipfix_device) { $IPFIX = 1; } 1366 } 1367 1368 print " <fieldset class=level2>\n"; 1369 print " <legend class=level2>Monitor Parameters</legend>\n"; 1370 1371 print " <span class=input_text>\n"; 1372 print " <label for=monitor_label>Monitor Label</label>\n"; 1373 print " <input class=left_monitor type=text name=monitor_label value=\"$form_monitor_label\">\n"; 1374 print " </span>\n"; 1375 print " <span class=port_spacer></span>\n"; 1376 1377 print " <span class=select>\n"; 1378 print " <label for=monitor_type>Monitor Type</label>\n"; 1379 print " <select class=med name=monitor_type></b>\n"; 1380 if (($form_monitor_type eq "") || ($form_monitor_type eq "Individual") || ($form_monitor_type eq "bps")) { print " <option value=bps selected>Bits/Second</option>\n"; } 1381 else { print " <option value=bps>Bits/Second</option>\n"; } 1382 if (($form_graph_type =~ /pps/) || ($form_monitor_type eq "pps")) { print " <option value=pps selected>Packets/Second</option>\n"; } 1383 else { print " <option value=pps>Packets/Second</option>\n"; } 1384 if (($form_graph_type =~ /fpsi/) || ($form_monitor_type eq "fpsi")) { print " <option value=fpsi selected>Flows Initiated/Second</option>\n"; } 1385 else { print " <option value=fpsi>Flows Initiated/Second</option>\n"; } 1386 if (($form_graph_type =~ /fpsa/) || ($form_monitor_type eq "fpsa")) { print " <option value=fpsa selected>Flows Active/Second</option>\n"; } 1387 else { print " <option value=fpsa>Flows Active/Second</option>\n"; } 1388 if ($form_monitor_type eq "Group") { print " <option value=Group selected>Group</option>\n"; } 1389 else { print " <option value=Group>Group</option>\n"; } 1390 print " </select>\n"; 1391 print " </span>\n"; 1392 print " <span class=port_spacer></span>\n"; 1393 1394 print " <span class=input_text>\n"; 1395 print " <label for=sampling_multiplier>Sampling Multi</label>\n"; 1396 print " <input class=left_port type=text name=sampling_multiplier value=\"$form_sampling_multiplier\">\n"; 1397 print " </span>\n"; 1398 print " <br><br>\n"; 1399 1400 print " <span class=input_text>\n"; 1401 print " <label for=alert_destination>Alert Destination (email address)</label>\n"; 1402 print " <input class=left_monitor type=text name=alert_destination value=\"$form_alert_destination\">\n"; 1403 print " </span>\n"; 1404 print " <span class=port_spacer></span>\n"; 1405 1406 print " <span class=select>\n"; 1407 print " <label for=alert_frequency>Alert Frequency</label>\n"; 1408 print " <select class=med name=alert_frequency></b>\n"; 1409 if (($form_alert_frequency eq "") || ($form_alert_frequency eq "none")) { print " <option value=none selected>No Notification</option>\n"; } 1410 else { print " <option value=none>No Notification</option>\n"; } 1411 if ($form_alert_frequency eq "daily") { print " <option value=daily selected>Single miss - Once a Day</option>\n"; } 1412 else { print " <option value=daily>Single miss - Once a Day</option>\n"; } 1413 if ($form_alert_frequency eq "daily3") { print " <option value=daily3 selected>3 Consecutive - Once a Day</option>\n"; } 1414 else { print " <option value=daily3>3 Consecutive - Once a Day</option>\n"; } 1415 if ($form_alert_frequency eq "daily6") { print " <option value=daily6 selected>6 Consecutive - Once a Day</option>\n"; } 1416 else { print " <option value=daily6>6 Consecutive - Once a Day</option>\n"; } 1417 if ($form_alert_frequency eq "daily12") { print " <option value=daily12 selected>12 Consecutive - Once a Day</option>\n"; } 1418 else { print " <option value=daily12>12 Consecutive - Once a Day</option>\n"; } 1419 if ($form_alert_frequency eq "eachtime") { print " <option value=eachtime selected>Single miss - Each Occurence</option>\n"; } 1420 else { print " <option value=eachtime>Single miss - Each Occurrence</option>\n"; } 1421 if ($form_alert_frequency eq "eachtime3") { print " <option value=eachtime3 selected>3 Consecutive - Each Occurence</option>\n"; } 1422 else { print " <option value=eachtime3>3 Consecutive - Each Occurrence</option>\n"; } 1423 if ($form_alert_frequency eq "eachtime6") { print " <option value=eachtime6 selected>6 Consecutive - Each Occurence</option>\n"; } 1424 else { print " <option value=eachtime6>6 Consecutive - Each Occurrence</option>\n"; } 1425 if ($form_alert_frequency eq "eachtime12") { print " <option value=eachtime12 selected>12 Consecutive - Each Occurence</option>\n"; } 1426 else { print " <option value=eachtime12>12 Consecutive - Each Occurrence</option>\n"; } 1427 if ($form_alert_frequency eq "sigma1") { print " <option value=sigma1 selected>Sigma Type 1 Check</option>\n"; } 1428 else { print " <option value=sigma1>Sigma Type 1 Check</option>\n"; } 1429 if ($form_alert_frequency eq "sigma2") { print " <option value=sigma2 selected>Sigma Type 2 Check</option>\n"; } 1430 else { print " <option value=sigma2>Sigma Type 2 Check</option>\n"; } 1431 if ($form_alert_frequency eq "sigma3") { print " <option value=sigma3 selected>Sigma Type 3 Check</option>\n"; } 1432 else { print " <option value=sigma3>Sigma Type 3 Check</option>\n"; } 1433 print " </select>\n"; 1434 print " </span>\n"; 1435 print " <span class=port_spacer></span>\n"; 1436 1437 print " <span class=input_text>\n"; 1438 print " <label for=alert_threshold>Alert Threshold</label>\n"; 1439 print " <input class=left_port type=text name=alert_threshold value=\"$form_alert_threshold\">\n"; 1440 print " </span>\n"; 1441 print " <br><br>\n"; 1442 1443 print " <span class=input_text>\n"; 1444 print " <label for=general_comment>General Comment</label>\n"; 1445 print " <input class=left_addr type=text name=general_comment value=\"$form_general_comment\">\n"; 1446 print " </span>\n"; 1447 1448 print " </fieldset>\n"; 1449} 1450 1451sub create_revision_form { 1452 1453 print " <fieldset class=level2>\n"; 1454 print " <legend class=level2>Revision Notes</legend>\n"; 1455 1456 print " <span class=input_text>\n"; 1457 print " <label for=revision_comment>Revision Comment</label>\n"; 1458 print " <input class=left_rev type=text name=revision_comment value=\"$form_revision_comment\" id=revision_comment>\n"; 1459 print " </span>\n"; 1460 1461 print " <span class=select>\n"; 1462 print " <label for=monitor_type>Notate Graphs</label>\n"; 1463 print " <select class=short name=notate_graphs></b>\n"; 1464 print " <option value=N selected>No</option>\n"; 1465 print " <option value=Y>Yes</option>\n"; 1466 print " </select>\n"; 1467 print " </span>\n"; 1468 1469 print " </fieldset>\n"; 1470} 1471 1472sub create_SiLK_form { 1473 1474 # If using IPFIX, prepare the SiLK Selection 1475 1476 $IPFIX = 0; 1477 foreach $ipfix_device (@ipfix_devices) { 1478 if ($form_device_name eq $ipfix_device) { $IPFIX = 1; } 1479 } 1480 1481 if ($IPFIX) { 1482 1483 # For legacy use of "silk_field", convert to silk_type 1484 1485 if (substr($form_silk_field,1,1) eq "1") { $form_silk_type = "in,"; } 1486 if (substr($form_silk_field,2,1) eq "1") { $form_silk_type .= "out,"; } 1487 if (substr($form_silk_field,3,1) eq "1") { $form_silk_type .= "inweb,"; } 1488 if (substr($form_silk_field,4,1) eq "1") { $form_silk_type .= "outweb,"; } 1489 if (substr($form_silk_field,5,1) eq "1") { $form_silk_type .= "int2int,"; } 1490 if (substr($form_silk_field,6,1) eq "1") { $form_silk_type .= "ext2ext,"; } 1491 if (substr($form_silk_type,-1,1) eq ",") { $form_silk_type = substr($form_silk_type,0,-1); } 1492 1493 if ($form_silk_other ne "") { $form_silk_type = $form_silk_other; } 1494 1495 if ($form_silk_class eq "") { $form_silk_class = $silk_class_default; } 1496 if ($form_silk_flowtype eq "") { $form_silk_flowtype = $silk_flowtype_default; } 1497 if ($form_silk_type eq "") { $form_silk_type = $silk_type_default; } 1498 if ($form_silk_sensors eq "") { $form_silk_sensors = $silk_sensors_default; } 1499 if ($form_silk_switches eq "") { $form_silk_switches = $silk_switches_default; } 1500 1501 print " <fieldset class=level2>\n"; 1502 print " <legend class=level2>SiLK Selection</legend>\n"; 1503 1504 print " <span class=input_text>\n"; 1505 print " <label for=silk_class>Class</label>\n"; 1506 print " <input class=silk_source type=text name=silk_class value=\"$form_silk_class\">\n"; 1507 print " </span>\n"; 1508 print " <span class=silk_spacer></span>\n"; 1509 print " <span class=input_text>\n"; 1510 print " <label for=silk_flowtype>Flowtype</label>\n"; 1511 print " <input class=silk_source type=text name=silk_flowtype value=\"$form_silk_flowtype\">\n"; 1512 print " </span>\n"; 1513 print " <span class=silk_spacer></span>\n"; 1514 print " <span class=input_text>\n"; 1515 print " <label for=silk_type>Type</label>\n"; 1516 print " <input class=silk_source type=text name=silk_type value=\"$form_silk_type\">\n"; 1517 print " </span>\n"; 1518 print " <span class=silk_spacer></span>\n"; 1519 print " <span class=input_text>\n"; 1520 print " <label for=silk_sensors>Sensors</label>\n"; 1521 print " <input class=silk_source type=text name=silk_sensors value=\"$form_silk_sensors\">\n"; 1522 print " </span>\n"; 1523 print " <span class=silk_spacer></span>\n"; 1524 print " <span class=input_text>\n"; 1525 print " <label for=silk_switches>Other Switches</label>\n"; 1526 print " <input class=silk_source type=text name=silk_switches value=\"$form_silk_switches\">\n"; 1527 print " </span>\n"; 1528 print " </fieldset>\n"; 1529 1530 } 1531} 1532 1533sub create_submit_buttons { 1534 1535 my ($called_by) = @_; 1536 1537 if ($called_by ne "FlowMonitor_Sol") { print " <br>\n"; } 1538 print " <table>\n"; 1539 print " <tr>\n"; 1540 print " <td class=td_left>\n"; 1541 if ($called_by eq "FlowViewer") { print " <input class=button type=submit value=\"Generate Textual Report\">\n"; } 1542 if ($called_by eq "FlowGrapher") { print " <input class=button type=submit value=\"Generate Graph Report\">\n"; } 1543 if ($called_by eq "FlowMonitor") { print " <input class=button type=submit value=\"Create Monitor\">\n"; } 1544 if ($called_by eq "FlowMonitor_Sol") { print " <input class=button type=submit value=\"Revise Monitor\">\n"; $called_by = "FlowMonitor"; } 1545 print " </td>\n"; 1546 print " <td>     </td>\n"; 1547 print " <td>     </td>\n"; 1548 print " <td>     </td>\n"; 1549 print " <td>     </td>\n"; 1550 print " <input type=hidden name=active_dashboard value=\"$active_dashboard\">\n"; 1551 print " <td class=td_right>\n"; 1552 print " <a href=\"$cgi_bin_short/$called_by.cgi?$active_dashboard^filter_hash=\">\n"; 1553 print " <button class=reset type=button onClick=window.location.href=\"$cgi_bin_short/$called_by.cgi?$active_dashboard^filter_hash=\">Reset Form Values</button>\n"; 1554 print " </a>\n"; 1555 print " </td>\n"; 1556 print " </tr>\n"; 1557 print " </table>\n"; 1558 if ($called_by ne "FlowMonitor_Sol") { print " <br>\n"; } 1559 print " </fieldset>\n"; 1560 print " </form>\n"; 1561} 1562 1563sub create_filter_output { 1564 1565 my ($called_by,$filter_hash) = @_; 1566 1567 load_filtering_parameters($called_by,$filter_hash); 1568 1569 if ($called_by =~ "FlowMonitor_Replay") { 1570 print " <br>\n"; 1571 print " <span class=text16>$form_Description</span>\n"; 1572 print " <br>\n"; 1573 } 1574 1575 if ($called_by =~ "FlowMonitor") { 1576 print " <br>\n"; 1577 print " <span class=text16>$form_monitor_label</span>\n"; 1578 print " <br>\n"; 1579 } 1580 1581 if ($form_monitor_type eq "Group") { 1582 if ($form_general_comment ne "") { 1583 print " <br>\n"; 1584 print " <span class=text10>$form_general_comment</span>\n"; 1585 } 1586 return; 1587 } 1588 1589 if ($time_zone eq "") { 1590 open(DATE,"date 2>&1|"); 1591 while (<DATE>) { 1592 ($d_tz,$m_tz,$dt_tz,$t_tz,$time_zone,$y_tz) = split(/\s+/,$_); 1593 } 1594 } 1595 1596 print " <table class=filter>\n"; 1597 1598 if (($called_by =~ "FlowViewer") || ($called_by =~ "FlowGrapher")) { 1599 print " <tr>\n"; 1600 if ($called_by =~ "FlowViewer") { 1601 1602 if ($stat_report == 99) { $report_title = "Summary"; } 1603 if ($stat_report == 5) { $report_title = "UDP/TCP Destination Port"; } 1604 if ($stat_report == 6) { $report_title = "UDP/TCP Source Port"; } 1605 if ($stat_report == 7) { $report_title = "UDP/TCP Port"; } 1606 if ($stat_report == 8) { $report_title = "Destination IP"; } 1607 if ($stat_report == 9) { $report_title = "Source IP"; } 1608 if ($stat_report == 10) { $report_title = "Source/Destination IP"; } 1609 if ($stat_report == 11) { $report_title = "Source or Destination IP"; } 1610 if ($stat_report == 12) { $report_title = "IP Protocol"; } 1611 if ($stat_report == 17) { $report_title = "Input Interface"; } 1612 if ($stat_report == 18) { $report_title = "Output Interface"; } 1613 if ($stat_report == 19) { $report_title = "Source AS"; } 1614 if ($stat_report == 20) { $report_title = "Destination AS"; } 1615 if ($stat_report == 21) { $report_title = "Source/Destination AS"; } 1616 if ($stat_report == 22) { $report_title = "IP ToS"; } 1617 if ($stat_report == 23) { $report_title = "Input/Output Interface"; } 1618 if ($stat_report == 24) { $report_title = "Source Prefix"; } 1619 if ($stat_report == 25) { $report_title = "Destination Prefix"; } 1620 if ($stat_report == 26) { $report_title = "Source/Destination Prefix"; } 1621 if ($stat_report == 27) { $report_title = "Exporter IP"; } 1622 if ($stat_report == 30) { $report_title = "Detect Scanning"; } 1623 1624 if ($print_report == 1) { $report_title = "Flow Times"; } 1625 if ($print_report == 4) { $report_title = "AS Numbers"; } 1626 if ($print_report == 5) { $report_title = "132 Columns"; } 1627 if ($print_report == 9) { $report_title = "1 Line with Tags"; } 1628 if ($print_report == 10) { $report_title = "AS Aggregation"; } 1629 if ($print_report == 11) { $report_title = "Protocol Port Aggregation"; } 1630 if ($print_report == 12) { $report_title = "Source Prefix Aggregation"; } 1631 if ($print_report == 13) { $report_title = "Destination Prefix Aggregation"; } 1632 if ($print_report == 14) { $report_title = "Prefix Aggregation"; } 1633 if ($print_report == 15) { $report_title = "Source Prefix Aggregation v6"; } 1634 if ($print_report == 16) { $report_title = "Destination Prefix Aggregation v6"; } 1635 if ($print_report == 17) { $report_title = "Prefix Aggregation v6"; } 1636 if ($print_report == 24) { $report_title = "Full (Catalyst)"; } 1637 1638 print " <td class=label>Report:  </td>\n"; 1639 print " <td class=value>$report_title</td>\n"; 1640 print " <td class=label>Sort Field:  </td>\n"; 1641 1642 if ($form_sort_field == 1) { print " <td class=value>Octets</td>\n"; } 1643 if ($form_sort_field == 2) { print " <td class=value>Flows</td>\n"; } 1644 if ($form_sort_field == 3) { print " <td class=value>Packets</td>\n"; } 1645 1646 } elsif ($called_by =~ "FlowGrapher") { 1647 1648 print " <td class=label>Report:  </td>\n"; 1649 if ($form_graph_type eq "bps") { $graph_type_out = "Bits/Second"; } 1650 elsif ($form_graph_type eq "bpsa") { $graph_type_out = "Bits/Second Analysis"; } 1651 elsif ($form_graph_type eq "pps") { $graph_type_out = "Packets/Second"; } 1652 elsif ($form_graph_type eq "ppsa") { $graph_type_out = "Packets/Second Analysis"; } 1653 elsif ($form_graph_type eq "fpsi") { $graph_type_out = "Flows Initiated/Second"; } 1654 elsif ($form_graph_type eq "fpsa") { $graph_type_out = "Flows Active/Second"; } 1655 elsif ($form_graph_type eq "fpsia") { $graph_type_out = "Flows Initiated/Second Analysis"; } 1656 elsif ($form_graph_type eq "fpsaa") { $graph_type_out = "Flows Active/Second Analysis"; } 1657 print " <td class=value>$graph_type_out</td>\n"; 1658 print " <td class=label>Bucket Size:  </td>\n"; 1659 print " <td class=value>$form_bucket_size sec</td>\n"; 1660 1661 } 1662 print " </tr>\n"; 1663 print " <tr>\n"; 1664 print " <td class=label>Start Time:  </td>\n"; 1665 print " <td class=value>$form_start_date $form_start_time $time_zone</td>\n"; 1666 print " <td class=label>End Time:  </td>\n"; 1667 print " <td class=value>$form_end_date $form_end_time $time_zone</td>\n"; 1668 print " </tr>\n"; 1669 } 1670 1671 if ($form_exporter ne "") { 1672 foreach $exporter_pair (@exporters) { 1673 ($exporter_ip,$exporter_name) = split(/:/,$exporter_pair); 1674 if ($form_exporter eq $exporter_ip) { last; } 1675 } 1676 } 1677 1678 print " <tr>\n"; 1679 print " <td class=label>Device Name:  </td>\n"; 1680 print " <td class=value>$form_device_name</td>\n"; 1681 print " <td class=label>Exporter:  </td>\n"; 1682 print " <td class=value>$exporter_name</td>\n"; 1683 print " </tr>\n"; 1684 1685 print " <tr>\n"; 1686 print " <td class=label>Source IPs:  </td>\n"; 1687 print " <td class=value>$form_source_addresses</td>\n"; 1688 print " <td class=label>Destination IPs:  </td>\n"; 1689 print " <td class=value>$form_dest_addresses</td>\n"; 1690 print " </tr>\n"; 1691 1692 print " <tr>\n"; 1693 print " <td class=label>Source Ports:  </td>\n"; 1694 print " <td class=value>$form_source_ports</td>\n"; 1695 print " <td class=label>Destination Ports:  </td>\n"; 1696 print " <td class=value>$form_dest_ports</td>\n"; 1697 print " </tr>\n"; 1698 1699 print " <tr>\n"; 1700 print " <td class=label>Source I/Fs:  </td>\n"; 1701 1702 if ($form_sif_names ne "") { 1703 if ($form_device_name ne "") { 1704 $interfaces_file = "$cgi_bin_directory/NamedInterfaces_Devices"; 1705 } elsif ($form_exporter ne "") { 1706 $interfaces_file = "$cgi_bin_directory/NamedInterfaces_Exporters"; 1707 } 1708 1709 open (NAMED,"<$interfaces_file"); 1710 chomp (@interfaces = <NAMED>); 1711 close (NAMED); 1712 1713 foreach $interface (@interfaces) { 1714 if (($interface eq "") || (substr($interface,0,1) eq "#")) { next; } 1715 ($device,$interface_index,$interface_name) = split(/:/,$interface); 1716 if (($device eq $form_device_name) || ($device eq $form_exporter)) { 1717 if ($interface_index eq $form_sif_names) { 1718 $sif_name_out = $interface_name; 1719 } 1720 } 1721 } 1722 print " <td class=value>$sif_name_out</td>\n"; 1723 } else { 1724 print " <td class=value>$form_source_ifs</td>\n"; 1725 } 1726 1727 print " <td class=label>Destination I/Fs:  </td>\n"; 1728 if ($form_dif_names ne "") { 1729 1730 if ($form_device_name ne "") { 1731 $interfaces_file = "$cgi_bin_directory/NamedInterfaces_Devices"; 1732 } elsif ($form_exporter ne "") { 1733 $interfaces_file = "$cgi_bin_directory/NamedInterfaces_Exporters"; 1734 } 1735 1736 open (NAMED,"<$interfaces_file"); 1737 chomp (@interfaces = <NAMED>); 1738 close (NAMED); 1739 1740 foreach $interface (@interfaces) { 1741 if (($interface eq "") || (substr($interface,0,1) eq "#")) { next; } 1742 ($device,$interface_index,$interface_name) = split(/:/,$interface); 1743 if (($device eq $form_device_name) || ($device eq $form_exporter)) { 1744 if ($interface_index eq $form_dif_names) { 1745 $dif_name_out = $interface_name; 1746 } 1747 } 1748 } 1749 print " <td class=value>$dif_name_out</td>\n"; 1750 } else { 1751 print " <td class=value>$form_dest_ifs</td>\n"; 1752 } 1753 print " </tr>\n"; 1754 1755 print " <tr>\n"; 1756 print " <td class=label>Source AS:  </td>\n"; 1757 print " <td class=value>$form_source_ases</td>\n"; 1758 print " <td class=label>Destination AS:  </td>\n"; 1759 print " <td class=value>$form_dest_ases</td>\n"; 1760 print " </tr>\n"; 1761 1762 if (($form_nexthop_ips ne "") || ($form_protocols ne "")) { 1763 print " <tr>\n"; 1764 print " <td class=label>NextHop IPs:  </td>\n"; 1765 print " <td class=value>$form_nexthop_ips</td>\n"; 1766 print " <td class=label>Protocols:  </td>\n"; 1767 print " <td class=value>$form_protocols</td>\n"; 1768 print " </tr>\n"; 1769 } 1770 1771 if (($form_tos_fields ne "") || ($form_tcp_flags ne "")) { 1772 print " <tr>\n"; 1773 print " <td class=label>TOS Field:  </td>\n"; 1774 print " <td class=value>$form_tos_fields</td>\n"; 1775 print " <td class=label>TCP Flags:  </td>\n"; 1776 print " <td class=value>$form_tcp_flags</td>\n"; 1777 print " </tr>\n"; 1778 } 1779 1780 if ($called_by =~ "FlowGrapher") { 1781 1782 print " <tr>\n"; 1783 print " <td class=label>Detail Lines:  </td>\n"; 1784 print " <td class=value>$form_detail_lines</td>\n"; 1785 print " <td class=label>Graph Width:  </td>\n"; 1786 print " <td class=value>$form_graph_multiplier</td>\n"; 1787 print " </tr>\n"; 1788 } 1789 1790 if ($called_by =~ "FlowViewer") { 1791 1792 print " <tr>\n"; 1793 print " <td class=label>Cutoff Lines:  </td>\n"; 1794 print " <td class=value>$form_cutoff_lines</td>\n"; 1795 print " <td class=label>Cutoff Octets:  </td>\n"; 1796 print " <td class=value>$form_cutoff_octets</td>\n"; 1797 print " </tr>\n"; 1798 } 1799 1800 if (($called_by =~ "FlowViewer") || ($called_by =~ "FlowGrapher")) { 1801 1802 if ($form_flow_select == 1) { $flow_select_out = "Any Part in Specified Time Span"; } 1803 if ($form_flow_select == 2) { $flow_select_out = "End Time in Specified Time Span"; } 1804 if ($form_flow_select == 3) { $flow_select_out = "Start Time in Specified Time Span"; } 1805 if ($form_flow_select == 4) { $flow_select_out = "Entirely in Specified Time Span"; } 1806 1807 print " <tr>\n"; 1808 print " <td class=label>Include If:  </td>\n"; 1809 print " <td class=value>$flow_select_out</td>\n"; 1810 } 1811 1812 if ($form_IPFIX) { 1813 1814 if ($form_silk_rootdir ne "") { $selection_out = "--data-rootdir=$form_silk_rootdir "; } 1815 if ($form_silk_class ne "") { $selection_out .= "--class=$form_silk_class "; } 1816 if ($form_silk_flowtype ne "") { $selection_out .= "--flowtype=$form_silk_flowtype "; } 1817 if ($form_silk_type ne "") { $selection_out .= "--type=$form_silk_type "; } 1818 if ($form_silk_sensors ne "") { $selection_out .= "--sensors=$form_silk_sensors "; } 1819 if ($form_silk_switches ne "") { $selection_out .= "$form_silk_switches "; } 1820 1821 print " <td class=label>SiLK Selection:  </td>\n"; 1822 if ($called_by =~ "FlowMonitor") { 1823 print " <td class=value>$selection_out</td>\n"; 1824 } else { 1825 print " <td class=value>$selection_out</td>\n"; 1826 print " </tr>\n"; 1827 } 1828 } 1829 1830 if ($called_by =~ "FlowMonitor") { 1831 1832 $monitor_type_out = $form_monitor_type; 1833 if ($form_monitor_type eq "") { $monitor_type_out = "Bits/Second"; } 1834 if ($form_monitor_type eq "Individual") { $monitor_type_out = "Bits/Second"; } 1835 if ($form_monitor_type =~ "bps") { $monitor_type_out = "Bits/Second"; } 1836 if ($form_monitor_type =~ "pps") { $monitor_type_out = "Packets/Second"; } 1837 if (($form_monitor_type eq "fpsi") || ($form_monitor_type eq "Individual-fps")) { $monitor_type_out = "Flows Initiated/Second"; } 1838 if (($form_monitor_type eq "fpsa") || ($form_monitor_type =~ /fps-prorated/)) { $monitor_type_out = "Flows Active/Second"; } 1839 if ($form_IPFIX) { 1840 print " <td class=label>Monitor Type:  </td>\n"; 1841 print " <td class=value>$monitor_type_out</td>\n"; 1842 } else { 1843 print " <tr>\n"; 1844 print " <td class=label>Monitor Type:  </td>\n"; 1845 print " <td class=value>$monitor_type_out</td>\n"; 1846 } 1847 print " </tr>\n"; 1848 } else { 1849 if (($form_graph_type eq "bpsa") || ($form_graph_type eq "ppsa") || ($form_graph_type eq "fpsia") || ($form_graph_type eq "fpsaa")) { 1850 print " <td class=label>Peak Period Obs:  </td>\n"; 1851 print " <td class=value>$analyze_peak_width</td>\n"; 1852 } 1853 } 1854 1855 if (($called_by =~ "FlowMonitor") && ($form_general_comment ne "")) { 1856 1857 print " <tr>\n"; 1858 print " <td class=label>Comments:  </td>\n"; 1859 print " <td class=value colspan=3>$form_general_comment</td>\n"; 1860 print " </tr>\n"; 1861 } 1862 1863 if (($form_sampling_multiplier > 1) && (!(($stat_report == 99) && ($IPFIX)))) { 1864 print " <tr>\n"; 1865 print " <td class=label>Note:  </td>\n"; 1866 if (($print_report > 0) && ($print_report <= 10)) { 1867 print " <td class=value colspan=3>The sampling multiplier option is not available for this report</td>\n"; 1868 } else { 1869 print " <td class=value colspan=3>*all values have been multiplied by the Sampling Multiplier: $form_sampling_multiplier</td>\n"; 1870 } 1871 print " </tr>\n"; 1872 } 1873 1874 if ((($form_print_report >= 12) && ($form_print_report <= 17)) && (($form_source_addresses eq "") && ($form_dest_addresses eq ""))) { 1875 print " <tr>\n"; 1876 print " <td class=label>Note:  </td>\n"; 1877 print " <td class=value colspan=3>You may change the mask using the Source or Dest IP: fields (e.g., /24)</td>\n"; 1878 print " </tr>\n"; 1879 } 1880 1881 print " </table>\n"; 1882} 1883 1884sub load_filtering_parameters { 1885 1886 ($called_by,$filter_hash) = @_; 1887 1888 if ($filter_hash eq "") { 1889 1890 if ($called_by eq "FlowViewer") { $filter_hash = "FV_"; } 1891 if ($called_by eq "FlowGrapher") { $filter_hash = "FG_"; } 1892 if ($called_by eq "FlowMonitor") { $filter_hash = "FM_"; } 1893 1894 } else { 1895 1896 $filter_source = substr($filter_hash,0,2); 1897 $filter_link = substr($filter_hash,3,255); 1898 if ($filter_link =~ /^/) { 1899 if (substr($filter_link,0,1) eq "^") { 1900 $new_device = substr($filter_link,1,255); 1901 $filter_link = ""; 1902 } else { 1903 ($filter_filename,$new_device) = split(/\^/,$filter_link); 1904 } 1905 1906 if (substr($new_device,0,3) eq "DDD") { $new_device = substr($new_device,3,255); $new_exporter = ""; } 1907 if (substr($new_device,0,3) eq "EEE") { $new_exporter = substr($new_device,3,255); $new_device = ""; } 1908 $filter_hash = $filter_source ."_". $filter_filename; 1909 } 1910 1911 if ($filter_source eq "FV") { $filter_source_file = "$work_directory/$filter_filename"; } 1912 if ($filter_source eq "FG") { $filter_source_file = "$work_directory/$filter_filename"; } 1913 if (($filter_source eq "FM") || (filter_source eq "FT")) { $filter_source_file = "$work_directory/$filter_filename"; } 1914 if ($filter_source eq "PV") { $filter_source_file = "$work_directory/$filter_filename"; } 1915 if ($filter_source eq "FL") { $filter_source_file = "$save_directory/$filter_filename.svf"; } 1916 if ($filter_source eq "SV") { 1917 if (($filter_hash =~ /FlowMonitor/) || ($filter_hash =~ /FlowTracker/)) { 1918 $MT_saved_directory = substr($filter_link,0,25); 1919 $flowmonitor = substr($filter_link,26,255); 1920 if ($flowmonitor =~ /^/) { ($flowmonitor,$new_device_extra) = split(/\^/,$flowmonitor); } 1921 if (-e "$filter_directory/$flowmonitor.grp") { $filter_suffix = ".grp"; } 1922 if (-e "$filter_directory/$flowmonitor.fil") { $filter_suffix = ".fil"; } 1923 $filter_filename = $MT_saved_directory ."/". $flowmonitor . $filter_suffix; 1924 } 1925 $filter_source_file = "$save_directory/$filter_filename"; 1926 } 1927 if (($filter_source eq "MT") || ($filter_source eq "TR")) { 1928 if (-e "$filter_directory/$filter_filename.archive") { $filter_filename .= ".archive"; } 1929 if (-e "$filter_directory/$filter_filename.grp") { $filter_filename .= ".grp"; } 1930 if (-e "$filter_directory/$filter_filename.fil") { $filter_filename .= ".fil"; } 1931 $filter_source_file = "$filter_directory/$filter_filename"; 1932 } 1933 } 1934 1935print DEBUG "filter_hash: $filter_hash filter_source: $filter_source filter_source_file: $filter_source_file\n"; 1936 open(FILTER,"<$filter_source_file"); 1937 while (<FILTER>) { 1938 chop; 1939 1940 if ((($filter_source eq "MT") || ($filter_source eq "TR")) || (($filter_source eq "SV") && (($filter_hash =~ /FlowMonitor/) || ($filter_hash =~ /FlowTracker/)) )) { 1941 $key = substr($_,0,8); 1942 if ($key eq " input: ") { 1943 ($input,$field,$field_value) = split(/: /); 1944 if ($field eq "device_name") { $form_device_name = $field_value; } 1945 if ($field eq "Description") { $form_Description = $field_value; } 1946 if ($field eq "create_time") { $form_create_time = $field_value; } 1947 if ($field eq "start_date") { $form_start_date = $field_value; } 1948 if ($field eq "start_time") { $form_start_time = $field_value; } 1949 if ($field eq "end_date") { $form_end_date = $field_value; } 1950 if ($field eq "end_time") { $form_end_time = $field_value; } 1951 if ($field eq "source_addresses") { $form_source_addresses = $field_value; } 1952 if ($field eq "source_ports") { $form_source_ports = $field_value; } 1953 if ($field eq "source_ifs") { $form_source_ifs = $field_value; } 1954 if ($field eq "sif_names") { $form_sif_names = $field_value; } 1955 if ($field eq "source_ases") { $form_source_ases = $field_value; } 1956 if ($field eq "dest_addresses") { $form_dest_addresses = $field_value; } 1957 if ($field eq "dest_ports") { $form_dest_ports = $field_value; } 1958 if ($field eq "dest_ifs") { $form_dest_ifs = $field_value; } 1959 if ($field eq "dif_names") { $form_dif_names = $field_value; } 1960 if ($field eq "dest_ases") { $form_dest_ases = $field_value; } 1961 if ($field eq "protocols") { $form_protocols = $field_value; } 1962 if ($field eq "tcp_flags") { $form_tcp_flags = $field_value; } 1963 if ($field eq "tos_fields") { $form_tos_fields = $field_value; } 1964 if ($field eq "exporter") { $form_exporter = $field_value; } 1965 if ($field eq "nexthop_ips") { $form_nexthop_ips = $field_value; } 1966 if(($field eq "monitor_type") || ($field eq "tracking_type")) { if ($field_value eq "Individual") { $form_monitor_type = "bps"; } 1967 elsif ($field_value eq "Individual-bps") { $form_monitor_type = "bps"; } 1968 elsif ($field_value eq "Individual-bps-prorated") { $form_monitor_type = "bps"; } 1969 elsif ($field_value eq "Individual-pps") { $form_monitor_type = "pps"; } 1970 elsif ($field_value eq "Individual-pps-prorated") { $form_monitor_type = "pps"; } 1971 elsif ($field_value eq "Individual-fps") { $form_monitor_type = "fpsi"; } 1972 elsif ($field_value eq "Individual-fps-prorated") { $form_monitor_type = "fpsa"; } 1973 else { $form_monitor_type = $field_value; }} 1974 if(($field eq "monitor_label") || ($field eq "tracking_label")) { $form_monitor_label = $field_value; } 1975 if ($field eq "general_comment") { $form_general_comment = $field_value; } 1976 if ($field eq "alert_threshold") { $form_alert_threshold = $field_value; } 1977 if ($field eq "alert_frequency") { $form_alert_frequency = $field_value; } 1978 if ($field eq "alert_destination") { $form_alert_destination = $field_value; } 1979 if ($field eq "sampling_multiplier") { $form_sampling_multiplier = $field_value; } 1980 if ($field eq "IPFIX") { $form_IPFIX = $field_value; } 1981 if ($field eq "silk_field") { $form_silk_field = $field_value; } 1982 if ($field eq "silk_other") { $form_silk_other = $field_value; } 1983 if ($field eq "silk_rootdir") { $form_silk_rootdir = $field_value; } 1984 if ($field eq "silk_class") { $form_silk_class = $field_value; } 1985 if ($field eq "silk_flowtype") { $form_silk_flowtype = $field_value; } 1986 if ($field eq "silk_type") { $form_silk_type = $field_value; } 1987 if ($field eq "silk_sensors") { $form_silk_sensors = $field_value; } 1988 if ($field eq "silk_switches") { $form_silk_switches = $field_value; } 1989 } 1990 1991 } else { 1992 1993 ($field,$field_value) = split(/: /); 1994 if (/BEGIN FILTERING/) { $found_parameters = 1; next; } 1995 if ($found_parameters) { 1996 if (/END FILTERING/) { last; } 1997 if ($field eq "filter_title") { $filter_title = $field_value; } 1998 if ($field eq "device_name") { $form_device_name = $field_value; } 1999 if ($field eq "start_date") { $form_start_date = $field_value; } 2000 if ($field eq "start_time") { $form_start_time = $field_value; } 2001 if ($field eq "end_date") { $form_end_date = $field_value; } 2002 if ($field eq "end_time") { $form_end_time = $field_value; } 2003 if ($field eq "source_addresses") { $form_source_addresses = $field_value; } 2004 if ($field eq "source_ports") { $form_source_ports = $field_value; } 2005 if ($field eq "source_ifs") { $form_source_ifs = $field_value; } 2006 if ($field eq "sif_names") { $form_sif_names = $field_value; } 2007 if ($field eq "source_ases") { $form_source_ases = $field_value; } 2008 if ($field eq "dest_addresses") { $form_dest_addresses = $field_value; } 2009 if ($field eq "dest_ports") { $form_dest_ports = $field_value; } 2010 if ($field eq "dest_ifs") { $form_dest_ifs = $field_value; } 2011 if ($field eq "dif_names") { $form_dif_names = $field_value; } 2012 if ($field eq "dest_ases") { $form_dest_ases = $field_value; } 2013 if ($field eq "protocols") { $form_protocols = $field_value; } 2014 if ($field eq "tcp_flags") { $form_tcp_flags = $field_value; } 2015 if ($field eq "tos_fields") { $form_tos_fields = $field_value; } 2016 if ($field eq "exporter") { $form_exporter = $field_value; } 2017 if ($field eq "nexthop_ips") { $form_nexthop_ips = $field_value; } 2018 if(($field eq "monitor_type") || ($field eq "tracking_type")) { if ($field_value eq "Individual") { $form_monitor_type = "bps"; } 2019 elsif ($field_value eq "Individual-bps") { $form_monitor_type = "bps"; } 2020 elsif ($field_value eq "Individual-bps-prorated") { $form_monitor_type = "bps"; } 2021 elsif ($field_value eq "Individual-pps") { $form_monitor_type = "pps"; } 2022 elsif ($field_value eq "Individual-pps-prorated") { $form_monitor_type = "pps"; } 2023 elsif ($field_value eq "Individual-fps") { $form_monitor_type = "fpsi"; } 2024 elsif ($field_value eq "Individual-fps-prorated") { $form_monitor_type = "fpsa"; } 2025 else { $form_monitor_type = $field_value; }} 2026 if(($field eq "monitor_label") || ($field eq "tracking_label")) { $form_monitor_label = $field_value; } 2027 if(($field eq "monitor_status") || ($field eq "tracking_status")) { $form_monitor_status = $field_value; } 2028 if ($field eq "general_comment") { $form_general_comment = $field_value; } 2029 if ($field eq "sampling_multiplier") { $form_sampling_multiplier = $field_value; } 2030 if ($field eq "stat_report") { $form_stat_report = $field_value; } 2031 if ($field eq "print_report") { $form_print_report = $field_value; } 2032 if ($field eq "flow_select") { $form_flow_select = $field_value; } 2033 if ($field eq "sort_field") { $form_sort_field = $field_value; } 2034 if ($field eq "pie_charts") { $form_pie_charts= $field_value; } 2035 if ($field eq "flow_analysis") { $form_flow_analysis= $field_value; } 2036 if ($field eq "cutoff_lines") { $form_cutoff_lines = $field_value; } 2037 if ($field eq "cutoff_octets") { $form_cutoff_octets = $field_value; } 2038 if ($field eq "unit_conversion") { $form_unit_conversion = $field_value; } 2039 if ($field eq "detail_lines") { $form_detail_lines = $field_value; } 2040 if ($field eq "bucket_size") { $form_bucket_size = $field_value; } 2041 if ($field eq "resolve_addresses") { $form_resolve_addresses = $field_value; } 2042 if ($field eq "graph_multiplier") { $form_graph_multiplier = $field_value; } 2043 if ($field eq "stats_method") { $form_stats_method = $field_value; } 2044 if ($field eq "graph_type") { if ($field_value eq "Bits") { $form_graph_type = "bps"; } 2045 elsif ($field_value eq "Bits_P") { $form_graph_type = "bps"; } 2046 elsif ($field_value eq "Packets") { $form_graph_type = "pps"; } 2047 elsif ($field_value eq "Packets_P") { $form_graph_type = "pps"; } 2048 elsif ($field_value eq "Flows") { $form_graph_type = "fpsi"; } 2049 elsif ($field_value eq "Flows_I") { $form_graph_type = "fpsi"; } 2050 elsif ($field_value eq "Flows_P") { $form_graph_type = "fpsa"; } 2051 else {$form_graph_type = $field_value; } } 2052 if ($field eq "IPFIX") { $form_IPFIX = $field_value; } 2053 if ($field eq "silk_field") { $form_silk_field = $field_value; } 2054 if ($field eq "silk_other") { $form_silk_other = $field_value; } 2055 if ($field eq "silk_rootdir") { $form_silk_rootdir = $field_value; } 2056 if ($field eq "silk_class") { $form_silk_class = $field_value; } 2057 if ($field eq "silk_flowtype") { $form_silk_flowtype = $field_value; } 2058 if ($field eq "silk_type") { $form_silk_type = $field_value; } 2059 if ($field eq "silk_sensors") { $form_silk_sensors = $field_value; } 2060 if ($field eq "silk_switches") { $form_silk_switches = $field_value; } 2061 } 2062 } 2063 } 2064 close(FILTER); 2065} 2066 2067sub get_monitor_title { 2068 2069 my ($filter_filename,$suffix) = @_; 2070 2071 $check_file = "$filter_directory/$filter_filename.fil"; 2072 if (-e $check_file) { $filter_source_file = "$filter_directory/$filter_filename.fil"; } 2073 $check_file = "$filter_directory/$filter_filename.grp"; 2074 if (-e $check_file) { $filter_source_file = "$filter_directory/$filter_filename.grp"; } 2075 $check_file = "$filter_directory/$filter_filename.archive"; 2076 if (-e $check_file) { $filter_source_file = "$filter_directory/$filter_filename.archive"; } 2077 2078 open(FILTER,"<$filter_source_file"); 2079 while (<FILTER>) { 2080 chop; 2081 $key = substr($_,0,8); 2082 if ($key eq " input: ") { 2083 ($input,$field,$field_value) = split(/: /); 2084 if (($field eq "monitor_label") || ($field eq "tracking_label")) { 2085 $monitor_title = $field_value; 2086 last; 2087 } 2088 } 2089 } 2090 close(FILTER); 2091 2092 return $monitor_title; 2093} 2094 2095sub start_saved_file { 2096 2097 my ($saved_file) = @_; 2098 2099 ($temp_mnth_s,$temp_day_s,$temp_yr_s) = split(/\//,$start_date); 2100 ($temp_mnth_e,$temp_day_e,$temp_yr_e) = split(/\//,$end_date); 2101 2102 if ($date_format eq "DMY") { 2103 $start_date_save = $temp_day_s ."/". $temp_mnth_s ."/". $temp_yr_s; 2104 $end_date_save = $temp_day_e ."/". $temp_mnth_e ."/". $temp_yr_e; 2105 } elsif ($date_format eq "DMY2") { 2106 $start_date_save = $temp_day_s .".". $temp_mnth_s .".". $temp_yr_s; 2107 $end_date_save = $temp_day_e .".". $temp_mnth_e .".". $temp_yr_e; 2108 } elsif ($date_format eq "YMD") { 2109 $start_date_save = $temp_yr_s ."-". $temp_mnth_s ."-". $temp_day_s; 2110 $end_date_save = $temp_yr_e ."-". $temp_mnth_e ."-". $temp_day_e; 2111 } else { 2112 $start_date_save = $start_date; 2113 $end_date_save = $end_date; 2114 } 2115 2116 open (SAVED,">$saved_file"); 2117 2118 print SAVED "<!-- BEGIN FILTERING PARAMETERS\n"; 2119 print SAVED "filter_hash: $filter_hash\n"; 2120 print SAVED "filter_title: $filter_title\n"; 2121 print SAVED "device_name: $device_name\n"; 2122 print SAVED "start_date: $start_date_save\n"; 2123 print SAVED "start_time: $start_time\n"; 2124 print SAVED "end_date: $end_date_save\n"; 2125 print SAVED "end_time: $end_time\n"; 2126 print SAVED "source_addresses: $source_addresses\n"; 2127 print SAVED "source_ports: $source_ports\n"; 2128 print SAVED "source_ifs: $source_ifs\n"; 2129 print SAVED "sif_names: $sif_names\n"; 2130 print SAVED "source_ases: $source_ases\n"; 2131 print SAVED "dest_addresses: $dest_addresses\n"; 2132 print SAVED "dest_ports: $dest_ports\n"; 2133 print SAVED "dest_ifs: $dest_ifs\n"; 2134 print SAVED "dif_names: $dif_names\n"; 2135 print SAVED "dest_ases: $dest_ases\n"; 2136 print SAVED "protocols: $protocols\n"; 2137 print SAVED "tcp_flags: $tcp_flags\n"; 2138 print SAVED "tos_fields: $tos_fields\n"; 2139 print SAVED "exporter: $exporter\n"; 2140 print SAVED "nexthop_ips: $nexthop_ips\n"; 2141 print SAVED "monitor_type: $monitor_type\n"; 2142 print SAVED "monitor_label: $monitor_label\n"; 2143 print SAVED "monitor_status: $monitor_status\n"; 2144 print SAVED "general_comment: $general_comment\n"; 2145 print SAVED "description: $description\n"; 2146 print SAVED "sampling_multiplier: $sampling_multiplier\n"; 2147 print SAVED "stat_report: $stat_report\n"; 2148 print SAVED "print_report: $print_report\n"; 2149 print SAVED "flow_select: $flow_select\n"; 2150 print SAVED "sort_field: $sort_field\n"; 2151 print SAVED "pie_charts: $pie_charts\n"; 2152 print SAVED "flow_analysis: $flow_analysis\n"; 2153 print SAVED "cutoff_lines: $cutoff_lines\n"; 2154 print SAVED "cutoff_octets: $cutoff_octets\n"; 2155 print SAVED "unit_conversion: $unit_conversion\n"; 2156 print SAVED "detail_lines: $detail_lines\n"; 2157 print SAVED "bucket_size: $bucket_size\n"; 2158 print SAVED "resolve_addresses: $resolve_addresses\n"; 2159 print SAVED "graph_multiplier: $graph_multiplier\n"; 2160 print SAVED "stats_method: $stats_method\n"; 2161 print SAVED "graph_type: $graph_type\n"; 2162 print SAVED "alert_threshold: $alert_threshold\n"; 2163 print SAVED "alert_frequency: $alert_frequency\n"; 2164 print SAVED "alert_destination: $alert_destination\n"; 2165 print SAVED "IPFIX: $IPFIX\n"; 2166 print SAVED "silk_rootdir: $silk_rootdir\n"; 2167 print SAVED "silk_class: $silk_class\n"; 2168 print SAVED "silk_flowtype: $silk_flowtype\n"; 2169 print SAVED "silk_type: $silk_type\n"; 2170 print SAVED "silk_sensors: $silk_sensors\n"; 2171 print SAVED "silk_switches: $silk_switches\n"; 2172 print SAVED "<END FILTERING PARAMETERS -->\n"; 2173 2174 close(SAVED); 2175} 2176 2177return 1; 2178