Exemplo n.º 1
0
  public Conversation insertNewConversation(long rmt_ip, int lcl_port, int rmt_port) {
    gc();

    Conversation conv = new Conversation(rmt_ip, lcl_port, rmt_port);

    modLong.setLong(rmt_ip);
    modInt.setInt((lcl_port << 16) | (rmt_port & 0xFFFF));

    ModInteger mInt = new ModInteger();
    mInt.setInt((lcl_port << 16) | (rmt_port & 0xFFFF));

    HashMap portsMap = (HashMap) hostsMap.get(modLong);
    if (portsMap == null) {
      ModLong mLong = new ModLong();

      mLong.setLong(rmt_ip);
      portsMap = new HashMap();
      hostsMap.put(mLong, portsMap);
    }
    portsMap.put(mInt, conv);
    allConversations.add(conv);
    hasChanged = true;

    return conv;
  }
Exemplo n.º 2
0
  public Conversation findConversation(long rmt_ip, int lcl_port, int rmt_port) {
    modLong.setLong(rmt_ip);
    modInt.setInt((lcl_port << 16) | (rmt_port & 0xFFFF));

    Conversation conv = null;

    HashMap portsMap = (HashMap) hostsMap.get(modLong);
    if (portsMap != null) {
      conv = (Conversation) portsMap.get(modInt);
    }

    if (conv != null) {
      return conv;
    }

    return insertNewConversation(rmt_ip, lcl_port, rmt_port);
  }
Exemplo n.º 3
0
  public Conversation removeConversation(long rmt_ip, int lcl_port, int rmt_port) {
    modLong.setLong(rmt_ip);
    modInt.setInt((lcl_port << 16) | (rmt_port & 0xFFFF));

    HashMap portsMap = (HashMap) hostsMap.get(modLong);
    Conversation conv = null;

    if (portsMap != null) {
      conv = (Conversation) portsMap.remove(modInt);
      if (conv != null) {
        if (portsMap.size() == 0) {
          hostsMap.remove(modLong);
        }
      }
    }

    allConversations.remove(conv);

    return conv;
  }