ats_api_scanner.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2010-2015 GNUnet e.V.
  4. GNUnet is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Affero General Public License as published
  6. by the Free Software Foundation, either version 3 of the License,
  7. or (at your option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. SPDX-License-Identifier: AGPL3.0-or-later
  15. */
  16. /**
  17. * @file ats/ats_api_scanner.c
  18. * @brief LAN interface scanning to determine IPs in LAN
  19. * @author Christian Grothoff
  20. * @author Matthias Wachs
  21. */
  22. #include "platform.h"
  23. #include "gnunet_ats_service.h"
  24. /**
  25. * Convert ATS properties from host to network byte order.
  26. *
  27. * @param nbo[OUT] value written
  28. * @param hbo value read
  29. */
  30. void
  31. GNUNET_ATS_properties_hton(struct GNUNET_ATS_PropertiesNBO *nbo,
  32. const struct GNUNET_ATS_Properties *hbo)
  33. {
  34. nbo->utilization_out = htonl(hbo->utilization_out);
  35. nbo->utilization_in = htonl(hbo->utilization_in);
  36. nbo->scope = htonl((uint32_t)hbo->scope);
  37. nbo->distance = htonl(hbo->distance);
  38. nbo->delay = GNUNET_TIME_relative_hton(hbo->delay);
  39. }
  40. /**
  41. * Convert ATS properties from network to host byte order.
  42. *
  43. * @param hbo[OUT] value written
  44. * @param nbo value read
  45. */
  46. void
  47. GNUNET_ATS_properties_ntoh(struct GNUNET_ATS_Properties *hbo,
  48. const struct GNUNET_ATS_PropertiesNBO *nbo)
  49. {
  50. hbo->utilization_out = ntohl(nbo->utilization_out);
  51. hbo->utilization_in = ntohl(nbo->utilization_in);
  52. hbo->scope = ntohl((uint32_t)nbo->scope);
  53. hbo->distance = ntohl(nbo->distance);
  54. hbo->delay = GNUNET_TIME_relative_ntoh(nbo->delay);
  55. }
  56. /* end of ats_api_scanner.c */