Map27
 All Classes Functions Variables Enumerations Enumerator Pages
Address.h
1 // Address.h
2 //
3 // Author: Mike McCauley (mikem@airspayce.com)
4 // Copyright (C) 2013 Mike McCauley
5 // $Id: Address.h,v 1.2 2013/07/14 07:15:46 mikem Exp mikem $
6 
7 
8 #ifndef MAP27_ADDRESS_H
9 #define MAP27_ADDRESS_H
10 
11 #include <stdint.h>
12 
13 // Max possible address component length
14 #define MAP27_ADDRESS_MAX_ALEN 15
15 
16 // Some address and ident definitions
17 // Address types ADESC
18 #define MAP27_ADDRESS_ADESC_NO_ADDRESS 0x00
19 #define MAP27_ADDRESS_ADESC_SAMIS_BCD 0x01
20 #define MAP27_ADDRESS_ADESC_SPARE 0x02
21 #define MAP27_ADDRESS_ADESC_MPT1327_PABX_BINARY 0x03
22 #define MAP27_ADDRESS_ADESC_MPT1327_PABX 0x04
23 #define MAP27_ADDRESS_ADESC_MPT1327 0x05
24 #define MAP27_ADDRESS_ADESC_MPT1327_SAMIS 0x06
25 #define MAP27_ADDRESS_ADESC_MMI_DIALLED_NUMBER 0x07
26 
27 // Well known prefixes and idents
28 #define MAP27_ADDRESS_DUMMYP 0x00
29 #define MAP27_ADDRESS_DUMMYI 0x00
30 #define MAP27_ADDRESS_PSTNGI 8101
31 #define MAP27_ADDRESS_PABXI 8102
32 #define MAP27_ADDRESS_DNI 8103
33 
34 #define MAP27_ADDRESS_PSTNI(j) (8120+j)
35 #define MAP27_ADDRESS_REGI 8185
36 #define MAP27_ADDRESS_INCI 8186
37 #define MAP27_ADDRESS_DIVERTI 8187
38 #define MAP27_ADDRESS_SDMI 8188
39 #define MAP27_ADDRESS_IPFIXI 8189
40 #define MAP27_ADDRESS_TSCI 8190
41 #define MAP27_ADDRESS_ALLI 0000
42 
58 {
59 public:
60 
63  Map27Address();
64 
67  void setPrefix(uint8_t prefix = MAP27_ADDRESS_DUMMYP);
68 
71  uint8_t prefix() const;
72 
75  void setIdent(uint16_t ident = MAP27_ADDRESS_DUMMYI);
76 
79  uint16_t ident() const;
80 
87  void setAddress(uint8_t adesc = MAP27_ADDRESS_ADESC_NO_ADDRESS, uint8_t* address = 0, uint8_t alen = 0);
88 
91  uint8_t adesc() const;
92 
95  uint8_t alen() const;
96 
101  const uint8_t* address() const;
102 
110  uint8_t decodeBasic(uint8_t* buf, uint16_t bufLen);
111 
117  uint8_t decode(uint8_t* buf, uint16_t bufLen);
118 
123  uint8_t encodeBasic(uint8_t* buf, uint16_t bufLen) const;
124 
129  uint8_t encode(uint8_t* buf, uint16_t bufLen) const;
130 
133  uint16_t mpt1343_prefix() const;
134 
138  uint16_t mpt1343_fin(uint16_t ibi) const;
139 
143  uint16_t mpt1343_un3d(uint16_t ibi) const;
144 
148  uint16_t mpt1343_un2d(uint16_t ibi) const;
149 
153  const char* asString();
154 
155 private:
156  uint8_t _prefix;
157  uint16_t _ident;
158  uint8_t _adesc;
159  uint8_t _alen;
160  uint8_t _address[MAP27_ADDRESS_MAX_ALEN];
161 };
162 
163 #endif
uint8_t alen() const
Definition: Address.cpp:56
const char * asString()
Definition: Address.cpp:144
uint8_t prefix() const
Definition: Address.cpp:26
uint8_t decode(uint8_t *buf, uint16_t bufLen)
Definition: Address.cpp:80
void setIdent(uint16_t ident=MAP27_ADDRESS_DUMMYI)
Definition: Address.cpp:31
uint8_t encode(uint8_t *buf, uint16_t bufLen) const
Definition: Address.cpp:109
Class for handling Map27 Prefix/Ident/Address.
Definition: Address.h:57
uint8_t encodeBasic(uint8_t *buf, uint16_t bufLen) const
Definition: Address.cpp:97
uint16_t mpt1343_prefix() const
Definition: Address.cpp:124
uint8_t decodeBasic(uint8_t *buf, uint16_t bufLen)
Definition: Address.cpp:66
uint16_t mpt1343_un2d(uint16_t ibi) const
Definition: Address.cpp:139
const uint8_t * address() const
Definition: Address.cpp:61
uint16_t ident() const
Definition: Address.cpp:36
uint8_t adesc() const
Definition: Address.cpp:51
uint16_t mpt1343_fin(uint16_t ibi) const
Definition: Address.cpp:129
void setPrefix(uint8_t prefix=MAP27_ADDRESS_DUMMYP)
Definition: Address.cpp:21
void setAddress(uint8_t adesc=MAP27_ADDRESS_ADESC_NO_ADDRESS, uint8_t *address=0, uint8_t alen=0)
Definition: Address.cpp:41
uint16_t mpt1343_un3d(uint16_t ibi) const
Definition: Address.cpp:134
Map27Address()
Definition: Address.cpp:13