Пример #1
0
  /**
   * Parses a physical interface, expects to find a mac address and interface.
   *
   * <p>Sample, ( set brackets delimit important data )
   *
   * <pre>
   * {{FastEthernet0/3}} is down,
   *   line protocol is down (notconnect) Hardware is Fast Ethernet, address is {{000e.831e.7283}} (bia 000e.831e.7283)
   * </pre>
   *
   * @param r Reader for the open input file.
   * @param line Line such as above.
   * @param data TopologySource data for the entire import.
   */
  private void parsePhysical(BufferedReader r, String line, PhysicalNode data) throws IOException {
    String ifaText = SubParser.getFirstWord(line);

    /** next line expects ' Hardware is EtherSVI, address is 000e.831e.7280 (bia 000e.831e.7280)' */
    line = r.readLine().replaceAll("^.*?address.is.", "");
    String macText = SubParser.getFirstWord(line);
    Mac mac = new Mac(macText);

    Port p = data.getPort(new Port(data, ifaText, mac));
  }
Пример #2
0
  /**
   * Parsed a vlan, expects to find, mac, ip, and vlan id.
   *
   * <p>Sample, ( set brackets delimit important data )
   *
   * <pre>
   * Vlan{{1}} is up, line
   *   protocol is down Hardware is EtherSVI, address is {{000e.831e.7280}} (bia 000e.831e.7280)
   *   Internet address is {{192.168.0.3}}/24
   * </pre>
   *
   * @param r Reader for the open input file.
   * @param line Line such as above.
   * @param data TopologySource data for the entire import.
   */
  private void parseVirtual(BufferedReader r, String line, PhysicalNode data) throws IOException {
    String vlanId = SubParser.getFirstWord(line.replaceAll("^\\D+", ""));

    Vlan vlan = data.getVlan(Integer.valueOf(vlanId));

    /** next line expects ' Hardware is EtherSVI, address is 000e.831e.7280 (bia 000e.831e.7280)' */
    line = r.readLine().replaceAll("^.*?address.is.", "");
    String macText = SubParser.getFirstWord(line);
    Mac mac = new Mac(macText);

    line = r.readLine().replaceAll("^.*?address.is.", "");
    String ipText = SubParser.getFirstWord(line);
    Ip ip = new Ip.Ip4(ipText);

    vlan.macs.add(mac);
  }