#ifndef __ISNS_HH__
#define __ISNS_HH__
#include <vector>
#define ISNS_VERSION 0x0001
#define ISNS_FUNC_DEVATTRREG 0x0001
#define ISNS_FUNC_DEVATTRQRY 0x0002
#define ISNS_FUNC_DEVGETNEXT 0x0003
#define ISNS_FUNC_DEVDEREG 0x0004
#define ISNS_FUNC_SCNREG 0x0005
#define ISNS_FUNC_SCNDEREG 0x0006
#define ISNS_FUNC_SCNEVENT 0x0007
#define ISNS_FUNC_SCN 0x0008
#define ISNS_FUNC_DDREG 0x0009
#define ISNS_FUNC_DDDEREG 0x000a
#define ISNS_FUNC_DDSREG 0x000b
#define ISNS_FUNC_DDSDEREG 0x000c
#define ISNS_FUNC_ESI 0x000d
#define ISNS_FUNC_HEARTBEAT 0x000e
#define ISNS_FUNC_RESPONSE 0x8000
#define ISNS_FLAG_CLIENT 0x8000
#define ISNS_FLAG_SERVER 0x4000
#define ISNS_FLAG_AUTH 0x2000
#define ISNS_FLAG_REPLACE 0x1000
#define ISNS_FLAG_LAST 0x0800
#define ISNS_FLAG_FIRST 0x0400
struct isns_hdr {
uint8_t ih_version[2];
uint8_t ih_function[2];
uint8_t ih_length[2];
uint8_t ih_flags[2];
uint8_t ih_transaction[2];
uint8_t ih_sequence[2];
};
struct isns_tlv {
uint8_t it_tag[4];
uint8_t it_length[4];
uint8_t it_value[];
};
struct isns_req {
isns_req() {}
isns_req(uint16_t func, uint16_t flags, const char *descr);
const char *descr() const { return ir_descr; }
void add(uint32_t tag, uint32_t len, const void *value);
void add_delim();
void add_str(uint32_t tag, const char *value);
void add_32(uint32_t tag, uint32_t value);
void add_addr(uint32_t tag, const struct addrinfo *ai);
void add_port(uint32_t tag, const struct addrinfo *ai);
bool send(int s);
bool receive(int s);
uint32_t get_status();
private:
void getspace(uint32_t len);
void append(const void *buf, size_t len);
std::vector<char> ir_buf;
const char *ir_descr;
};
#endif