Serializes a chunk into a stream by writing all bytes representing the chunk at the end of the stream.
30 if (
auto authenticationFrame = dynamicPtrCast<const Ieee80211AuthenticationFrame>(chunk)) {
33 stream.writeUint16Be(0);
35 stream.writeUint16Be(authenticationFrame->getSequenceNumber());
37 stream.writeUint16Be(authenticationFrame->getStatusCode());
41 else if (
auto deauthenticationFrame = dynamicPtrCast<const Ieee80211DeauthenticationFrame>(chunk)) {
43 stream.writeUint16Be(deauthenticationFrame->getReasonCode());
45 else if (
auto disassociationFrame = dynamicPtrCast<const Ieee80211DisassociationFrame>(chunk)) {
47 stream.writeUint16Be(disassociationFrame->getReasonCode());
49 else if (
auto probeRequestFrame = dynamicPtrCast<const Ieee80211ProbeRequestFrame>(chunk)) {
52 const char *SSID = probeRequestFrame->getSSID();
53 unsigned int length = strlen(SSID);
55 stream.writeByte(length);
56 stream.writeBytes((uint8_t *)SSID,
B(length));
58 const Ieee80211SupportedRatesElement& supportedRates = probeRequestFrame->getSupportedRates();
60 stream.writeByte(supportedRates.numRates);
61 for (
int i = 0; i < supportedRates.numRates; i++) {
62 uint8_t rate = ceil(supportedRates.rate[i] / 0.5);
64 stream.writeByte(rate);
70 else if (
auto associationRequestFrame = dynamicPtrCast<const Ieee80211AssociationRequestFrame>(chunk)) {
73 stream.writeUint16Be(0);
75 stream.writeUint16Be(0);
77 const char *SSID = associationRequestFrame->getSSID();
78 unsigned int length = strlen(SSID);
80 stream.writeByte(length);
81 stream.writeBytes((uint8_t *)SSID,
B(length));
83 const Ieee80211SupportedRatesElement& supportedRates = associationRequestFrame->getSupportedRates();
85 stream.writeByte(supportedRates.numRates);
86 for (
int i = 0; i < supportedRates.numRates; i++) {
87 uint8_t rate = ceil(supportedRates.rate[i] / 0.5);
89 stream.writeByte(rate);
98 else if (
auto reassociationRequestFrame = dynamicPtrCast<const Ieee80211ReassociationRequestFrame>(chunk)) {
101 stream.writeUint16Be(0);
103 stream.writeUint16Be(0);
105 stream.writeMacAddress(reassociationRequestFrame->getCurrentAP());
107 const char *SSID = reassociationRequestFrame->getSSID();
108 unsigned int length = strlen(SSID);
111 stream.writeByte(length);
112 stream.writeBytes((uint8_t *)SSID,
B(length));
114 const Ieee80211SupportedRatesElement& supportedRates = reassociationRequestFrame->getSupportedRates();
116 stream.writeByte(supportedRates.numRates);
117 for (
int i = 0; i < supportedRates.numRates; i++) {
118 uint8_t rate = ceil(supportedRates.rate[i] / 0.5);
120 stream.writeByte(rate);
129 else if (
auto associationResponseFrame = dynamicPtrCast<const Ieee80211AssociationResponseFrame>(chunk)) {
132 stream.writeUint16Be(0);
134 stream.writeUint16Be(associationResponseFrame->getStatusCode());
136 stream.writeUint16Be(associationResponseFrame->getAid());
139 stream.writeByte(associationResponseFrame->getSupportedRates().numRates);
140 for (
int i = 0; i < associationResponseFrame->getSupportedRates().numRates; i++) {
141 uint8_t rate = ceil(associationResponseFrame->getSupportedRates().rate[i] / 0.5);
143 stream.writeByte(rate);
149 else if (
auto reassociationResponseFrame = dynamicPtrCast<const Ieee80211ReassociationResponseFrame>(chunk)) {
152 stream.writeUint16Be(0);
154 stream.writeUint16Be(reassociationResponseFrame->getStatusCode());
156 stream.writeUint16Be(reassociationResponseFrame->getAid());
159 stream.writeByte(reassociationResponseFrame->getSupportedRates().numRates);
160 for (
int i = 0; i < reassociationResponseFrame->getSupportedRates().numRates; i++) {
161 uint8_t rate = ceil(reassociationResponseFrame->getSupportedRates().rate[i] / 0.5);
163 stream.writeByte(rate);
169 else if (
auto beaconFrame = dynamicPtrCast<const Ieee80211BeaconFrame>(chunk)) {
172 stream.writeUint64Be(simTime().raw());
174 stream.writeUint16Be((uint16_t)(beaconFrame->getBeaconInterval().inUnit(SIMTIME_US) / 1024));
176 stream.writeUint16Be(0);
178 const char *SSID = beaconFrame->getSSID();
179 unsigned int length = strlen(SSID);
181 stream.writeByte(length);
182 stream.writeBytes((uint8_t *)SSID,
B(length));
185 stream.writeByte(beaconFrame->getSupportedRates().numRates);
186 for (
int i = 0; i < beaconFrame->getSupportedRates().numRates; i++) {
187 uint8_t rate = ceil(beaconFrame->getSupportedRates().rate[i] / 0.5);
189 stream.writeByte(rate);
212 else if (
auto probeResponseFrame = dynamicPtrCast<const Ieee80211ProbeResponseFrame>(chunk)) {
215 stream.writeUint64Be(simTime().raw());
217 stream.writeUint16Be((uint16_t)(probeResponseFrame->getBeaconInterval().inUnit(SIMTIME_US) / 1024));
219 stream.writeUint16Be(0);
221 const char *SSID = probeResponseFrame->getSSID();
222 unsigned int length = strlen(SSID);
224 stream.writeByte(length);
225 stream.writeBytes((uint8_t *)SSID,
B(length));
228 stream.writeByte(probeResponseFrame->getSupportedRates().numRates);
229 for (
int i = 0; i < probeResponseFrame->getSupportedRates().numRates; i++) {
230 uint8_t rate = ceil(probeResponseFrame->getSupportedRates().rate[i] / 0.5);
232 stream.writeByte(rate);
255 throw cRuntimeError(
"Cannot serialize frame");