202 auto position = stream.getPosition();
203 unsigned char type = stream.readByte();
204 unsigned char length = 1;
208 return new Ipv4OptionEnd();
211 return new Ipv4OptionNop();
214 length = stream.readByte();
216 auto *option =
new Ipv4OptionStreamId();
217 option->setType(
type);
218 option->setLength(length);
219 option->setStreamId(stream.readUint16Be());
225 length = stream.readByte();
226 uint8_t pointer = stream.readByte();
227 uint8_t flagbyte = stream.readByte();
228 uint8_t overflow = flagbyte >> 4;
231 switch (flagbyte & 0x0f) {
237 if (flag !=
static_cast<TimestampFlag>(-1) && length > 4 && bytes && ((length - 4) % bytes) == 0 && pointer >= 5 && ((pointer - 5) % bytes) == 0) {
238 auto *option =
new Ipv4OptionTimestamp();
239 option->setType(
type);
240 option->setLength(length);
241 option->setFlag(flag);
242 option->setOverflow(overflow);
243 option->setRecordTimestampArraySize((length - 4) / bytes);
245 option->setRecordAddressArraySize((length - 4) / bytes);
246 option->setNextIdx((pointer - 5) / bytes);
247 for (
unsigned int count = 0;
count < option->getRecordAddressArraySize();
count++) {
249 option->setRecordAddress(
count, stream.readIpv4Address());
250 option->setRecordTimestamp(
count, SimTime(stream.readUint32Be(), SIMTIME_MS));
260 length = stream.readByte();
261 uint8_t pointer = stream.readByte();
262 if (length > 3 && (length % 4) == 3 && pointer >= 4 && (pointer % 4) == 0) {
263 auto *option =
new Ipv4OptionRecordRoute();
264 option->setType(
type);
265 option->setLength(length);
266 option->setRecordAddressArraySize((length - 3) / 4);
267 option->setNextAddressIdx((pointer - 4) / 4);
268 for (
unsigned int count = 0;
count < option->getRecordAddressArraySize();
count++) {
269 option->setRecordAddress(
count, stream.readIpv4Address());
277 length = stream.readByte();
279 auto *option =
new Ipv4OptionRouterAlert();
280 option->setType(
type);
281 option->setLength(length);
282 option->setRouterAlert(stream.readUint16Be());
289 length = stream.readByte();
293 auto *option =
new TlvOptionRaw();
294 stream.seek(position);
295 type = stream.readByte();
296 length = stream.readByte();
297 option->setType(
type);
298 option->setLength(length);
300 option->setBytesArraySize(length - 2);
301 for (
unsigned int i = 2; i < length; i++)
302 option->setBytes(i - 2, stream.readByte());