| | 3020 | sub dump_config() { |
|---|
| | 3021 | my $cmd = "$fwknopdCmd --Dump-config"; |
|---|
| | 3022 | if (&run_cmd($cmd, $NO_APPEND)) { |
|---|
| | 3023 | my $found = 0; |
|---|
| | 3024 | open F, "< $current_test_file" or die $!; |
|---|
| | 3025 | ### just look for an expected variable |
|---|
| | 3026 | while (<F>) { |
|---|
| | 3027 | if (/SLEEP_INTERVAL/) { |
|---|
| | 3028 | $found = 1; |
|---|
| | 3029 | last; |
|---|
| | 3030 | } |
|---|
| | 3031 | } |
|---|
| | 3032 | close F; |
|---|
| | 3033 | if ($found) { |
|---|
| | 3034 | return 1; |
|---|
| | 3035 | } else { |
|---|
| | 3036 | return &print_errors("[-] Could not find expected " . |
|---|
| | 3037 | "variable from --Dump-config output"); |
|---|
| | 3038 | } |
|---|
| | 3039 | } |
|---|
| | 3040 | return &print_errors("[-] Could not execute: $cmd"); |
|---|
| | 3041 | } |
|---|
| | 3042 | |
|---|
| | 3043 | sub override_config() { |
|---|
| | 3044 | my $cmd = "$fwknopdCmd --Override-config " . |
|---|
| | 3045 | "$override_sleep_fwknop_conf --Dump-config"; |
|---|
| | 3046 | if (&run_cmd($cmd, $NO_APPEND)) { |
|---|
| | 3047 | my $found = 0; |
|---|
| | 3048 | open F, "< $current_test_file" or die $!; |
|---|
| | 3049 | ### just look for an expected variable |
|---|
| | 3050 | while (<F>) { |
|---|
| | 3051 | if (/SLEEP_INTERVAL\s+42/) { |
|---|
| | 3052 | $found = 1; |
|---|
| | 3053 | last; |
|---|
| | 3054 | } |
|---|
| | 3055 | } |
|---|
| | 3056 | close F; |
|---|
| | 3057 | if ($found) { |
|---|
| | 3058 | return 1; |
|---|
| | 3059 | } else { |
|---|
| | 3060 | return &print_errors("[-] Could not find expected " . |
|---|
| | 3061 | "override value from --Dump-config output"); |
|---|
| | 3062 | } |
|---|
| | 3063 | } |
|---|
| | 3064 | return &print_errors("[-] Could not execute: $cmd"); |
|---|
| | 3065 | } |
|---|
| | 3066 | |
|---|
| | 3067 | sub SPA_disk_caching() { |
|---|
| | 3068 | my $pkt_file = "$output_dir/SPA_pkt.single"; |
|---|
| | 3069 | unlink $pkt_file if -e $pkt_file; |
|---|
| | 3070 | my $cmd = "$fwknopCmd $default_fwknop_args --Save-packet " . |
|---|
| | 3071 | "--Save-packet-file $pkt_file"; |
|---|
| | 3072 | unless (&run_cmd($cmd, $NO_APPEND)) { |
|---|
| | 3073 | return &print_errors("[-] Could not execute: $cmd"); |
|---|
| | 3074 | } |
|---|
| | 3075 | unless (&run_cmd($cmd, $APPEND)) { |
|---|
| | 3076 | return &print_errors("[-] Could not execute: $cmd"); |
|---|
| | 3077 | } |
|---|
| | 3078 | if (-e $pkt_file) { |
|---|
| | 3079 | my $lines = 0; |
|---|
| | 3080 | open F, "< $pkt_file" or die $!; |
|---|
| | 3081 | while (<F>) { |
|---|
| | 3082 | $lines++; |
|---|
| | 3083 | } |
|---|
| | 3084 | close F; |
|---|
| | 3085 | if ($lines == 1) { |
|---|
| | 3086 | return 1; |
|---|
| | 3087 | } else { |
|---|
| | 3088 | return &print_errors("[-] --Save-packet-file " . |
|---|
| | 3089 | "$pkt_file does not contain a single SPA packet"); |
|---|
| | 3090 | } |
|---|
| | 3091 | } else { |
|---|
| | 3092 | return &print_errors("[-] --Save-packet-file " . |
|---|
| | 3093 | "$pkt_file does not exist"); |
|---|
| | 3094 | } |
|---|
| | 3095 | return &print_errors("[-] Could not write SPA packet " . |
|---|
| | 3096 | "to --Save-packet-file $pkt_file"); |
|---|
| | 3097 | } |
|---|
| | 3098 | |
|---|
| | 3099 | sub SPA_multi_packet_disk_caching() { |
|---|
| | 3100 | my $pkt_file = "$output_dir/SPA_pkt.multi"; |
|---|
| | 3101 | unlink $pkt_file if -e $pkt_file; |
|---|
| | 3102 | my $cmd = "$fwknopCmd $default_fwknop_args --Save-packet " . |
|---|
| | 3103 | "--Save-packet-file $pkt_file --Save-packet-append"; |
|---|
| | 3104 | unless (&run_cmd($cmd, $NO_APPEND)) { |
|---|
| | 3105 | return &print_errors("[-] Could not execute: $cmd"); |
|---|
| | 3106 | } |
|---|
| | 3107 | unless (&run_cmd($cmd, $APPEND)) { |
|---|
| | 3108 | return &print_errors("[-] Could not execute: $cmd"); |
|---|
| | 3109 | } |
|---|
| | 3110 | if (-e $pkt_file) { |
|---|
| | 3111 | my $lines = 0; |
|---|
| | 3112 | open F, "< $pkt_file" or die $!; |
|---|
| | 3113 | while (<F>) { |
|---|
| | 3114 | $lines++; |
|---|
| | 3115 | } |
|---|
| | 3116 | close F; |
|---|
| | 3117 | if ($lines == 2) { |
|---|
| | 3118 | return 1; |
|---|
| | 3119 | } else { |
|---|
| | 3120 | return &print_errors("[-] --Save-packet-file " . |
|---|
| | 3121 | "$pkt_file does not contain two SPA packets"); |
|---|
| | 3122 | } |
|---|
| | 3123 | } else { |
|---|
| | 3124 | return &print_errors("[-] --Save-packet-file " . |
|---|
| | 3125 | "$pkt_file does not exist"); |
|---|
| | 3126 | } |
|---|
| | 3127 | return &print_errors("[-] Could not write two SPA packets " . |
|---|
| | 3128 | "with --Save-packet-append"); |
|---|
| | 3129 | } |
|---|
| | 3130 | |
|---|