BArpProbe.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**
  2. * @file BArpProbe.h
  3. * @author Ambroz Bizjak <ambrop7@gmail.com>
  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. #ifndef BADVPN_BARPPROBE_H
  23. #define BADVPN_BARPPROBE_H
  24. #include <stdint.h>
  25. #include <misc/debug.h>
  26. #include <misc/debugerror.h>
  27. #include <misc/arp_proto.h>
  28. #include <misc/ethernet_proto.h>
  29. #include <base/DebugObject.h>
  30. #include <system/BDatagram.h>
  31. #include <system/BReactor.h>
  32. #define BARPPROBE_INITIAL_WAITRECV 1000
  33. #define BARPPROBE_INITIAL_NUM_ATTEMPTS 6
  34. #define BARPPROBE_NOEXIST_WAITRECV 15000
  35. #define BARPPROBE_EXIST_WAITSEND 15000
  36. #define BARPPROBE_EXIST_WAITRECV 10000
  37. #define BARPPROBE_EXIST_NUM_NOREPLY 2
  38. #define BARPPROBE_EXIST_PANIC_WAITRECV 1000
  39. #define BARPPROBE_EXIST_PANIC_NUM_NOREPLY 6
  40. #define BARPPROBE_EVENT_EXIST 1
  41. #define BARPPROBE_EVENT_NOEXIST 2
  42. #define BARPPROBE_EVENT_ERROR 3
  43. typedef void (*BArpProbe_handler) (void *user, int event);
  44. typedef struct {
  45. uint32_t addr;
  46. BReactor *reactor;
  47. void *user;
  48. BArpProbe_handler handler;
  49. BDatagram dgram;
  50. uint8_t if_mac[6];
  51. PacketPassInterface *send_if;
  52. int send_sending;
  53. struct arp_packet send_packet;
  54. PacketRecvInterface *recv_if;
  55. struct arp_packet recv_packet;
  56. BTimer timer;
  57. int state;
  58. int num_missed;
  59. DebugError d_err;
  60. DebugObject d_obj;
  61. } BArpProbe;
  62. int BArpProbe_Init (BArpProbe *o, const char *ifname, uint32_t addr, BReactor *reactor, void *user, BArpProbe_handler handler) WARN_UNUSED;
  63. void BArpProbe_Free (BArpProbe *o);
  64. #endif