List of usage examples for io.netty.buffer Unpooled buffer
public static ByteBuf buffer()
From source file:DescriptorTester.java
License:Open Source License
public ByteBuf resultCodeTester() { ODLCapwapMessage msg = null;//from w w w.ja va 2s.c o m ByteBuf buf = Unpooled.buffer(); msg = new ODLCapwapMessage(); ResultCode l = new ResultCode(); l.setResultCode(12345); msg.ctrlMsg.addMessageElement(l); msg.ctrlMsg.setMsgType(ODLCapwapConsts.ODL_CAPWAP_DISCOVERY_REQUEST); msg.ctrlMsg.setSeqNo((short) 1); msg.header.encodeHeader(buf); msg.ctrlMsg.encode(buf); return buf; }
From source file:DescriptorTester.java
License:Open Source License
public ByteBuf returnedMsgElementTester() { ODLCapwapMessage msg = null;//from w ww . j a va 2 s. c o m ByteBuf buf = Unpooled.buffer(); msg = new ODLCapwapMessage(); ReturnedMessageElement r = new ReturnedMessageElement(); r.setReason((short) 1); byte[] address = new byte[] { 0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; r.setMsgElement(address); msg.ctrlMsg.addMessageElement(r); msg.ctrlMsg.setMsgType(ODLCapwapConsts.ODL_CAPWAP_DISCOVERY_REQUEST); msg.ctrlMsg.setSeqNo((short) 1); msg.header.encodeHeader(buf); msg.ctrlMsg.encode(buf); return buf; }
From source file:DescriptorTester.java
License:Open Source License
public ByteBuf fallBackModeTester() { ODLCapwapMessage msg = null;/*ww w . ja v a 2s . co m*/ ByteBuf buf = Unpooled.buffer(); msg = new ODLCapwapMessage(); WtpFallBack fb = new WtpFallBack(); fb.setMode(2); msg.ctrlMsg.addMessageElement(fb); msg.ctrlMsg.addMessageElement(fb); msg.ctrlMsg.addMessageElement(fb); msg.ctrlMsg.setMsgType(ODLCapwapConsts.ODL_CAPWAP_JOIN_REQUEST); msg.ctrlMsg.setSeqNo((short) 1); // msg.header.setMbit(); msg.header.setFragId(2); msg.header.setFragOffset(8190); MacAddress mac = new MacAddress(); byte[] address = new byte[6]; address[0] = 12; address[1] = 52; address[2] = 32; address[3] = 42; address[4] = 72; address[5] = 92; mac.setAddress(address); msg.header.setRadioMacAddress(mac); WsiInfo wsi = new WsiInfo(); msg.header.setWbit(); byte[] wsiData = new byte[8]; address[0] = 12; address[1] = 52; address[2] = 32; address[3] = 42; address[4] = 72; address[5] = 92; wsi.setData(wsiData); msg.header.setWsiInfo(wsi); msg.header.encodeHeader(buf); msg.ctrlMsg.encode(buf); return buf; }
From source file:DescriptorTester.java
License:Open Source License
public void encodeDecodeTester(ODLCapwapMessage o, ODLCapwapMessage n) { //encode new message //decode new message //compare it new new message with old message ByteBuf buf = Unpooled.buffer(); n.header.encodeHeader(buf);/*w w w.ja v a 2 s .c o m*/ n.ctrlMsg.encode(buf); StackTraceElement bTop = Thread.currentThread().getStackTrace()[1]; ODLCapwapMessage nn = ODLCapwapMessageFactory.decodeFromByteArray(buf); if (compareMessage(o, nn)) { LOG.info("Decoding SUCCESS {}:", getFunctionName(bTop)); } { LOG.error("Decoding failed {}:", getFunctionName(bTop)); } }
From source file:DescriptorTester.java
License:Open Source License
public boolean allDescriptorTester(int dType) { ByteBuf buf = Unpooled.buffer(); boolean result = false; switch (dType) { case ODLCapwapConsts.CAPWAP_ELMT_TYPE_AC_NAME: result = AcNameDescriptorTest(buf); if (!result) { return false; }//from ww w.j av a 2 s .c o m sender(buf); break; case ODLCapwapConsts.CAPWAP_ELMT_TYPE_CAPWAP_CONTROL_IPV4_ADDR: result = IPV4ControlDescriptorTest(buf); if (!result) { return false; } sender(buf); break; case ODLCapwapConsts.CAPWAP_ELMT_TYPE_RESULT_CODE: result = resultCodeTest(buf); if (!result) { return false; } sender(buf); break; case ODLCapwapConsts.CAPWAP_ELMT_TYPE_CAPWAP_LOCAL_IPV4_ADDR: result = localIPV4DescriptorTest(buf); if (!result) { return false; } sender(buf); break; case ODLCapwapConsts.CAPWAP_ELMT_TYPE_ECN_SUPPORT: result = ECNTest(buf); if (!result) { return false; } sender(buf); break; case ODLCapwapConsts.CAPWAP_ELMT_TYPE_SESSION_ID: result = sessionIdTester(buf); if (!result) { return false; } sender(buf); break; case ODLCapwapConsts.CAPWAP_ELMT_TYPE_WTP_NAME: result = wtpNameTester(buf); if (!result) { return false; } sender(buf); break; case ODLCapwapConsts.CAPWAP_ELMT_TYPE_STATISTICS_TIMER: result = statisticsTimerTester(buf); if (!result) { return false; } sender(buf); break; case ODLCapwapConsts.CAPWAP_ELMT_TYPE_MAX_MESSAGE_LENGTH: result = maxLenTester(buf); if (!result) { return false; } sender(buf); break; case ODLCapwapConsts.CAPWAP_ELMT_TYPE_WTP_REBOOT_STATS: result = WtpReootStatisticsTeaster(buf); if (!result) { return false; } sender(buf); break; case ODLCapwapConsts.CAPWAP_ELMT_TYPE_AC_IPV4_LIST: result = IPV4ListDescriptorTest(buf); if (!result) { return false; } sender(buf); break; case ODLCapwapConsts.CAPWAP_ELMT_TYPE_CAPWAP_TRANSPORT_PROTO: result = CapwapProtocolTester(buf); if (!result) { return false; } sender(buf); break; case ODLCapwapConsts.CAPWAP_ELMT_TYPE_IMAGE_IDENTIFIER: result = imageIdentifierTester(buf); if (!result) { return false; } sender(buf); break; case ODLCapwapConsts.CAPWAP_ELMT_TYPE_VENDOR_SPECIFIC_PAYLOAD: result = VendorSpecificPayloadTester(buf); if (!result) { return false; } sender(buf); break; case ODLCapwapConsts.CAPWAP_ELMT_TYPE_WTP_DESCRIPTOR: result = WtpDesciptorTester(buf); if (!result) { return false; } sender(buf); break; case ODLCapwapConsts.CAPWAP_ELMT_TYPE_DISCOVERY_TYPE: result = DiscoveryDescriptorTest(buf); if (!result) { return false; } sender(buf); break; case ODLCapwapConsts.IEEE_80211_WTP_RADIO_INFORMATION: result = wtpRadioInfoTester(buf); if (!result) { return false; } sender(buf); break; case ODLCapwapConsts.CAPWAP_ELMT_TYPE_AC_DESCRIPTOR: result = ACDescriptorTest(buf); if (!result) { return false; } sender(buf); break; default: } return true; }
From source file:TestDescriptor.java
License:Open Source License
@Test public void AddWlanTester() { StackTraceElement bTop = Thread.currentThread().getStackTrace()[1]; ODLCapwapMessage msg = null;/* w w w.j a v a2s. co m*/ ODLCapwapMessage n = null; msg = new ODLCapwapMessage(); AddWlan addWlan = new AddWlan(); System.out.println("AddWlanTester: type = " + addWlan.getType()); addWlan.setRadioId((byte) 2); addWlan.setWlanId((byte) 12); //addWlan.setCapability(343); addWlan.setCapabilityEbit(); System.out.println("Capability = " + addWlan.getCapability()); System.out.println("Capability set = " + addWlan.isCapabilityEbitSet()); addWlan.unsetCapabilityEbit(); System.out.println("Capability = " + addWlan.getCapability()); System.out.println("Capability set = " + addWlan.isCapabilityEbitSet()); addWlan.setCapabilityAbit(); addWlan.setCapabilityBbit(); addWlan.setCapabilityCbit(); addWlan.setCapabilityDbit(); addWlan.setCapabilityEbit(); addWlan.setCapabilityFbit(); addWlan.setCapabilityIbit(); addWlan.setCapabilityKbit(); addWlan.setCapabilityLbit(); addWlan.setCapabilityMbit(); addWlan.setCapabilityObit(); addWlan.setCapabilityPbit(); addWlan.setCapabilityQbit(); addWlan.setCapabilitySbit(); addWlan.setCapabilityTbit(); addWlan.setCapabilityVbit(); System.out.println("Capability = " + addWlan.getCapability()); addWlan.setKeyIndex((byte) 78); addWlan.setKeyStatus((byte) 1); byte[] key = new byte[4]; key[0] = 1; key[1] = 2; key[2] = 3; key[3] = 4; addWlan.setKey(key); byte[] groupTsc = new byte[6]; groupTsc[0] = 1; groupTsc[1] = 2; groupTsc[2] = 3; groupTsc[3] = 4; groupTsc[4] = 5; groupTsc[5] = 6; addWlan.setGroupTsc(groupTsc); addWlan.setQos((byte) 2); addWlan.setAuthType((byte) 1); addWlan.setMacMode((byte) 0); addWlan.setTunnelMode((byte) 2); addWlan.setSuppressSSID((byte) 1); byte[] ssId = new byte[4]; ssId[0] = 100; ssId[1] = 101; ssId[2] = 102; ssId[3] = 104; addWlan.setSsId(ssId); msg.ctrlMsg.addMessageElement(addWlan); msg.ctrlMsg.setMsgType(ODLCapwapConsts.ODL_CAPWAP_DISCOVERY_REQUEST); msg.ctrlMsg.setSeqNo((short) 1); ByteBuf buf = Unpooled.buffer(); msg.header.encodeHeader(buf); msg.ctrlMsg.encode(buf); n = ODLCapwapMessageFactory.decodeFromByteArray(buf); sender(buf); Assert.assertEquals(msg, n); }
From source file:TestDescriptor.java
License:Open Source License
@Test public void SessionIdTester() { StackTraceElement bTop = Thread.currentThread().getStackTrace()[1]; ODLCapwapMessage msg = null;//from ww w .j a v a 2 s . c o m ODLCapwapMessage n = null; msg = new ODLCapwapMessage(); SessionID sess = new SessionID(); byte[] address = new byte[16]; address[12] = 32; address[1] = 32; address[5] = 32; address[2] = 32; address[8] = 62; address[7] = 32; sess.setSessionid(address); msg.ctrlMsg.addMessageElement(sess); msg.ctrlMsg.setMsgType(ODLCapwapConsts.ODL_CAPWAP_DISCOVERY_REQUEST); msg.ctrlMsg.setSeqNo((short) 1); ByteBuf buf = Unpooled.buffer(); msg.header.encodeHeader(buf); msg.ctrlMsg.encode(buf); n = ODLCapwapMessageFactory.decodeFromByteArray(buf); sender(buf); Assert.assertEquals(msg, n); }
From source file:TestDescriptor.java
License:Open Source License
@Test public void wtpNameTester() { StackTraceElement bTop = Thread.currentThread().getStackTrace()[1]; ODLCapwapMessage msg = null;//from w ww . ja v a 2s. com ODLCapwapMessage n = null; msg = new ODLCapwapMessage(); WTPName name = new WTPName(); byte[] address = new byte[16]; address[12] = 32; address[1] = 32; address[5] = 32; address[2] = 32; address[8] = 62; address[7] = 32; name.setName(address); msg.ctrlMsg.addMessageElement(name); msg.ctrlMsg.setMsgType(ODLCapwapConsts.ODL_CAPWAP_DISCOVERY_REQUEST); msg.ctrlMsg.setSeqNo((short) 1); ByteBuf buf = Unpooled.buffer(); msg.header.encodeHeader(buf); msg.ctrlMsg.encode(buf); n = ODLCapwapMessageFactory.decodeFromByteArray(buf); sender(buf); Assert.assertEquals(msg, n); }
From source file:TestDescriptor.java
License:Open Source License
@Test public void WtpDesciptorTester() { StackTraceElement bTop = Thread.currentThread().getStackTrace()[1]; ODLCapwapMessage msg = null;/*from w w w. ja v a2s . com*/ ODLCapwapMessage n = null; DiscoveryType discoveryType = null; ACDescriptor acDescriptor = null; msg = new ODLCapwapMessage(); //create Discovery Type discoveryType = new DiscoveryType(); discoveryType.setDhcp(); msg.ctrlMsg.addMessageElement(discoveryType); //create WtpDescriptor WtpDescriptor wtpDescriptor = new WtpDescriptor(); wtpDescriptor.setMaxRadios((short) 12).setRadioInUse((short) 4); EncryptionSubElement e = new EncryptionSubElement((byte) 1, 12); EncryptionSubElement e1 = new EncryptionSubElement((byte) 2, 10); wtpDescriptor.addEncryptSubElement(e); wtpDescriptor.addEncryptSubElement(e1); DescriptorSubElement d = new DescriptorSubElement(128); d.setVendorId(120).setDescType(13); DescriptorSubElement d1 = new DescriptorSubElement(64); d1.setVendorId(110).setDescType(10); wtpDescriptor.addDescriptorSubElm(d); wtpDescriptor.addDescriptorSubElm(d1); msg.ctrlMsg.addMessageElement(wtpDescriptor); msg.ctrlMsg.setMsgType(ODLCapwapConsts.ODL_CAPWAP_DISCOVERY_REQUEST); msg.ctrlMsg.setSeqNo((short) 1); ByteBuf buf = Unpooled.buffer(); msg.header.encodeHeader(buf); msg.ctrlMsg.encode(buf); n = ODLCapwapMessageFactory.decodeFromByteArray(buf); sender(buf); Assert.assertEquals(msg, n); }
From source file:TestDescriptor.java
License:Open Source License
@Test public void frameTunnelModeTester() { StackTraceElement bTop = Thread.currentThread().getStackTrace()[1]; ODLCapwapMessage msg = null;/*from w ww . j a v a2 s . c o m*/ ODLCapwapMessage n = null; msg = new ODLCapwapMessage(); WtpFrameTunnelModeMsgElem ft = new WtpFrameTunnelModeMsgElem(); ft.setnBit(); msg.ctrlMsg.addMessageElement(ft); msg.ctrlMsg.setMsgType(ODLCapwapConsts.ODL_CAPWAP_DISCOVERY_REQUEST); msg.ctrlMsg.setSeqNo((short) 1); ByteBuf buf = Unpooled.buffer(); msg.header.encodeHeader(buf); msg.ctrlMsg.encode(buf); n = ODLCapwapMessageFactory.decodeFromByteArray(buf); sender(buf); Assert.assertEquals(msg, n); }