1bae4d13cSopenharmony_ci/*
2bae4d13cSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
3bae4d13cSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4bae4d13cSopenharmony_ci * you may not use this file except in compliance with the License.
5bae4d13cSopenharmony_ci * You may obtain a copy of the License at
6bae4d13cSopenharmony_ci *
7bae4d13cSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8bae4d13cSopenharmony_ci *
9bae4d13cSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10bae4d13cSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11bae4d13cSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12bae4d13cSopenharmony_ci * See the License for the specific language governing permissions and
13bae4d13cSopenharmony_ci * limitations under the License.
14bae4d13cSopenharmony_ci */
15bae4d13cSopenharmony_ci
16bae4d13cSopenharmony_ci#ifndef NET_PACKET_H
17bae4d13cSopenharmony_ci#define NET_PACKET_H
18bae4d13cSopenharmony_ci
19bae4d13cSopenharmony_ci#include "proto.h"
20bae4d13cSopenharmony_ci#include "stream_buffer.h"
21bae4d13cSopenharmony_ci
22bae4d13cSopenharmony_ci#undef LOG_TAG
23bae4d13cSopenharmony_ci#define LOG_TAG "NetPacket"
24bae4d13cSopenharmony_ci
25bae4d13cSopenharmony_ci#pragma pack(1)
26bae4d13cSopenharmony_ciusing PACKHEAD = struct PackHead {
27bae4d13cSopenharmony_ci    OHOS::Sensors::MessageId idMsg;
28bae4d13cSopenharmony_ci    size_t size;
29bae4d13cSopenharmony_ci};
30bae4d13cSopenharmony_ci
31bae4d13cSopenharmony_ci#pragma pack()
32bae4d13cSopenharmony_cinamespace OHOS {
33bae4d13cSopenharmony_cinamespace Sensors {
34bae4d13cSopenharmony_ciclass NetPacket : public StreamBuffer {
35bae4d13cSopenharmony_cipublic:
36bae4d13cSopenharmony_ci    explicit NetPacket(MessageId msgId);
37bae4d13cSopenharmony_ci    NetPacket(const NetPacket &pkt);
38bae4d13cSopenharmony_ci    NetPacket &operator = (const NetPacket &pkt);
39bae4d13cSopenharmony_ci    ~NetPacket() = default;
40bae4d13cSopenharmony_ci    void MakeData(StreamBuffer &buf) const;
41bae4d13cSopenharmony_ci    size_t GetSize() const;
42bae4d13cSopenharmony_ci    size_t GetPacketLength() const;
43bae4d13cSopenharmony_ci    const char *GetData() const;
44bae4d13cSopenharmony_ci    MessageId GetMsgId() const;
45bae4d13cSopenharmony_ci    DISALLOW_MOVE(NetPacket);
46bae4d13cSopenharmony_ci
47bae4d13cSopenharmony_ciprotected:
48bae4d13cSopenharmony_ci    MessageId msgId_ = MessageId::INVALID;
49bae4d13cSopenharmony_ci};
50bae4d13cSopenharmony_ci} // namespace Sensors
51bae4d13cSopenharmony_ci} // namespace OHOS
52bae4d13cSopenharmony_ci#endif // NET_PACKET_H