1 package com.android.server.wifi.anqp; 2 3 import com.android.server.wifi.hotspot2.Utils; 4 5 import java.net.ProtocolException; 6 import java.nio.ByteBuffer; 7 import java.nio.ByteOrder; 8 import java.util.ArrayList; 9 import java.util.Collections; 10 import java.util.List; 11 12 import static com.android.server.wifi.anqp.Constants.BYTE_MASK; 13 import static com.android.server.wifi.anqp.Constants.getInteger; 14 15 /** 16 * The Roaming Consortium ANQP Element, IEEE802.11-2012 section 8.4.4.7 17 */ 18 public class RoamingConsortiumElement extends ANQPElement { 19 20 private final List<Long> mOis; 21 22 public RoamingConsortiumElement(Constants.ANQPElementType infoID, ByteBuffer payload) 23 throws ProtocolException { 24 super(infoID); 25 26 mOis = new ArrayList<Long>(); 27 28 while (payload.hasRemaining()) { 29 int length = payload.get() & BYTE_MASK; 30 if (length > payload.remaining()) { 31 throw new ProtocolException("Bad OI length: " + length); 32 } 33 mOis.add(getInteger(payload, ByteOrder.BIG_ENDIAN, length)); 34 } 35 } 36 37 public List<Long> getOIs() { 38 return Collections.unmodifiableList(mOis); 39 } 40 41 @Override 42 public String toString() { 43 return "RoamingConsortium{mOis=[" + Utils.roamingConsortiumsToString(mOis) + "]}"; 44 } 45 } 46