aboutsummaryrefslogtreecommitdiffstats
path: root/fnet/src/examples/ping/packets.h
blob: d196f3e439240b7d2decbcedac3c673dc51868a6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <vespa/fnet/packet.h>
#include <vespa/fnet/ipacketfactory.h>

enum {
    PCODE_PING_REQUEST = 1,
    PCODE_PING_REPLY   = 2
};

class PingRequest : public FNET_Packet
{
public:
    uint32_t GetPCODE() override;
    uint32_t GetLength() override;
    void Encode(FNET_DataBuffer *) override;
    bool Decode(FNET_DataBuffer *src, uint32_t len) override;
};

class PingReply : public FNET_Packet
{
public:
    uint32_t GetPCODE() override;
    uint32_t GetLength() override;
    void Encode(FNET_DataBuffer *) override;
    bool Decode(FNET_DataBuffer *src, uint32_t len) override;
};


class PingPacketFactory : public FNET_IPacketFactory
{
public:
    FNET_Packet *CreatePacket(uint32_t pcode, FNET_Context) override;
};