Coverage Report

Created: 2024-02-08 06:10

/src/opendnp3/cpp/lib/src/app/AppControlField.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2013-2022 Step Function I/O, LLC
3
 *
4
 * Licensed to Green Energy Corp (www.greenenergycorp.com) and Step Function I/O
5
 * LLC (https://stepfunc.io) under one or more contributor license agreements.
6
 * See the NOTICE file distributed with this work for additional information
7
 * regarding copyright ownership. Green Energy Corp and Step Function I/O LLC license
8
 * this file to you under the Apache License, Version 2.0 (the "License"); you
9
 * may not use this file except in compliance with the License. You may obtain
10
 * a copy of the License at:
11
 *
12
 * http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
20
#ifndef OPENDNP3_APPCONTROLFIELD_H
21
#define OPENDNP3_APPCONTROLFIELD_H
22
23
#include <cstdint>
24
25
namespace opendnp3
26
{
27
28
/** Represents the first byte in every APDU
29
 */
30
struct AppControlField
31
{
32
    const static AppControlField DEFAULT;
33
34
    static AppControlField Request(uint8_t seq);
35
36
396
    AppControlField() = default;
37
38
    explicit AppControlField(uint8_t byte);
39
40
    AppControlField(bool fir, bool fin, bool con, bool uns, uint8_t seq = 0);
41
42
    uint8_t ToByte() const;
43
44
    bool IsFirAndFin() const
45
0
    {
46
0
        return FIR && FIN;
47
0
    }
48
49
    bool FIR = true;
50
    bool FIN = true;
51
    bool CON = false;
52
    bool UNS = false;
53
    uint8_t SEQ = 0;
54
55
private:
56
    static const uint8_t FIR_MASK = 0x80;
57
    static const uint8_t FIN_MASK = 0x40;
58
    static const uint8_t CON_MASK = 0x20;
59
    static const uint8_t UNS_MASK = 0x10;
60
    static const uint8_t SEQ_MASK = 0x0F;
61
};
62
63
} // namespace opendnp3
64
65
#endif