snowid_util.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. *
  3. * MIT License
  4. *
  5. * Copyright (c) 2022 beyonddream
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. * The above copyright notice and this permission notice shall be included in all
  13. * copies or substantial portions of the Software.
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. #ifndef __SNOWID_UTIL_H__
  23. #define __SNOWID_UTIL_H__
  24. #include <stdbool.h>
  25. #include <stdint.h>
  26. /**
  27. * Retrive a binary representation of the H/W (MAC) address either from the interface name
  28. * but if the interface name is not present then one of the H/W address from any of the
  29. * interfaces except loopback.
  30. *
  31. * @param workerid Binary representation of the mac address of the interface.
  32. * @param interface Interface name to pull the address from.
  33. * @return bool - true if we could return hw address, else false.
  34. */
  35. bool get_hw_addr_as_binary(uint64_t *workerid, char *interface);
  36. /**
  37. * Get current timestamp
  38. *
  39. * @param result - set the current timestamp to the value pointed by result.
  40. * @return bool - true if we can get current timestamp, else false.
  41. */
  42. bool get_current_ts(uint64_t *result);
  43. #endif /* __SNOWID_UTIL_H__ */