summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-10-06 17:38:19 (UTC)
committer mickeyl <mickeyl>2003-10-06 17:38:19 (UTC)
commit42aefe8bc6a8089b771d6f109fed22a770295cc8 (patch) (unidiff)
tree3233ee1af3d857cd2fddca3b27623cee8d2aa45b
parente0acd0d9400bb489415d21ec715c5f6704c22b95 (diff)
downloadopie-42aefe8bc6a8089b771d6f109fed22a770295cc8.zip
opie-42aefe8bc6a8089b771d6f109fed22a770295cc8.tar.gz
opie-42aefe8bc6a8089b771d6f109fed22a770295cc8.tar.bz2
add client mac address decoding to DHCP
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/opcap.cpp7
-rw-r--r--libopie2/opienet/opcap.h2
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
@@ -493,64 +493,71 @@ QString ODHCPPacket::type() const
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
502QHostAddress ODHCPPacket::clientAddress() const 502QHostAddress ODHCPPacket::clientAddress() const
503{ 503{
504 return EXTRACT_32BITS( &_dhcphdr->ciaddr ); 504 return EXTRACT_32BITS( &_dhcphdr->ciaddr );
505} 505}
506 506
507 507
508QHostAddress ODHCPPacket::yourAddress() const 508QHostAddress ODHCPPacket::yourAddress() const
509{ 509{
510 return EXTRACT_32BITS( &_dhcphdr->yiaddr ); 510 return EXTRACT_32BITS( &_dhcphdr->yiaddr );
511} 511}
512 512
513 513
514QHostAddress ODHCPPacket::serverAddress() const 514QHostAddress ODHCPPacket::serverAddress() const
515{ 515{
516 return EXTRACT_32BITS( &_dhcphdr->siaddr ); 516 return EXTRACT_32BITS( &_dhcphdr->siaddr );
517} 517}
518 518
519 519
520QHostAddress ODHCPPacket::relayAddress() const 520QHostAddress ODHCPPacket::relayAddress() const
521{ 521{
522 return EXTRACT_32BITS( &_dhcphdr->giaddr ); 522 return EXTRACT_32BITS( &_dhcphdr->giaddr );
523} 523}
524 524
525
526OMacAddress ODHCPPacket::clientMacAddress() const
527{
528 return OMacAddress( _dhcphdr->chaddr );
529}
530
531
525/*====================================================================================== 532/*======================================================================================
526 * OTCPPacket 533 * OTCPPacket
527 *======================================================================================*/ 534 *======================================================================================*/
528 535
529 536
530OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QObject* parent ) 537OTCPPacket::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
538OTCPPacket::~OTCPPacket() 545OTCPPacket::~OTCPPacket()
539{ 546{
540} 547}
541 548
542 549
543int OTCPPacket::fromPort() const 550int OTCPPacket::fromPort() const
544{ 551{
545 return EXTRACT_16BITS( &_tcphdr->source ); 552 return EXTRACT_16BITS( &_tcphdr->source );
546} 553}
547 554
548 555
549int OTCPPacket::toPort() const 556int OTCPPacket::toPort() const
550{ 557{
551 return EXTRACT_16BITS( &_tcphdr->dest ); 558 return EXTRACT_16BITS( &_tcphdr->dest );
552} 559}
553 560
554 561
555int OTCPPacket::seq() const 562int OTCPPacket::seq() const
556{ 563{
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
@@ -480,64 +480,66 @@ class OUDPPacket : public QObject
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
499class ODHCPPacket : public QObject 499class 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
525class OTCPPacket : public QObject 527class 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