NetDev.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 <http://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 eh an exception handler.
  31. */
  32. void NetDev_addAddress(const char* ifName,
  33. struct Sockaddr* sa,
  34. struct Log* logger,
  35. struct Except* eh);
  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. void NetDev_setMTU(const char* interfaceName,
  45. uint32_t mtu,
  46. struct Log* logger,
  47. struct Except* eh);
  48. void NetDev_flushAddresses(const char* deviceName, struct Except* eh);
  49. /**
  50. * Set a route to an interface.
  51. *
  52. * @param ifName the name of the interface to alter.
  53. * @param sa the ip address to use use for route base.
  54. * @param prefixLen the number of bits netmast to include in the route.
  55. * @param logger
  56. * @param eh an exception handler.
  57. */
  58. void NetDev_setRoutes(const char* ifName,
  59. struct Sockaddr** prefixSet,
  60. int prefixCount,
  61. struct Log* logger,
  62. struct Allocator* tempAlloc,
  63. struct Except* eh);
  64. #endif