Class List Method List File List

# Module: Yast::FirewallGeneralfunctionsInclude

Defined in:
  ../../src/include/firewall/generalfunctions.rb

## Instance Method Summary (collapse)

- - (Object) GetPortName(port_to_be_checked)

  Function returns port name of port number got as parameter.

- - (Object) initialize_firewall_generalfunctions(include_target)

## Instance Method Details

### - (`Object`) GetPortName(port_to_be_checked)

Function returns port name of port number got as parameter. If no port name found, nil is returned.

    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    # File '../../src/include/firewall/generalfunctions.rb', line 40

    def GetPortName(port_to_be_checked)
      if port_to_be_checked == ""
        Builtins.y2error("Port name/number must be defined")
        return nil
      end
      # if port is a port name, find port number
      if Builtins.regexpmatch(port_to_be_checked, "^[0123456789]+$")
        port_aliases = PortAliases.GetListOfServiceAliases(port_to_be_checked)
        # clear port name
        port_to_be_checked = nil
        Builtins.foreach(port_aliases) do |port_alias|
          # if found port name in aliases, assigning port name instead of port number
          if !Builtins.regexpmatch(port_alias, "^[0123456789]+$")
            port_to_be_checked = port_alias
            raise Break
          end
        end
      end

      port_to_be_checked
    end

### - (`Object`) initialize_firewall_generalfunctions(include_target)

    32
    33
    34
    35
    36
    # File '../../src/include/firewall/generalfunctions.rb', line 32

    def initialize_firewall_generalfunctions(include_target)
      textdomain "firewall"

      Yast.import "PortAliases"
    end