1//
2// Copyright (C) 2015 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//      http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17#ifndef DHCP_CLIENT_PARSER_H_
18#define DHCP_CLIENT_PARSER_H_
19
20#include <cstdint>
21
22namespace dhcp_client {
23
24class DHCPOptionsParser {
25 public:
26  virtual bool GetOption(const uint8_t* buffer,
27                         uint8_t length,
28                         void* value) = 0;
29  virtual ~DHCPOptionsParser() {}
30};
31
32class UInt8Parser : public DHCPOptionsParser {
33 public:
34  UInt8Parser() {}
35  bool GetOption(const uint8_t* buffer,
36                 uint8_t length,
37                 void* value) override;
38};
39
40class UInt16Parser : public DHCPOptionsParser {
41 public:
42  UInt16Parser() {}
43  bool GetOption(const uint8_t* buffer,
44                 uint8_t length,
45                 void* value) override;
46};
47
48class UInt32Parser : public DHCPOptionsParser {
49 public:
50  UInt32Parser() {}
51  bool GetOption(const uint8_t* buffer,
52                 uint8_t length,
53                 void* value) override;
54};
55
56class UInt8ListParser : public DHCPOptionsParser {
57 public:
58  UInt8ListParser() {}
59  bool GetOption(const uint8_t* buffer,
60                 uint8_t length,
61                 void* value) override;
62};
63
64class UInt16ListParser : public DHCPOptionsParser {
65 public:
66  UInt16ListParser() {}
67  bool GetOption(const uint8_t* buffer,
68                 uint8_t length,
69                 void* value) override;
70};
71
72class UInt32ListParser : public DHCPOptionsParser {
73 public:
74  UInt32ListParser() {}
75  bool GetOption(const uint8_t* buffer,
76                 uint8_t length,
77                 void* value) override;
78};
79
80class UInt32PairListParser : public DHCPOptionsParser {
81 public:
82  UInt32PairListParser() {}
83  bool GetOption(const uint8_t* buffer,
84                 uint8_t length,
85                 void* value) override;
86};
87
88class BoolParser : public DHCPOptionsParser {
89 public:
90  BoolParser() {}
91  bool GetOption(const uint8_t* buffer,
92                 uint8_t length,
93                 void* value) override;
94};
95
96class StringParser : public DHCPOptionsParser {
97 public:
98  StringParser() {}
99  bool GetOption(const uint8_t* buffer,
100                 uint8_t length,
101                 void* value) override;
102};
103
104class ByteArrayParser : public DHCPOptionsParser {
105 public:
106  bool GetOption(const uint8_t* buffer,
107                 uint8_t length,
108                 void* value) override;
109};
110}  // namespace dhcp_client
111
112#endif  // DHCP_CLIENT_PARSER_H_
113