summaryrefslogtreecommitdiff
path: root/scripts/VyattaQosPolicy.pm
blob: 76f86ebe207730697a692e52a7ee58e7fde046d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package VyattaQosPolicy;

use strict;

require VyattaConfig;
use VyattaQosTrafficShaper;
use VyattaQosFairQueue;

# Main class for all QoS policys
# It is a base class, and actual policies are subclass instances.

# Build a new traffic shaper of the proper type based
# on the configuration information.
sub config {
    my ( $class, $config, $type ) = @_;
    my $object = undef;

  SWITCH: {
        ( $type eq 'fair-queue' ) && do {
            $object = new VyattaQosFairQueue($config);
            last SWITCH;
        };

        ( $type eq 'traffic-shaper' ) && do {
            $object = new VyattaQosTrafficShaper($config);
            last SWITCH;
        };

        die "Unknown policy type \"$type\"\n";
    }
    return $object;
}

1;