Skip to content
This repository has been archived by the owner on Sep 23, 2020. It is now read-only.

Commit

Permalink
Proposed fix for bug7084: Explicit MAC persistence
Browse files Browse the repository at this point in the history
Avoided adding extra field to network assoc database table by encoding whether MAC is explicit in the MAC field itself (prefixed with 'X'). Since we aren't likely changing anything else in the schema for 2.6, this seems reasonable and simplifies upgrading. Up for discussion, however.
  • Loading branch information
labisso committed Sep 24, 2010
1 parent 1d4387b commit 456b63b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Expand Up @@ -1741,6 +1741,16 @@ public synchronized Hashtable currentAssociations(boolean cachedIsFine)
rs2.getString(6),
rs2.getString(7));
entry.setInUse(rs2.getBoolean(8));

// Encoding that MAC is explicit in the MAC field itself.
// better to introduce a new field to schema?
String mac = entry.getMac();
if (mac.startsWith(AssociationPersistenceUtil.EXPLICIT_MAC_PREFIX)) {
mac = mac.substring(AssociationPersistenceUtil.EXPLICIT_MAC_PREFIX.length());
entry.setMac(mac);
entry.setExplicitMac(true);
}

entries.add(entry);
}
assoc.setEntries(entries);
Expand Down
Expand Up @@ -31,6 +31,8 @@
public class AssociationPersistenceUtil
implements PersistenceAdapterConstants {

public static final String EXPLICIT_MAC_PREFIX = "X";

// not necessary to switch to prep statement, this only happens at startup
public static String[] insertAllAssociationsSQL(Hashtable associations) {

Expand Down Expand Up @@ -79,7 +81,9 @@ public static String[] insertAllAssociationsSQL(Hashtable associations) {
append("'");

if (entry.getMac() != null) {
// Prefix explicit MAC addresses so they can be detected on load
buf.append(", '").
append(entry.isExplicitMac() ? EXPLICIT_MAC_PREFIX : "").
append(entry.getMac()).
append("'");
} else {
Expand Down

0 comments on commit 456b63b

Please sign in to comment.