프로그래밍/네트워크

[libtins] libtins 라이브러리에 대해...

asvv 2017. 1. 12. 01:34

BoB 에서 교육을 받으면서 gilgil 멘토님에 소개로 알게된 라이브러리이다.


라이브러리

http://libtins.github.io/


github

https://github.com/mfontanini/libtins


설치 방법은 github에 README.md에 상세하게 나와있다.


예제 소스


  1. #include <iostream>  
  2. #include <tins/tins.h>  
  3.   
  4. using namespace Tins;  
  5.   
  6. bool callback(const PDU &pdu) {  
  7.     const IP &ip = pdu.rfind_pdu<IP>(); // Find the IP layer  
  8.     const TCP &tcp = pdu.rfind_pdu<TCP>(); // Find the TCP layer  
  9.     std::cout << ip.src_addr() << ':' << tcp.sport() << " -> "   
  10.               << ip.dst_addr() << ':' << tcp.dport() << std::endl;  
  11.     return true;  
  12. }  
  13.   
  14. int main() {  
  15.     Sniffer("eth0").sniff_loop(callback);  


결과 화면



쉽게 공부할 수 있을 듯 하다.


반응형

'프로그래밍 > 네트워크' 카테고리의 다른 글

[libtins] Basics을 공부하면서  (0) 2017.01.12