-rw-r--r-- | libopie2/opienet/opcap.cpp | 7 | ||||
-rw-r--r-- | libopie2/opienet/opcap.h | 2 |
2 files changed, 9 insertions, 0 deletions
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp index 313f5bb..9ed2b83 100644 --- a/libopie2/opienet/opcap.cpp +++ b/libopie2/opienet/opcap.cpp | |||
@@ -333,384 +333,391 @@ QString OARPPacket::type() const | |||
333 | { | 333 | { |
334 | switch ( EXTRACT_16BITS( &_arphdr->ar_op ) ) | 334 | switch ( EXTRACT_16BITS( &_arphdr->ar_op ) ) |
335 | { | 335 | { |
336 | case 1: return "REQUEST"; | 336 | case 1: return "REQUEST"; |
337 | case 2: return "REPLY"; | 337 | case 2: return "REPLY"; |
338 | case 3: return "RREQUEST"; | 338 | case 3: return "RREQUEST"; |
339 | case 4: return "RREPLY"; | 339 | case 4: return "RREPLY"; |
340 | case 8: return "InREQUEST"; | 340 | case 8: return "InREQUEST"; |
341 | case 9: return "InREPLY"; | 341 | case 9: return "InREPLY"; |
342 | case 10: return "NAK"; | 342 | case 10: return "NAK"; |
343 | default: qWarning( "OARPPacket::type(): invalid ARP type!" ); return "<unknown>"; | 343 | default: qWarning( "OARPPacket::type(): invalid ARP type!" ); return "<unknown>"; |
344 | } | 344 | } |
345 | } | 345 | } |
346 | 346 | ||
347 | 347 | ||
348 | QHostAddress OARPPacket::senderIPV4Address() const | 348 | QHostAddress OARPPacket::senderIPV4Address() const |
349 | { | 349 | { |
350 | return EXTRACT_32BITS( &_arphdr->ar_sip ); | 350 | return EXTRACT_32BITS( &_arphdr->ar_sip ); |
351 | } | 351 | } |
352 | 352 | ||
353 | 353 | ||
354 | QHostAddress OARPPacket::targetIPV4Address() const | 354 | QHostAddress OARPPacket::targetIPV4Address() const |
355 | { | 355 | { |
356 | return EXTRACT_32BITS( &_arphdr->ar_tip ); | 356 | return EXTRACT_32BITS( &_arphdr->ar_tip ); |
357 | } | 357 | } |
358 | 358 | ||
359 | 359 | ||
360 | OMacAddress OARPPacket::senderMacAddress() const | 360 | OMacAddress OARPPacket::senderMacAddress() const |
361 | { | 361 | { |
362 | return OMacAddress( _arphdr->ar_sha ); | 362 | return OMacAddress( _arphdr->ar_sha ); |
363 | } | 363 | } |
364 | 364 | ||
365 | 365 | ||
366 | OMacAddress OARPPacket::targetMacAddress() const | 366 | OMacAddress OARPPacket::targetMacAddress() const |
367 | { | 367 | { |
368 | return OMacAddress( _arphdr->ar_tha ); | 368 | return OMacAddress( _arphdr->ar_tha ); |
369 | } | 369 | } |
370 | 370 | ||
371 | 371 | ||
372 | /*====================================================================================== | 372 | /*====================================================================================== |
373 | * OUDPPacket | 373 | * OUDPPacket |
374 | *======================================================================================*/ | 374 | *======================================================================================*/ |
375 | 375 | ||
376 | 376 | ||
377 | OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QObject* parent ) | 377 | OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QObject* parent ) |
378 | :QObject( parent, "UDP" ), _udphdr( data ) | 378 | :QObject( parent, "UDP" ), _udphdr( data ) |
379 | 379 | ||
380 | { | 380 | { |
381 | qDebug( "OUDPPacket::OUDPPacket(): decoding UDP header..." ); | 381 | qDebug( "OUDPPacket::OUDPPacket(): decoding UDP header..." ); |
382 | qDebug( "fromPort = %d", fromPort() ); | 382 | qDebug( "fromPort = %d", fromPort() ); |
383 | qDebug( " toPort = %d", toPort() ); | 383 | qDebug( " toPort = %d", toPort() ); |
384 | 384 | ||
385 | // TODO: Make this a case or a hash if we know more udp protocols | 385 | // TODO: Make this a case or a hash if we know more udp protocols |
386 | 386 | ||
387 | if ( fromPort() == UDP_PORT_BOOTPS || fromPort() == UDP_PORT_BOOTPC || | 387 | if ( fromPort() == UDP_PORT_BOOTPS || fromPort() == UDP_PORT_BOOTPC || |
388 | toPort() == UDP_PORT_BOOTPS || toPort() == UDP_PORT_BOOTPC ) | 388 | toPort() == UDP_PORT_BOOTPS || toPort() == UDP_PORT_BOOTPC ) |
389 | { | 389 | { |
390 | qDebug( "seems to be part of a DHCP conversation => creating DHCP packet." ); | 390 | qDebug( "seems to be part of a DHCP conversation => creating DHCP packet." ); |
391 | new ODHCPPacket( end, (const struct dhcp_packet*) (data+1), this ); | 391 | new ODHCPPacket( end, (const struct dhcp_packet*) (data+1), this ); |
392 | } | 392 | } |
393 | } | 393 | } |
394 | 394 | ||
395 | 395 | ||
396 | OUDPPacket::~OUDPPacket() | 396 | OUDPPacket::~OUDPPacket() |
397 | { | 397 | { |
398 | } | 398 | } |
399 | 399 | ||
400 | 400 | ||
401 | int OUDPPacket::fromPort() const | 401 | int OUDPPacket::fromPort() const |
402 | { | 402 | { |
403 | return EXTRACT_16BITS( &_udphdr->source ); | 403 | return EXTRACT_16BITS( &_udphdr->source ); |
404 | } | 404 | } |
405 | 405 | ||
406 | 406 | ||
407 | int OUDPPacket::toPort() const | 407 | int OUDPPacket::toPort() const |
408 | { | 408 | { |
409 | return EXTRACT_16BITS( &_udphdr->dest ); | 409 | return EXTRACT_16BITS( &_udphdr->dest ); |
410 | } | 410 | } |
411 | 411 | ||
412 | 412 | ||
413 | int OUDPPacket::length() const | 413 | int OUDPPacket::length() const |
414 | { | 414 | { |
415 | return EXTRACT_16BITS( &_udphdr->len ); | 415 | return EXTRACT_16BITS( &_udphdr->len ); |
416 | } | 416 | } |
417 | 417 | ||
418 | 418 | ||
419 | int OUDPPacket::checksum() const | 419 | int OUDPPacket::checksum() const |
420 | { | 420 | { |
421 | return EXTRACT_16BITS( &_udphdr->check ); | 421 | return EXTRACT_16BITS( &_udphdr->check ); |
422 | } | 422 | } |
423 | 423 | ||
424 | 424 | ||
425 | /*====================================================================================== | 425 | /*====================================================================================== |
426 | * ODHCPPacket | 426 | * ODHCPPacket |
427 | *======================================================================================*/ | 427 | *======================================================================================*/ |
428 | 428 | ||
429 | 429 | ||
430 | ODHCPPacket::ODHCPPacket( const unsigned char* end, const struct dhcp_packet* data, QObject* parent ) | 430 | ODHCPPacket::ODHCPPacket( const unsigned char* end, const struct dhcp_packet* data, QObject* parent ) |
431 | :QObject( parent, "DHCP" ), _dhcphdr( data ) | 431 | :QObject( parent, "DHCP" ), _dhcphdr( data ) |
432 | 432 | ||
433 | { | 433 | { |
434 | qDebug( "ODHCPPacket::ODHCPPacket(): decoding DHCP information..." ); | 434 | qDebug( "ODHCPPacket::ODHCPPacket(): decoding DHCP information..." ); |
435 | qDebug( "DHCP opcode seems to be %02d - '%s'", _dhcphdr->op, isRequest() ? "REQUEST" : "REPLY" ); | 435 | qDebug( "DHCP opcode seems to be %02d - '%s'", _dhcphdr->op, isRequest() ? "REQUEST" : "REPLY" ); |
436 | qDebug( "clientAddress: %s", (const char*) clientAddress().toString() ); | 436 | qDebug( "clientAddress: %s", (const char*) clientAddress().toString() ); |
437 | qDebug( " yourAddress: %s", (const char*) yourAddress().toString() ); | 437 | qDebug( " yourAddress: %s", (const char*) yourAddress().toString() ); |
438 | qDebug( "serverAddress: %s", (const char*) serverAddress().toString() ); | 438 | qDebug( "serverAddress: %s", (const char*) serverAddress().toString() ); |
439 | qDebug( " relayAddress: %s", (const char*) relayAddress().toString() ); | 439 | qDebug( " relayAddress: %s", (const char*) relayAddress().toString() ); |
440 | qDebug( "parsing DHCP options..." ); | 440 | qDebug( "parsing DHCP options..." ); |
441 | 441 | ||
442 | _type = 0; | 442 | _type = 0; |
443 | 443 | ||
444 | const unsigned char* option = &_dhcphdr->options[4]; | 444 | const unsigned char* option = &_dhcphdr->options[4]; |
445 | char tag = -1; | 445 | char tag = -1; |
446 | char len = -1; | 446 | char len = -1; |
447 | 447 | ||
448 | while ( ( tag = *option++ ) != -1 /* end of option field */ ) | 448 | while ( ( tag = *option++ ) != -1 /* end of option field */ ) |
449 | { | 449 | { |
450 | len = *option++; | 450 | len = *option++; |
451 | qDebug( "recognized DHCP option #%d, length %d", tag, len ); | 451 | qDebug( "recognized DHCP option #%d, length %d", tag, len ); |
452 | 452 | ||
453 | if ( tag == DHO_DHCP_MESSAGE_TYPE ) | 453 | if ( tag == DHO_DHCP_MESSAGE_TYPE ) |
454 | _type = *option; | 454 | _type = *option; |
455 | 455 | ||
456 | option += len; | 456 | option += len; |
457 | if ( option >= end ) | 457 | if ( option >= end ) |
458 | { | 458 | { |
459 | qWarning( "DHCP parsing ERROR: sanity check says the packet is at its end!" ); | 459 | qWarning( "DHCP parsing ERROR: sanity check says the packet is at its end!" ); |
460 | break; | 460 | break; |
461 | } | 461 | } |
462 | } | 462 | } |
463 | 463 | ||
464 | qDebug( "DHCP type seems to be '%s'", (const char*) type() ); | 464 | qDebug( "DHCP type seems to be '%s'", (const char*) type() ); |
465 | } | 465 | } |
466 | 466 | ||
467 | 467 | ||
468 | ODHCPPacket::~ODHCPPacket() | 468 | ODHCPPacket::~ODHCPPacket() |
469 | { | 469 | { |
470 | } | 470 | } |
471 | 471 | ||
472 | 472 | ||
473 | bool ODHCPPacket::isRequest() const | 473 | bool ODHCPPacket::isRequest() const |
474 | { | 474 | { |
475 | return ( _dhcphdr->op == 01 ); | 475 | return ( _dhcphdr->op == 01 ); |
476 | } | 476 | } |
477 | 477 | ||
478 | 478 | ||
479 | bool ODHCPPacket::isReply() const | 479 | bool ODHCPPacket::isReply() const |
480 | { | 480 | { |
481 | return ( _dhcphdr->op == 02 ); | 481 | return ( _dhcphdr->op == 02 ); |
482 | } | 482 | } |
483 | 483 | ||
484 | 484 | ||
485 | QString ODHCPPacket::type() const | 485 | QString ODHCPPacket::type() const |
486 | { | 486 | { |
487 | switch ( _type ) | 487 | switch ( _type ) |
488 | { | 488 | { |
489 | case 1: return "DISCOVER"; | 489 | case 1: return "DISCOVER"; |
490 | case 2: return "OFFER"; | 490 | case 2: return "OFFER"; |
491 | case 3: return "REQUEST"; | 491 | case 3: return "REQUEST"; |
492 | case 4: return "DECLINE"; | 492 | case 4: return "DECLINE"; |
493 | case 5: return "ACK"; | 493 | case 5: return "ACK"; |
494 | case 6: return "NAK"; | 494 | case 6: return "NAK"; |
495 | case 7: return "RELEASE"; | 495 | case 7: return "RELEASE"; |
496 | case 8: return "INFORM"; | 496 | case 8: return "INFORM"; |
497 | default: qWarning( "ODHCPPacket::type(): invalid DHCP type (%d) !", _dhcphdr->op ); return "<unknown>"; | 497 | default: qWarning( "ODHCPPacket::type(): invalid DHCP type (%d) !", _dhcphdr->op ); return "<unknown>"; |
498 | } | 498 | } |
499 | } | 499 | } |
500 | 500 | ||
501 | 501 | ||
502 | QHostAddress ODHCPPacket::clientAddress() const | 502 | QHostAddress ODHCPPacket::clientAddress() const |
503 | { | 503 | { |
504 | return EXTRACT_32BITS( &_dhcphdr->ciaddr ); | 504 | return EXTRACT_32BITS( &_dhcphdr->ciaddr ); |
505 | } | 505 | } |
506 | 506 | ||
507 | 507 | ||
508 | QHostAddress ODHCPPacket::yourAddress() const | 508 | QHostAddress ODHCPPacket::yourAddress() const |
509 | { | 509 | { |
510 | return EXTRACT_32BITS( &_dhcphdr->yiaddr ); | 510 | return EXTRACT_32BITS( &_dhcphdr->yiaddr ); |
511 | } | 511 | } |
512 | 512 | ||
513 | 513 | ||
514 | QHostAddress ODHCPPacket::serverAddress() const | 514 | QHostAddress ODHCPPacket::serverAddress() const |
515 | { | 515 | { |
516 | return EXTRACT_32BITS( &_dhcphdr->siaddr ); | 516 | return EXTRACT_32BITS( &_dhcphdr->siaddr ); |
517 | } | 517 | } |
518 | 518 | ||
519 | 519 | ||
520 | QHostAddress ODHCPPacket::relayAddress() const | 520 | QHostAddress ODHCPPacket::relayAddress() const |
521 | { | 521 | { |
522 | return EXTRACT_32BITS( &_dhcphdr->giaddr ); | 522 | return EXTRACT_32BITS( &_dhcphdr->giaddr ); |
523 | } | 523 | } |
524 | 524 | ||
525 | |||
526 | OMacAddress ODHCPPacket::clientMacAddress() const | ||
527 | { | ||
528 | return OMacAddress( _dhcphdr->chaddr ); | ||
529 | } | ||
530 | |||
531 | |||
525 | /*====================================================================================== | 532 | /*====================================================================================== |
526 | * OTCPPacket | 533 | * OTCPPacket |
527 | *======================================================================================*/ | 534 | *======================================================================================*/ |
528 | 535 | ||
529 | 536 | ||
530 | OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QObject* parent ) | 537 | OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QObject* parent ) |
531 | :QObject( parent, "TCP" ), _tcphdr( data ) | 538 | :QObject( parent, "TCP" ), _tcphdr( data ) |
532 | 539 | ||
533 | { | 540 | { |
534 | qDebug( "OTCPPacket::OTCPPacket(): decoding TCP header..." ); | 541 | qDebug( "OTCPPacket::OTCPPacket(): decoding TCP header..." ); |
535 | } | 542 | } |
536 | 543 | ||
537 | 544 | ||
538 | OTCPPacket::~OTCPPacket() | 545 | OTCPPacket::~OTCPPacket() |
539 | { | 546 | { |
540 | } | 547 | } |
541 | 548 | ||
542 | 549 | ||
543 | int OTCPPacket::fromPort() const | 550 | int OTCPPacket::fromPort() const |
544 | { | 551 | { |
545 | return EXTRACT_16BITS( &_tcphdr->source ); | 552 | return EXTRACT_16BITS( &_tcphdr->source ); |
546 | } | 553 | } |
547 | 554 | ||
548 | 555 | ||
549 | int OTCPPacket::toPort() const | 556 | int OTCPPacket::toPort() const |
550 | { | 557 | { |
551 | return EXTRACT_16BITS( &_tcphdr->dest ); | 558 | return EXTRACT_16BITS( &_tcphdr->dest ); |
552 | } | 559 | } |
553 | 560 | ||
554 | 561 | ||
555 | int OTCPPacket::seq() const | 562 | int OTCPPacket::seq() const |
556 | { | 563 | { |
557 | return EXTRACT_16BITS( &_tcphdr->seq ); | 564 | return EXTRACT_16BITS( &_tcphdr->seq ); |
558 | } | 565 | } |
559 | 566 | ||
560 | 567 | ||
561 | int OTCPPacket::ack() const | 568 | int OTCPPacket::ack() const |
562 | { | 569 | { |
563 | return EXTRACT_16BITS( &_tcphdr->ack_seq ); | 570 | return EXTRACT_16BITS( &_tcphdr->ack_seq ); |
564 | } | 571 | } |
565 | 572 | ||
566 | 573 | ||
567 | int OTCPPacket::window() const | 574 | int OTCPPacket::window() const |
568 | { | 575 | { |
569 | return EXTRACT_16BITS( &_tcphdr->window ); | 576 | return EXTRACT_16BITS( &_tcphdr->window ); |
570 | } | 577 | } |
571 | 578 | ||
572 | 579 | ||
573 | int OTCPPacket::checksum() const | 580 | int OTCPPacket::checksum() const |
574 | { | 581 | { |
575 | return EXTRACT_16BITS( &_tcphdr->check ); | 582 | return EXTRACT_16BITS( &_tcphdr->check ); |
576 | } | 583 | } |
577 | 584 | ||
578 | /*====================================================================================== | 585 | /*====================================================================================== |
579 | * OPrismHeaderPacket | 586 | * OPrismHeaderPacket |
580 | *======================================================================================*/ | 587 | *======================================================================================*/ |
581 | 588 | ||
582 | 589 | ||
583 | OPrismHeaderPacket::OPrismHeaderPacket( const unsigned char* end, const struct prism_hdr* data, QObject* parent ) | 590 | OPrismHeaderPacket::OPrismHeaderPacket( const unsigned char* end, const struct prism_hdr* data, QObject* parent ) |
584 | :QObject( parent, "Prism" ), _header( data ) | 591 | :QObject( parent, "Prism" ), _header( data ) |
585 | 592 | ||
586 | { | 593 | { |
587 | qDebug( "OPrismHeaderPacket::OPrismHeaderPacket(): decoding PRISM header..." ); | 594 | qDebug( "OPrismHeaderPacket::OPrismHeaderPacket(): decoding PRISM header..." ); |
588 | 595 | ||
589 | qDebug( "Signal Strength = %d", data->signal.data ); | 596 | qDebug( "Signal Strength = %d", data->signal.data ); |
590 | 597 | ||
591 | new OWaveLanPacket( end, (const struct ieee_802_11_header*) (data+1), this ); | 598 | new OWaveLanPacket( end, (const struct ieee_802_11_header*) (data+1), this ); |
592 | } | 599 | } |
593 | 600 | ||
594 | OPrismHeaderPacket::~OPrismHeaderPacket() | 601 | OPrismHeaderPacket::~OPrismHeaderPacket() |
595 | { | 602 | { |
596 | } | 603 | } |
597 | 604 | ||
598 | 605 | ||
599 | unsigned int OPrismHeaderPacket::signalStrength() const | 606 | unsigned int OPrismHeaderPacket::signalStrength() const |
600 | { | 607 | { |
601 | return _header->signal.data; | 608 | return _header->signal.data; |
602 | } | 609 | } |
603 | 610 | ||
604 | /*====================================================================================== | 611 | /*====================================================================================== |
605 | * OWaveLanPacket | 612 | * OWaveLanPacket |
606 | *======================================================================================*/ | 613 | *======================================================================================*/ |
607 | 614 | ||
608 | 615 | ||
609 | OWaveLanPacket::OWaveLanPacket( const unsigned char* end, const struct ieee_802_11_header* data, QObject* parent ) | 616 | OWaveLanPacket::OWaveLanPacket( const unsigned char* end, const struct ieee_802_11_header* data, QObject* parent ) |
610 | :QObject( parent, "802.11" ), _wlanhdr( data ) | 617 | :QObject( parent, "802.11" ), _wlanhdr( data ) |
611 | 618 | ||
612 | { | 619 | { |
613 | qDebug( "OWaveLanPacket::OWaveLanPacket(): decoding IEEE 802.11 header..." ); | 620 | qDebug( "OWaveLanPacket::OWaveLanPacket(): decoding IEEE 802.11 header..." ); |
614 | qDebug( "type: %0X", type() ); | 621 | qDebug( "type: %0X", type() ); |
615 | qDebug( "subType: %0X", subType() ); | 622 | qDebug( "subType: %0X", subType() ); |
616 | qDebug( "duration: %d", duration() ); | 623 | qDebug( "duration: %d", duration() ); |
617 | qDebug( "powermanagement: %d", usesPowerManagement() ); | 624 | qDebug( "powermanagement: %d", usesPowerManagement() ); |
618 | qDebug( "payload is encrypted: %s", usesWep() ? "yes" : "no" ); | 625 | qDebug( "payload is encrypted: %s", usesWep() ? "yes" : "no" ); |
619 | qDebug( "MAC1: %s", (const char*) macAddress1().toString() ); | 626 | qDebug( "MAC1: %s", (const char*) macAddress1().toString() ); |
620 | qDebug( "MAC2: %s", (const char*) macAddress2().toString() ); | 627 | qDebug( "MAC2: %s", (const char*) macAddress2().toString() ); |
621 | qDebug( "MAC3: %s", (const char*) macAddress3().toString() ); | 628 | qDebug( "MAC3: %s", (const char*) macAddress3().toString() ); |
622 | qDebug( "MAC4: %s", (const char*) macAddress4().toString() ); | 629 | qDebug( "MAC4: %s", (const char*) macAddress4().toString() ); |
623 | 630 | ||
624 | switch ( type() ) | 631 | switch ( type() ) |
625 | { | 632 | { |
626 | case T_MGMT: new OWaveLanManagementPacket( end, (const struct ieee_802_11_mgmt_header*) data, this ); break; | 633 | case T_MGMT: new OWaveLanManagementPacket( end, (const struct ieee_802_11_mgmt_header*) data, this ); break; |
627 | case T_DATA: new OWaveLanDataPacket( end, (const struct ieee_802_11_data_header*) data, this ); break; | 634 | case T_DATA: new OWaveLanDataPacket( end, (const struct ieee_802_11_data_header*) data, this ); break; |
628 | case T_CTRL: new OWaveLanControlPacket( end, (const struct ieee_802_11_control_header*) data, this ); break; | 635 | case T_CTRL: new OWaveLanControlPacket( end, (const struct ieee_802_11_control_header*) data, this ); break; |
629 | default: qDebug( "OWaveLanPacket::OWaveLanPacket(): Warning: Unknown major type '%d'!", type() ); | 636 | default: qDebug( "OWaveLanPacket::OWaveLanPacket(): Warning: Unknown major type '%d'!", type() ); |
630 | } | 637 | } |
631 | } | 638 | } |
632 | 639 | ||
633 | OWaveLanPacket::~OWaveLanPacket() | 640 | OWaveLanPacket::~OWaveLanPacket() |
634 | { | 641 | { |
635 | } | 642 | } |
636 | 643 | ||
637 | 644 | ||
638 | int OWaveLanPacket::duration() const | 645 | int OWaveLanPacket::duration() const |
639 | { | 646 | { |
640 | return _wlanhdr->duration; | 647 | return _wlanhdr->duration; |
641 | } | 648 | } |
642 | 649 | ||
643 | 650 | ||
644 | OMacAddress OWaveLanPacket::macAddress1() const | 651 | OMacAddress OWaveLanPacket::macAddress1() const |
645 | { | 652 | { |
646 | return OMacAddress( _wlanhdr->mac1 ); | 653 | return OMacAddress( _wlanhdr->mac1 ); |
647 | } | 654 | } |
648 | 655 | ||
649 | 656 | ||
650 | OMacAddress OWaveLanPacket::macAddress2() const | 657 | OMacAddress OWaveLanPacket::macAddress2() const |
651 | { | 658 | { |
652 | return OMacAddress( _wlanhdr->mac2 ); | 659 | return OMacAddress( _wlanhdr->mac2 ); |
653 | } | 660 | } |
654 | 661 | ||
655 | 662 | ||
656 | OMacAddress OWaveLanPacket::macAddress3() const | 663 | OMacAddress OWaveLanPacket::macAddress3() const |
657 | { | 664 | { |
658 | return OMacAddress( _wlanhdr->mac3 ); | 665 | return OMacAddress( _wlanhdr->mac3 ); |
659 | } | 666 | } |
660 | 667 | ||
661 | 668 | ||
662 | OMacAddress OWaveLanPacket::macAddress4() const | 669 | OMacAddress OWaveLanPacket::macAddress4() const |
663 | { | 670 | { |
664 | return OMacAddress( _wlanhdr->mac4 ); | 671 | return OMacAddress( _wlanhdr->mac4 ); |
665 | } | 672 | } |
666 | 673 | ||
667 | 674 | ||
668 | int OWaveLanPacket::subType() const | 675 | int OWaveLanPacket::subType() const |
669 | { | 676 | { |
670 | return FC_SUBTYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); | 677 | return FC_SUBTYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); |
671 | } | 678 | } |
672 | 679 | ||
673 | 680 | ||
674 | int OWaveLanPacket::type() const | 681 | int OWaveLanPacket::type() const |
675 | { | 682 | { |
676 | return FC_TYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); | 683 | return FC_TYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); |
677 | } | 684 | } |
678 | 685 | ||
679 | 686 | ||
680 | int OWaveLanPacket::version() const | 687 | int OWaveLanPacket::version() const |
681 | { | 688 | { |
682 | return FC_VERSION( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); | 689 | return FC_VERSION( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); |
683 | } | 690 | } |
684 | 691 | ||
685 | 692 | ||
686 | bool OWaveLanPacket::fromDS() const | 693 | bool OWaveLanPacket::fromDS() const |
687 | { | 694 | { |
688 | return FC_FROM_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); | 695 | return FC_FROM_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); |
689 | } | 696 | } |
690 | 697 | ||
691 | 698 | ||
692 | bool OWaveLanPacket::toDS() const | 699 | bool OWaveLanPacket::toDS() const |
693 | { | 700 | { |
694 | return FC_TO_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); | 701 | return FC_TO_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); |
695 | } | 702 | } |
696 | 703 | ||
697 | 704 | ||
698 | bool OWaveLanPacket::usesPowerManagement() const | 705 | bool OWaveLanPacket::usesPowerManagement() const |
699 | { | 706 | { |
700 | return FC_POWER_MGMT( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); | 707 | return FC_POWER_MGMT( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); |
701 | } | 708 | } |
702 | 709 | ||
703 | 710 | ||
704 | bool OWaveLanPacket::usesWep() const | 711 | bool OWaveLanPacket::usesWep() const |
705 | { | 712 | { |
706 | return FC_WEP( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); | 713 | return FC_WEP( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); |
707 | } | 714 | } |
708 | 715 | ||
709 | 716 | ||
710 | /*====================================================================================== | 717 | /*====================================================================================== |
711 | * OWaveLanManagementPacket | 718 | * OWaveLanManagementPacket |
712 | *======================================================================================*/ | 719 | *======================================================================================*/ |
713 | 720 | ||
714 | OWaveLanManagementPacket::OWaveLanManagementPacket( const unsigned char* end, const struct ieee_802_11_mgmt_header* data, OWaveLanPacket* parent ) | 721 | OWaveLanManagementPacket::OWaveLanManagementPacket( const unsigned char* end, const struct ieee_802_11_mgmt_header* data, OWaveLanPacket* parent ) |
715 | :QObject( parent, "802.11 Management" ), _header( data ), | 722 | :QObject( parent, "802.11 Management" ), _header( data ), |
716 | _body( (const struct ieee_802_11_mgmt_body*) (data+1) ) | 723 | _body( (const struct ieee_802_11_mgmt_body*) (data+1) ) |
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h index f0d1d81..51f067a 100644 --- a/libopie2/opienet/opcap.h +++ b/libopie2/opienet/opcap.h | |||
@@ -320,341 +320,343 @@ class OWaveLanManagementDS : public QObject | |||
320 | 320 | ||
321 | int channel() const; | 321 | int channel() const; |
322 | 322 | ||
323 | private: | 323 | private: |
324 | const struct ds_t* _data; | 324 | const struct ds_t* _data; |
325 | }; | 325 | }; |
326 | 326 | ||
327 | /*====================================================================================== | 327 | /*====================================================================================== |
328 | * OWaveLanManagementTim | 328 | * OWaveLanManagementTim |
329 | *======================================================================================*/ | 329 | *======================================================================================*/ |
330 | 330 | ||
331 | class OWaveLanManagementTim : public QObject | 331 | class OWaveLanManagementTim : public QObject |
332 | { | 332 | { |
333 | Q_OBJECT | 333 | Q_OBJECT |
334 | 334 | ||
335 | public: | 335 | public: |
336 | OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 ); | 336 | OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 ); |
337 | virtual ~OWaveLanManagementTim(); | 337 | virtual ~OWaveLanManagementTim(); |
338 | 338 | ||
339 | private: | 339 | private: |
340 | const struct tim_t* _data; | 340 | const struct tim_t* _data; |
341 | }; | 341 | }; |
342 | 342 | ||
343 | /*====================================================================================== | 343 | /*====================================================================================== |
344 | * OWaveLanManagementIBSS | 344 | * OWaveLanManagementIBSS |
345 | *======================================================================================*/ | 345 | *======================================================================================*/ |
346 | 346 | ||
347 | class OWaveLanManagementIBSS : public QObject | 347 | class OWaveLanManagementIBSS : public QObject |
348 | { | 348 | { |
349 | Q_OBJECT | 349 | Q_OBJECT |
350 | 350 | ||
351 | public: | 351 | public: |
352 | OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 ); | 352 | OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 ); |
353 | virtual ~OWaveLanManagementIBSS(); | 353 | virtual ~OWaveLanManagementIBSS(); |
354 | 354 | ||
355 | private: | 355 | private: |
356 | const struct ibss_t* _data; | 356 | const struct ibss_t* _data; |
357 | }; | 357 | }; |
358 | 358 | ||
359 | /*====================================================================================== | 359 | /*====================================================================================== |
360 | * OWaveLanManagementChallenge | 360 | * OWaveLanManagementChallenge |
361 | *======================================================================================*/ | 361 | *======================================================================================*/ |
362 | 362 | ||
363 | class OWaveLanManagementChallenge : public QObject | 363 | class OWaveLanManagementChallenge : public QObject |
364 | { | 364 | { |
365 | Q_OBJECT | 365 | Q_OBJECT |
366 | 366 | ||
367 | public: | 367 | public: |
368 | OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 ); | 368 | OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 ); |
369 | virtual ~OWaveLanManagementChallenge(); | 369 | virtual ~OWaveLanManagementChallenge(); |
370 | 370 | ||
371 | private: | 371 | private: |
372 | const struct challenge_t* _data; | 372 | const struct challenge_t* _data; |
373 | }; | 373 | }; |
374 | 374 | ||
375 | /*====================================================================================== | 375 | /*====================================================================================== |
376 | * OWaveLanDataPacket - type: data (T_DATA) | 376 | * OWaveLanDataPacket - type: data (T_DATA) |
377 | *======================================================================================*/ | 377 | *======================================================================================*/ |
378 | 378 | ||
379 | class OWaveLanDataPacket : public QObject | 379 | class OWaveLanDataPacket : public QObject |
380 | { | 380 | { |
381 | Q_OBJECT | 381 | Q_OBJECT |
382 | 382 | ||
383 | public: | 383 | public: |
384 | OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 ); | 384 | OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 ); |
385 | virtual ~OWaveLanDataPacket(); | 385 | virtual ~OWaveLanDataPacket(); |
386 | 386 | ||
387 | private: | 387 | private: |
388 | const struct ieee_802_11_data_header* _header; | 388 | const struct ieee_802_11_data_header* _header; |
389 | }; | 389 | }; |
390 | 390 | ||
391 | /*====================================================================================== | 391 | /*====================================================================================== |
392 | * OWaveLanControlPacket - type: control (T_CTRL) | 392 | * OWaveLanControlPacket - type: control (T_CTRL) |
393 | *======================================================================================*/ | 393 | *======================================================================================*/ |
394 | 394 | ||
395 | class OWaveLanControlPacket : public QObject | 395 | class OWaveLanControlPacket : public QObject |
396 | { | 396 | { |
397 | Q_OBJECT | 397 | Q_OBJECT |
398 | 398 | ||
399 | public: | 399 | public: |
400 | OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 ); | 400 | OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 ); |
401 | virtual ~OWaveLanControlPacket(); | 401 | virtual ~OWaveLanControlPacket(); |
402 | 402 | ||
403 | private: | 403 | private: |
404 | const struct ieee_802_11_control_header* _header; | 404 | const struct ieee_802_11_control_header* _header; |
405 | }; | 405 | }; |
406 | 406 | ||
407 | /*====================================================================================== | 407 | /*====================================================================================== |
408 | * OLLCPacket - IEEE 802.2 Link Level Control | 408 | * OLLCPacket - IEEE 802.2 Link Level Control |
409 | *======================================================================================*/ | 409 | *======================================================================================*/ |
410 | 410 | ||
411 | class OLLCPacket : public QObject | 411 | class OLLCPacket : public QObject |
412 | { | 412 | { |
413 | Q_OBJECT | 413 | Q_OBJECT |
414 | 414 | ||
415 | public: | 415 | public: |
416 | OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 ); | 416 | OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 ); |
417 | virtual ~OLLCPacket(); | 417 | virtual ~OLLCPacket(); |
418 | 418 | ||
419 | private: | 419 | private: |
420 | const struct ieee_802_11_802_2_header* _header; | 420 | const struct ieee_802_11_802_2_header* _header; |
421 | }; | 421 | }; |
422 | 422 | ||
423 | /*====================================================================================== | 423 | /*====================================================================================== |
424 | * OIPPacket | 424 | * OIPPacket |
425 | *======================================================================================*/ | 425 | *======================================================================================*/ |
426 | 426 | ||
427 | class OIPPacket : public QObject | 427 | class OIPPacket : public QObject |
428 | { | 428 | { |
429 | Q_OBJECT | 429 | Q_OBJECT |
430 | 430 | ||
431 | public: | 431 | public: |
432 | OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 ); | 432 | OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 ); |
433 | virtual ~OIPPacket(); | 433 | virtual ~OIPPacket(); |
434 | 434 | ||
435 | QHostAddress fromIPAddress() const; | 435 | QHostAddress fromIPAddress() const; |
436 | QHostAddress toIPAddress() const; | 436 | QHostAddress toIPAddress() const; |
437 | 437 | ||
438 | int tos() const; | 438 | int tos() const; |
439 | int len() const; | 439 | int len() const; |
440 | int id() const; | 440 | int id() const; |
441 | int offset() const; | 441 | int offset() const; |
442 | int ttl() const; | 442 | int ttl() const; |
443 | int protocol() const; | 443 | int protocol() const; |
444 | int checksum() const; | 444 | int checksum() const; |
445 | 445 | ||
446 | private: | 446 | private: |
447 | const struct iphdr* _iphdr; | 447 | const struct iphdr* _iphdr; |
448 | }; | 448 | }; |
449 | 449 | ||
450 | /*====================================================================================== | 450 | /*====================================================================================== |
451 | * OARPPacket | 451 | * OARPPacket |
452 | *======================================================================================*/ | 452 | *======================================================================================*/ |
453 | 453 | ||
454 | class OARPPacket : public QObject | 454 | class OARPPacket : public QObject |
455 | { | 455 | { |
456 | Q_OBJECT | 456 | Q_OBJECT |
457 | 457 | ||
458 | public: | 458 | public: |
459 | OARPPacket( const unsigned char*, const struct myarphdr*, QObject* parent = 0 ); | 459 | OARPPacket( const unsigned char*, const struct myarphdr*, QObject* parent = 0 ); |
460 | virtual ~OARPPacket(); | 460 | virtual ~OARPPacket(); |
461 | 461 | ||
462 | QHostAddress senderIPV4Address() const; | 462 | QHostAddress senderIPV4Address() const; |
463 | OMacAddress senderMacAddress() const; | 463 | OMacAddress senderMacAddress() const; |
464 | QHostAddress targetIPV4Address() const; | 464 | QHostAddress targetIPV4Address() const; |
465 | OMacAddress targetMacAddress() const; | 465 | OMacAddress targetMacAddress() const; |
466 | 466 | ||
467 | //int type() const; | 467 | //int type() const; |
468 | QString type() const; | 468 | QString type() const; |
469 | 469 | ||
470 | private: | 470 | private: |
471 | const struct myarphdr* _arphdr; | 471 | const struct myarphdr* _arphdr; |
472 | }; | 472 | }; |
473 | 473 | ||
474 | /*====================================================================================== | 474 | /*====================================================================================== |
475 | * OUDPPacket | 475 | * OUDPPacket |
476 | *======================================================================================*/ | 476 | *======================================================================================*/ |
477 | 477 | ||
478 | class OUDPPacket : public QObject | 478 | class OUDPPacket : public QObject |
479 | { | 479 | { |
480 | Q_OBJECT | 480 | Q_OBJECT |
481 | 481 | ||
482 | public: | 482 | public: |
483 | OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 ); | 483 | OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 ); |
484 | virtual ~OUDPPacket(); | 484 | virtual ~OUDPPacket(); |
485 | 485 | ||
486 | int fromPort() const; | 486 | int fromPort() const; |
487 | int toPort() const; | 487 | int toPort() const; |
488 | int length() const; | 488 | int length() const; |
489 | int checksum() const; | 489 | int checksum() const; |
490 | 490 | ||
491 | private: | 491 | private: |
492 | const struct udphdr* _udphdr; | 492 | const struct udphdr* _udphdr; |
493 | }; | 493 | }; |
494 | 494 | ||
495 | /*====================================================================================== | 495 | /*====================================================================================== |
496 | * ODHCPPacket | 496 | * ODHCPPacket |
497 | *======================================================================================*/ | 497 | *======================================================================================*/ |
498 | 498 | ||
499 | class ODHCPPacket : public QObject | 499 | class ODHCPPacket : public QObject |
500 | { | 500 | { |
501 | Q_OBJECT | 501 | Q_OBJECT |
502 | 502 | ||
503 | public: | 503 | public: |
504 | ODHCPPacket( const unsigned char*, const struct dhcp_packet*, QObject* parent = 0 ); | 504 | ODHCPPacket( const unsigned char*, const struct dhcp_packet*, QObject* parent = 0 ); |
505 | virtual ~ODHCPPacket(); | 505 | virtual ~ODHCPPacket(); |
506 | 506 | ||
507 | QHostAddress clientAddress() const; | 507 | QHostAddress clientAddress() const; |
508 | QHostAddress yourAddress() const; | 508 | QHostAddress yourAddress() const; |
509 | QHostAddress serverAddress() const; | 509 | QHostAddress serverAddress() const; |
510 | QHostAddress relayAddress() const; | 510 | QHostAddress relayAddress() const; |
511 | 511 | ||
512 | OMacAddress clientMacAddress() const; | ||
513 | |||
512 | bool isRequest() const; | 514 | bool isRequest() const; |
513 | bool isReply() const; | 515 | bool isReply() const; |
514 | QString type() const; | 516 | QString type() const; |
515 | 517 | ||
516 | private: | 518 | private: |
517 | const struct dhcp_packet* _dhcphdr; | 519 | const struct dhcp_packet* _dhcphdr; |
518 | unsigned char _type; | 520 | unsigned char _type; |
519 | }; | 521 | }; |
520 | 522 | ||
521 | /*====================================================================================== | 523 | /*====================================================================================== |
522 | * OTCPPacket | 524 | * OTCPPacket |
523 | *======================================================================================*/ | 525 | *======================================================================================*/ |
524 | 526 | ||
525 | class OTCPPacket : public QObject | 527 | class OTCPPacket : public QObject |
526 | { | 528 | { |
527 | Q_OBJECT | 529 | Q_OBJECT |
528 | 530 | ||
529 | public: | 531 | public: |
530 | OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 ); | 532 | OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 ); |
531 | virtual ~OTCPPacket(); | 533 | virtual ~OTCPPacket(); |
532 | 534 | ||
533 | int fromPort() const; | 535 | int fromPort() const; |
534 | int toPort() const; | 536 | int toPort() const; |
535 | int seq() const; | 537 | int seq() const; |
536 | int ack() const; | 538 | int ack() const; |
537 | int window() const; | 539 | int window() const; |
538 | int checksum() const; | 540 | int checksum() const; |
539 | 541 | ||
540 | private: | 542 | private: |
541 | const struct tcphdr* _tcphdr; | 543 | const struct tcphdr* _tcphdr; |
542 | }; | 544 | }; |
543 | 545 | ||
544 | 546 | ||
545 | /*====================================================================================== | 547 | /*====================================================================================== |
546 | * OPacketCapturer | 548 | * OPacketCapturer |
547 | *======================================================================================*/ | 549 | *======================================================================================*/ |
548 | 550 | ||
549 | /** | 551 | /** |
550 | * @brief A class based wrapper for network packet capturing. | 552 | * @brief A class based wrapper for network packet capturing. |
551 | * | 553 | * |
552 | * This class is the base of a high-level interface to the well known packet capturing | 554 | * This class is the base of a high-level interface to the well known packet capturing |
553 | * library libpcap. | 555 | * library libpcap. |
554 | * @see http://tcpdump.org | 556 | * @see http://tcpdump.org |
555 | */ | 557 | */ |
556 | class OPacketCapturer : public QObject | 558 | class OPacketCapturer : public QObject |
557 | { | 559 | { |
558 | Q_OBJECT | 560 | Q_OBJECT |
559 | 561 | ||
560 | public: | 562 | public: |
561 | /** | 563 | /** |
562 | * Constructor. | 564 | * Constructor. |
563 | */ | 565 | */ |
564 | OPacketCapturer( QObject* parent = 0, const char* name = 0 ); | 566 | OPacketCapturer( QObject* parent = 0, const char* name = 0 ); |
565 | /** | 567 | /** |
566 | * Destructor. | 568 | * Destructor. |
567 | */ | 569 | */ |
568 | ~OPacketCapturer(); | 570 | ~OPacketCapturer(); |
569 | /** | 571 | /** |
570 | * Set the packet capturer to use blocking or non-blocking IO. This can be useful when | 572 | * Set the packet capturer to use blocking or non-blocking IO. This can be useful when |
571 | * not using the socket notifier, e.g. without an application object. | 573 | * not using the socket notifier, e.g. without an application object. |
572 | */ | 574 | */ |
573 | void setBlocking( bool ); | 575 | void setBlocking( bool ); |
574 | /** | 576 | /** |
575 | * @returns true if the packet capturer uses blocking IO calls. | 577 | * @returns true if the packet capturer uses blocking IO calls. |
576 | */ | 578 | */ |
577 | bool blocking() const; | 579 | bool blocking() const; |
578 | /** | 580 | /** |
579 | * Close the packet capturer. This is automatically done in the destructor. | 581 | * Close the packet capturer. This is automatically done in the destructor. |
580 | */ | 582 | */ |
581 | void close(); | 583 | void close(); |
582 | /** | 584 | /** |
583 | * Close the output capture file. | 585 | * Close the output capture file. |
584 | */ | 586 | */ |
585 | void closeDumpFile(); | 587 | void closeDumpFile(); |
586 | /** | 588 | /** |
587 | * @returns the data link type. | 589 | * @returns the data link type. |
588 | * @see <pcap.h> for possible values. | 590 | * @see <pcap.h> for possible values. |
589 | */ | 591 | */ |
590 | int dataLink() const; | 592 | int dataLink() const; |
591 | /** | 593 | /** |
592 | * Dump a packet to the output capture file. | 594 | * Dump a packet to the output capture file. |
593 | */ | 595 | */ |
594 | void dump( OPacket* ); | 596 | void dump( OPacket* ); |
595 | /** | 597 | /** |
596 | * @returns the file descriptor of the packet capturer. This is only useful, if | 598 | * @returns the file descriptor of the packet capturer. This is only useful, if |
597 | * not using the socket notifier, e.g. without an application object. | 599 | * not using the socket notifier, e.g. without an application object. |
598 | */ | 600 | */ |
599 | int fileno() const; | 601 | int fileno() const; |
600 | /** | 602 | /** |
601 | * @returns the next @ref OPacket from the packet capturer. | 603 | * @returns the next @ref OPacket from the packet capturer. |
602 | * @note If blocking mode is true then this call might block. | 604 | * @note If blocking mode is true then this call might block. |
603 | */ | 605 | */ |
604 | OPacket* next(); | 606 | OPacket* next(); |
605 | /** | 607 | /** |
606 | * Open the packet capturer to capture packets in live-mode from @a interface. | 608 | * Open the packet capturer to capture packets in live-mode from @a interface. |
607 | */ | 609 | */ |
608 | bool open( const QString& interface ); | 610 | bool open( const QString& interface ); |
609 | /** | 611 | /** |
610 | * Open the packet capturer to capture packets in offline-mode from @a file. | 612 | * Open the packet capturer to capture packets in offline-mode from @a file. |
611 | */ | 613 | */ |
612 | bool open( const QFile& file ); | 614 | bool open( const QFile& file ); |
613 | /** | 615 | /** |
614 | * Open a prerecorded tcpdump compatible capture file for use with @ref dump() | 616 | * Open a prerecorded tcpdump compatible capture file for use with @ref dump() |
615 | */ | 617 | */ |
616 | bool openDumpFile( const QString& filename ); | 618 | bool openDumpFile( const QString& filename ); |
617 | /** | 619 | /** |
618 | * @returns true if the packet capturer is open | 620 | * @returns true if the packet capturer is open |
619 | */ | 621 | */ |
620 | bool isOpen() const; | 622 | bool isOpen() const; |
621 | /** | 623 | /** |
622 | * @returns the snapshot length of this packet capturer | 624 | * @returns the snapshot length of this packet capturer |
623 | */ | 625 | */ |
624 | int snapShot() const; | 626 | int snapShot() const; |
625 | /** | 627 | /** |
626 | * @returns true if the input capture file has a different byte-order | 628 | * @returns true if the input capture file has a different byte-order |
627 | * than the byte-order of the running system. | 629 | * than the byte-order of the running system. |
628 | */ | 630 | */ |
629 | bool swapped() const; | 631 | bool swapped() const; |
630 | /** | 632 | /** |
631 | * @returns the libpcap version string used to write the input capture file. | 633 | * @returns the libpcap version string used to write the input capture file. |
632 | */ | 634 | */ |
633 | QString version() const; | 635 | QString version() const; |
634 | /** | 636 | /** |
635 | * @returns the packet statistic database. | 637 | * @returns the packet statistic database. |
636 | * @see QMap | 638 | * @see QMap |
637 | */ | 639 | */ |
638 | const QMap<QString,int>& statistics() const; | 640 | const QMap<QString,int>& statistics() const; |
639 | 641 | ||
640 | signals: | 642 | signals: |
641 | /** | 643 | /** |
642 | * This signal is emitted, when a packet has been received. | 644 | * This signal is emitted, when a packet has been received. |
643 | */ | 645 | */ |
644 | void receivedPacket( OPacket* ); | 646 | void receivedPacket( OPacket* ); |
645 | 647 | ||
646 | protected slots: | 648 | protected slots: |
647 | void readyToReceive(); | 649 | void readyToReceive(); |
648 | 650 | ||
649 | protected: | 651 | protected: |
650 | QString _name; // devicename | 652 | QString _name; // devicename |
651 | bool _open; // check this before doing pcap calls | 653 | bool _open; // check this before doing pcap calls |
652 | pcap_t* _pch; // pcap library handle | 654 | pcap_t* _pch; // pcap library handle |
653 | pcap_dumper_t* _pcd; // pcap dumper handle | 655 | pcap_dumper_t* _pcd; // pcap dumper handle |
654 | QSocketNotifier* _sn; // socket notifier for main loop | 656 | QSocketNotifier* _sn; // socket notifier for main loop |
655 | mutable char _errbuf[PCAP_ERRBUF_SIZE]; // holds error strings from libpcap | 657 | mutable char _errbuf[PCAP_ERRBUF_SIZE]; // holds error strings from libpcap |
656 | QMap<QString, int> _stats; // statistics; | 658 | QMap<QString, int> _stats; // statistics; |
657 | }; | 659 | }; |
658 | 660 | ||
659 | #endif // OPCAP_H | 661 | #endif // OPCAP_H |
660 | 662 | ||