hdlc_api.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* $Id$ */
  2. /*
  3. * Copyright (c) 2001-2010 Aaron Turner <aturner at synfin dot net>
  4. * Copyright (c) 2013-2018 Fred Klassen <tcpreplay at appneta dot com> - AppNeta
  5. *
  6. * The Tcpreplay Suite of tools is free software: you can redistribute it
  7. * and/or modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation, either version 3 of the
  9. * License, or with the authors permission any later version.
  10. *
  11. * The Tcpreplay Suite 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
  17. * along with the Tcpreplay Suite. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include "defines.h"
  20. #include "common.h"
  21. #include "tcpedit.h"
  22. #include "hdlc.h"
  23. #include "hdlc_api.h"
  24. /**
  25. * \brief Set the HDLC control value
  26. *
  27. * Reasonable values are 0-255
  28. */
  29. int
  30. tcpedit_hdlc_set_control(tcpedit_t *tcpedit, uint8_t control)
  31. {
  32. tcpeditdlt_t *ctx;
  33. tcpeditdlt_plugin_t *plugin;
  34. hdlc_config_t *config;
  35. assert(tcpedit);
  36. ctx = tcpedit->dlt_ctx;
  37. assert(ctx);
  38. plugin = ctx->decoder;
  39. assert(plugin);
  40. config = (hdlc_config_t *)plugin->config;
  41. config->control = control;
  42. return TCPEDIT_OK;
  43. }
  44. /**
  45. * \brief Set the HDLC address value
  46. *
  47. * Reasonable values are 0x000F (unicast) and 0x00BF (broadcast), but we
  48. * accept any value
  49. */
  50. int
  51. tcpedit_hdlc_set_address(tcpedit_t *tcpedit, uint8_t address)
  52. {
  53. tcpeditdlt_t *ctx;
  54. tcpeditdlt_plugin_t *plugin;
  55. hdlc_config_t *config;
  56. assert(tcpedit);
  57. ctx = tcpedit->dlt_ctx;
  58. assert(ctx);
  59. plugin = ctx->decoder;
  60. assert(plugin);
  61. config = (hdlc_config_t *)plugin->config;
  62. config->address = address;
  63. return TCPEDIT_OK;
  64. }