docsis_common.h 2.6 KB

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