28 lines
956 B
C++
28 lines
956 B
C++
#ifndef COPPINO_UDP_H
|
|
#define COPPINO_UDP_H
|
|
|
|
namespace udp {
|
|
class UDPPacket {
|
|
private:
|
|
char packet[ipv6::LEN - 40];
|
|
public:
|
|
void setSrcPort(uint16_t port);
|
|
uint16_t getSrcPort();
|
|
void setDstPort(uint16_t port);
|
|
uint16_t getDstPort();
|
|
const char* UDPPacket::getPayload();
|
|
void setPayload(const char* payload, int len); /* also sets proper length */
|
|
void computeChecksum(const ipv6::IPv6Addr* src_addr, const ipv6::IPv6Addr* dst_addr, int len); /* computes and updates checksum in the packet */
|
|
};
|
|
|
|
/* UDP handler for lower layer protocol */
|
|
int handleUDP(char* output_buffer, const char* input_buffer, int len);
|
|
|
|
/* pointer to server handler function */
|
|
extern int(*server_handler) (char* output_buffer, const char* buffer, int size);
|
|
extern uint16_t server_port;
|
|
void set_handler(uint16_t port, int(* handler) (char* output_buffer, const char* input_buffer, int size));
|
|
}
|
|
|
|
#endif
|