#ifndef TCP_HPP
#define TCP_HPP
#include <netinet/tcp.h>
#include <string>
#include <iostream>
#include "port_protocol.hpp"
void del_tcp(const u_char* ptr_packet, size_t used_len)
{
if (ptr_packet == NULL)
{
return ;
}
bool is_find;
const struct tcphdr* ptr_tcp = (struct tcphdr*)(ptr_packet+used_len);
std::string sp = get_protocol_by(ntohs(ptr_tcp->source), "tcp", is_find);
if (!is_find)//find not service by src_port, try dest_port
{
std::string dp = get_protocol_by(ntohs(ptr_tcp->dest), "tcp", is_find);
if (!is_find)//find not service by dest_port
{
std::cout<<_("tcp load undefined protocol")<<std::endl;
}
else
{
std::cout<<_("tcp load protocol is: ")<<dp<<std::endl;
}
}
else
{
std::cout<<_("tcp load protocol is: ")<<sp<<std::endl;
}
}
#endif
#define TCP_HPP
#include <netinet/tcp.h>
#include <string>
#include <iostream>
#include "port_protocol.hpp"
void del_tcp(const u_char* ptr_packet, size_t used_len)
{
if (ptr_packet == NULL)
{
return ;
}
bool is_find;
const struct tcphdr* ptr_tcp = (struct tcphdr*)(ptr_packet+used_len);
std::string sp = get_protocol_by(ntohs(ptr_tcp->source), "tcp", is_find);
if (!is_find)//find not service by src_port, try dest_port
{
std::string dp = get_protocol_by(ntohs(ptr_tcp->dest), "tcp", is_find);
if (!is_find)//find not service by dest_port
{
std::cout<<_("tcp load undefined protocol")<<std::endl;
}
else
{
std::cout<<_("tcp load protocol is: ")<<dp<<std::endl;
}
}
else
{
std::cout<<_("tcp load protocol is: ")<<sp<<std::endl;
}
}
#endif