utp_callbacks.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright (c) 2010-2013 BitTorrent, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  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
  20. * THE SOFTWARE.
  21. */
  22. #ifndef __UTP_CALLBACKS_H__
  23. #define __UTP_CALLBACKS_H__
  24. #include "utp.h"
  25. #include "utp_internal.h"
  26. // Generated by running: grep ^[a-z] utp_callbacks.cpp | sed 's/$/;/'
  27. int utp_call_on_firewall(utp_context *ctx, const struct sockaddr *address, socklen_t address_len);
  28. void utp_call_on_accept(utp_context *ctx, utp_socket *s, const struct sockaddr *address, socklen_t address_len);
  29. void utp_call_on_connect(utp_context *ctx, utp_socket *s);
  30. void utp_call_on_error(utp_context *ctx, utp_socket *s, int error_code);
  31. void utp_call_on_read(utp_context *ctx, utp_socket *s, const byte *buf, size_t len);
  32. void utp_call_on_overhead_statistics(utp_context *ctx, utp_socket *s, int send, size_t len, int type);
  33. void utp_call_on_delay_sample(utp_context *ctx, utp_socket *s, int sample_ms);
  34. void utp_call_on_state_change(utp_context *ctx, utp_socket *s, int state);
  35. uint16 utp_call_get_udp_mtu(utp_context *ctx, utp_socket *s, const struct sockaddr *address, socklen_t address_len);
  36. uint16 utp_call_get_udp_overhead(utp_context *ctx, utp_socket *s, const struct sockaddr *address, socklen_t address_len);
  37. uint64 utp_call_get_milliseconds(utp_context *ctx, utp_socket *s);
  38. uint64 utp_call_get_microseconds(utp_context *ctx, utp_socket *s);
  39. uint32 utp_call_get_random(utp_context *ctx, utp_socket *s);
  40. size_t utp_call_get_read_buffer_size(utp_context *ctx, utp_socket *s);
  41. void utp_call_log(utp_context *ctx, utp_socket *s, const byte *buf);
  42. void utp_call_sendto(utp_context *ctx, utp_socket *s, const byte *buf, size_t len, const struct sockaddr *address, socklen_t address_len, uint32 flags);
  43. #endif // __UTP_CALLBACKS_H__