blob: 331fe2b0e1b76fe4dc66618404a63d15da3714db (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
#ifndef __DEFS_H__
#define __DEFS_H__
#include <stdlib.h>
#include <stdio.h>
#include "cli_val.h"
#define boolean int
#define LOWEST_PRIORITY 1000
#define MAX_DEPTH 128
#define ENV_ACTION_NAME "COMMIT_ACTION"
#define ENV_ACTION_DELETE "DELETE"
#define ENV_ACTION_SET "SET"
#define ENV_ACTION_ACTIVE "ACTIVE"
#define ENV_SIBLING_POSITION "COMMIT_SIBLING_POSITION"
#define ENV_DATA_PATH "NODE_DATA_PATH"
#define ENV_COMMIT_STATUS "COMMIT_STATUS"
#define COMMIT_CHANGES_FILE "/tmp/.changes"
#define POST_COMMIT_HOOK_DIR "/etc/commit"
#define PRE_COMMIT_HOOK_DIR "/etc/pre_commit"
struct Result
{
int _err_code;
char *_err_str;
int _action;
int _mode;
void* _data;
};
typedef enum {
K_NO_OP = 0x01,
K_ACTIVE_OP = 0x02, //as a result of an already created node, but assuming action
K_SET_OP = 0x04,
K_CREATE_OP = 0x08,
K_DEL_OP = 0x10
} NODE_OPERATION;
typedef enum {
K_NO_DISABLE_OP = 0X00,
K_LOCAL_DISABLE_OP = 0x02, //MEANS DISABLE FLAG IS SET IN LOCAL CONFIGURATION
K_ACTIVE_DISABLE_OP = 0x04 //MEANS DISABLE FLAG IS SET IN ACTIVE CONFIGURATION
} NODE_ACTIVATE;
#define IS_SET(op) (op & K_SET_OP)
#define IS_ACTIVE(op) (op & K_ACTIVE_OP)
#define IS_CREATE(op) (op & K_CREATE_OP)
#define IS_DELETE(op) (op & K_DEL_OP)
#define IS_NOOP(op) (op & K_NO_OP)
#define IS_SET_OR_CREATE(op) ((op & K_SET_OP) || (op & K_CREATE_OP))
/**
* keeps both configuration and template data in single structure
*
**/
/*
TODO: either port over to new system or retain complete set of cli_val definiaitons.
remove _actions and rely on def in the future.
*/
struct Config
{
boolean _multi;
int _priority;
char* _priority_extended;
int _limit;
vtw_def _def; //keep this here
char* _help;
char* _default;
char* _path;
};
/*
* is used to define embedded nodes (multi) and leafs
*/
struct Data
{
char* _name; //name of this node
boolean _value; //is this a value?
char* _path;
NODE_OPERATION _operation; //no-op, set, or delete
NODE_ACTIVATE _disable_op; //is this node currently deactivated?
};
/*
* additional data to be defined and used by client
*/
struct Aux
{
boolean _first;
boolean _last;
};
struct VyattaNode
{
struct Data _data;
struct Config _config;
struct Aux _aux;
};
#endif //__DEFS_H__
|