Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for port aggregation #182

Merged
merged 4 commits into from
Mar 8, 2023
Merged

Add support for port aggregation #182

merged 4 commits into from
Mar 8, 2023

Commits on Mar 7, 2023

  1. Add support for port aggregation

    Fixes #142
    joshuaspence committed Mar 7, 2023
    Configuration menu
    Copy the full SHA
    b82692e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    79efacb View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    9379ba6 View commit details
    Browse the repository at this point in the history

Commits on Mar 8, 2023

  1. Add tests

    Note that only switches with a Broadcom, Microsemi or Nephos chipset support both port mirroring and port aggregation.
    
    ```java
    package com.ubnt.data;
    
    public class Device extends X implements Sanitizable
    {
    
      // ...
    
      public int getMaxMirrorSession() {
        int n = 0;
        if (this.getModel() == Model.\u00f8\u00f50000) {
          n = 2;
        }
        else if (this.isBroadcomSwitch() || this.isMicrosemiSwitch() || this.isMediaTekSwitch() || this.isNephosSwitch()) {
          n = 1;
        }
        return this.thisforObject().getInt("max_mirror_sessions", n);
      }
    
      public int getMaxAggregation() {
        int n = 0;
        if (this.isBroadcomSwitch() || this.isMicrosemiSwitch() || this.isNephosSwitch()) {
          n = 6;
        }
        return this.thisforObject().getInt("max_aggregate_sessions", n);
      }
    
      // ...
    
      public boolean isBroadcomSwitch() {
        final Model model = this.getModel();
        return model.getChipset().typeOf(Chipset.\u00f400000) && model.getType() == DeviceType.if;
      }
    
      public boolean isMicrosemiSwitch() {
        final Model model = this.getModel();
        return model.getChipset().typeOf(Chipset.o00000) && model.getType() == DeviceType.if;
      }
    
      public boolean isMediaTekSwitch() {
        final Model model = this.getModel();
        return model.getChipset().typeOf(Chipset.\u00d3O0000) && model.getType() == DeviceType.if;
      }
    
      public boolean isNephosSwitch() {
        final Model model = this.getModel();
        return model.getChipset().typeOf(Chipset.\u00d5O0000) && model.getType() == DeviceType.if;
      }
    
      // ...
    
    }
    ```
    
    To extract the list of models that use one of these chipsets I used the following script (executed as `java --class-path path/to/ace.jar main.java`):
    
    ```java
    import com.ubnt.data.Model;
    
    class UniFiModels {
      public static void main(String[] args) {
        /*
        for (Model model : Model.values()) {
          System.out.printf(
              "Model = %s\nSKU = %s\nType = %s\nFeatures = %s\nChipset = %s\nSysId = %s\nPortNum = %s\n\n",
              model,
              model.getSku(),
              model.getType(),
              model.getFeatures(),
              model.getChipset(),
              model.getSysId(),
              model.getPortNum());
        }
        */
    
        for (Model model : Model.values()) {
          System.out.printf("%s: %s (%s)\n", model.getChipset(), model, model.getSku());
        }
      }
    }
    
    ```
    joshuaspence committed Mar 8, 2023
    Configuration menu
    Copy the full SHA
    431a234 View commit details
    Browse the repository at this point in the history