BDHCPClient.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * @file BDHCPClient.h
  3. * @author Ambroz Bizjak <[email protected]>
  4. *
  5. * @section LICENSE
  6. *
  7. * This file is part of BadVPN.
  8. *
  9. * BadVPN is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2
  11. * as published by the Free Software Foundation.
  12. *
  13. * BadVPN is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program; if not, write to the Free Software Foundation, Inc.,
  20. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  21. *
  22. * @section DESCRIPTION
  23. *
  24. * DHCP client.
  25. */
  26. #ifndef BADVPN_DHCPCLIENT_BDHCPCLIENT_H
  27. #define BADVPN_DHCPCLIENT_BDHCPCLIENT_H
  28. #include <system/DebugObject.h>
  29. #include <system/BSocket.h>
  30. #include <flow/PacketCopier.h>
  31. #include <flow/SinglePacketBuffer.h>
  32. #include <flow/DatagramSocketSink.h>
  33. #include <flow/DatagramSocketSource.h>
  34. #include <dhcpclient/BDHCPClientCore.h>
  35. #include <dhcpclient/DHCPIpUdpDecoder.h>
  36. #include <dhcpclient/DHCPIpUdpEncoder.h>
  37. typedef struct {
  38. BReactor *reactor;
  39. BSocket sock;
  40. FlowErrorDomain domain;
  41. PacketCopier send_copier;
  42. DHCPIpUdpEncoder send_encoder;
  43. SinglePacketBuffer send_buffer;
  44. DatagramSocketSink send_sink;
  45. DatagramSocketSource recv_source;
  46. SinglePacketBuffer recv_buffer;
  47. DHCPIpUdpDecoder recv_decoder;
  48. PacketCopier recv_copier;
  49. BDHCPClientCore dhcp;
  50. DebugObject d_obj;
  51. } BDHCPClient;
  52. int BDHCPClient_Init (BDHCPClient *o, const char *ifname, BReactor *reactor, BDHCPClientCore_handler handler, void *user);
  53. void BDHCPClient_Free (BDHCPClient *o);
  54. void BDHCPClient_GetClientIP (BDHCPClient *o, uint32_t *out_ip);
  55. void BDHCPClient_GetClientMask (BDHCPClient *o, uint32_t *out_mask);
  56. int BDHCPClient_GetRouter (BDHCPClient *o, uint32_t *out_router);
  57. int BDHCPClient_GetDNS (BDHCPClient *o, uint32_t *out_dns_servers, size_t max_dns_servers);
  58. #endif