#ifndef UDP_HPP
#define UDP_HPP
/*[RFC768]
struct udphdr
{
u_int16_t uh_sport; // source port
u_int16_t uh_dport; // destination port
u_int16_t uh_ulen; // udp length
u_int16_t uh_sum; // udp checksum
};
#else
struct udphdr
{
u_int16_t source;
u_int16_t dest;
u_int16_t len;
u_int16_t check;
};*/
#include <string>
#include <iostream>
#include <netinet/udp.h>
#include "port_protocol.hpp"
void del_udp(const u_char* ptr_packet, size_t used_len)
{
if (ptr_packet == NULL)
{
return;
}
bool is_find;
struct udphdr* ptr_udp = (struct udphdr*)(ptr_packet+used_len);
std::string sp = get_protocol_by(ntohs(ptr_udp->source), "udp", is_find);
if (!is_find)
{
std::string dp = get_protocol_by(ntohs(ptr_udp->dest), "udp", is_find);
if (!is_find)
{
std::cout<<_("udp load undefined protocol")<<std::endl;
}
else
{
std::cout<<_("udp load protocol is: ")<<dp<<std::endl;
}
}
else
{
std::cout<<_("udp load protocol is:")<<sp<<std::endl;
}
}
#endif
#define UDP_HPP
/*[RFC768]
struct udphdr
{
u_int16_t uh_sport; // source port
u_int16_t uh_dport; // destination port
u_int16_t uh_ulen; // udp length
u_int16_t uh_sum; // udp checksum
};
#else
struct udphdr
{
u_int16_t source;
u_int16_t dest;
u_int16_t len;
u_int16_t check;
};*/
#include <string>
#include <iostream>
#include <netinet/udp.h>
#include "port_protocol.hpp"
void del_udp(const u_char* ptr_packet, size_t used_len)
{
if (ptr_packet == NULL)
{
return;
}
bool is_find;
struct udphdr* ptr_udp = (struct udphdr*)(ptr_packet+used_len);
std::string sp = get_protocol_by(ntohs(ptr_udp->source), "udp", is_find);
if (!is_find)
{
std::string dp = get_protocol_by(ntohs(ptr_udp->dest), "udp", is_find);
if (!is_find)
{
std::cout<<_("udp load undefined protocol")<<std::endl;
}
else
{
std::cout<<_("udp load protocol is: ")<<dp<<std::endl;
}
}
else
{
std::cout<<_("udp load protocol is:")<<sp<<std::endl;
}
}
#endif