isdnhdlc.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * isdnhdlc.h -- General purpose ISDN HDLC decoder.
  3. *
  4. * Implementation of a HDLC decoder/encoder in software.
  5. * Neccessary because some ISDN devices don't have HDLC
  6. * controllers. Also included: a bit reversal table.
  7. *
  8. *Copyright (C) 2002 Wolfgang Mües <wolfgang@iksw-muees.de>
  9. * 2001 Frode Isaksen <fisaksen@bewan.com>
  10. * 2001 Kai Germaschewski <kai.germaschewski@gmx.de>
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  25. */
  26. #ifndef __ISDNHDLC_H__
  27. #define __ISDNHDLC_H__
  28. struct isdnhdlc_vars {
  29. int bit_shift;
  30. int hdlc_bits1;
  31. int data_bits;
  32. int ffbit_shift; // encoding only
  33. int state;
  34. int dstpos;
  35. unsigned short crc;
  36. unsigned char cbin;
  37. unsigned char shift_reg;
  38. unsigned char ffvalue;
  39. unsigned int data_received:1; // set if transferring data
  40. unsigned int dchannel:1; // set if D channel (send idle instead of flags)
  41. unsigned int do_adapt56:1; // set if 56K adaptation
  42. unsigned int do_closing:1; // set if in closing phase (need to send CRC + flag
  43. };
  44. /*
  45. The return value from isdnhdlc_decode is
  46. the frame length, 0 if no complete frame was decoded,
  47. or a negative error number
  48. */
  49. #define HDLC_FRAMING_ERROR 1
  50. #define HDLC_CRC_ERROR 2
  51. #define HDLC_LENGTH_ERROR 3
  52. extern void isdnhdlc_rcv_init (struct isdnhdlc_vars *hdlc, int do_adapt56);
  53. extern int isdnhdlc_decode (struct isdnhdlc_vars *hdlc, const unsigned char *src, int slen,int *count,
  54. unsigned char *dst, int dsize);
  55. extern void isdnhdlc_out_init (struct isdnhdlc_vars *hdlc,int is_d_channel,int do_adapt56);
  56. extern int isdnhdlc_encode (struct isdnhdlc_vars *hdlc,const unsigned char *src,unsigned short slen,int *count,
  57. unsigned char *dst,int dsize);
  58. #endif /* __ISDNHDLC_H__ */