1 /*
2  *  DOCSIS configuration file encoder.
3  *  Copyright (c) 2001 Cornel Ciocirlan, ctrl@users.sourceforge.net.
4  *  Copyright (c) 2002,2003,2004,2005 Evvolve Media SRL,office@evvolve.com
5  *  Copyright (c) 2014 - 2015 Adrian Simionov, daniel.simionov@gmail.com
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2 of the License, or
10  *  (at your option) any later version.
11  *
12  *  This program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License along
18  *  with this program; if not, write to the Free Software Foundation, Inc.,
19  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  *  DOCSIS is a registered trademark of Cablelabs, http://www.cablelabs.com
22  */
23 
24 /*
25     change history
26 	2003-01-10 changed NUM_IDENTIFIERS to match what we have in docsis_symtable.h
27 
28 */
29 
30 #ifndef _DOCSIS_COMMON_H
31 #define _DOCSIS_COMMON_H
32 
33 
34 #ifndef NUM_IDENTIFIERS
35 #define NUM_IDENTIFIERS 1424
36 #endif /*  NUM_IDENTIFIERS, needed in docsis_symtable.h  */
37 
38 #define MAXINT 2000000000
39 #define TLV_VSIZE 1024
40 #define TRUE 1
41 #define FALSE 0
42 
43 #define INDENT_NOOP 		100
44 #define INDENT_CLEAR 		101
45 #define INDENT_INCREMENT 	102
46 #define INDENT_DECREMENT 	103
47 
48 struct symbol_entry;
49 
50 typedef int (*encode_func_t) (unsigned char *, void *, struct symbol_entry *);
51 typedef void (*decode_func_t) (unsigned char *, struct symbol_entry *, size_t length);
52 
53 struct symbol_entry {
54 	unsigned int id;
55 	char sym_ident[50];
56 	unsigned char docsis_code;
57 	unsigned int parent_id;
58 	encode_func_t encode_func;
59 	decode_func_t decode_func;
60 	unsigned int low_limit;
61 	unsigned int high_limit;
62 };
63 
64 typedef struct symbol_entry symbol_type;
65 
66 struct tlv {
67 	unsigned short docs_code;
68 	unsigned short tlv_len;
69 	unsigned char tlv_value[TLV_VSIZE];
70 	struct tlv *parent;
71 	struct tlv *next_sibling;
72 	struct tlv *first_child;
73 };
74 
75 union t_val {           /* union for returning token values */
76         int intval;             /* For integers */
77         unsigned int uintval;   /* For unsigned integers */
78         symbol_type *symptr;    /* For token identifiers */
79         char *strval;           /* For strings */
80         unsigned char *ustrval; /* For (unsigned char *) strings */
81         unsigned int ip;        /* For IP Addresses */
82         struct tlv_list *tlvlist; /* For for struct tlvlist pointers */
83         struct tlv *tlvptr;     /* For struct tlv pointers; */
84 };
85 
86 #endif /* _DOCSIS_COMMON_H */
87 
88