NetDev.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* vim: set expandtab ts=4 sw=4: */
  2. /*
  3. * You may redistribute this program and/or modify it under the terms of
  4. * the GNU General Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. */
  15. #ifndef NetDev_H
  16. #define NetDev_H
  17. #include "exception/Except.h"
  18. #include "util/log/Log.h"
  19. #include "util/platform/Sockaddr.h"
  20. #include "util/Linker.h"
  21. Linker_require("util/platform/netdev/NetDev.c")
  22. /**
  23. * Set an address on an interface, if the interface is down (linux) bring it up,
  24. * and if the interface requires an explicit route (Illumos), configure it.
  25. *
  26. * @param ifName the name of the interface to alter.
  27. * @param sa the ip address to set.
  28. * @param prefixLen the number of bits netmask to include in the route.
  29. * @param logger
  30. * @param alloc allocator for errors.
  31. */
  32. Er_DEFUN(void NetDev_addAddress(const char* ifName,
  33. struct Sockaddr* sa,
  34. struct Log* logger,
  35. struct Allocator* alloc));
  36. /**
  37. * Set the MTU of an interface.
  38. *
  39. * @param interfaceName the name of the interface to set the MTU for.
  40. * @param mtu the desired MTU.
  41. * @param logger where to write information.
  42. * @param eh an exception handler.
  43. */
  44. Er_DEFUN(void NetDev_setMTU(const char* interfaceName,
  45. uint32_t mtu,
  46. struct Log* logger,
  47. struct Allocator* alloc));
  48. Er_DEFUN(void NetDev_flushAddresses(const char* deviceName, struct Allocator* alloc));
  49. /**
  50. * Set a route to an interface.
  51. */
  52. Er_DEFUN(void NetDev_setRoutes(const char* ifName,
  53. struct Sockaddr** prefixSet,
  54. int prefixCount,
  55. struct Log* logger,
  56. struct Allocator* tempAlloc));
  57. #endif