raw_sock.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2010 iptelorg GmbH
  5. *
  6. * Permission to use, copy, modify, and distribute this software for any
  7. * purpose with or without fee is hereby granted, provided that the above
  8. * copyright notice and this permission notice appear in all copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  11. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  12. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  13. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  14. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  15. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  16. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. /** raw socket functions.
  19. * @file raw_sock.c
  20. * @ingroup core
  21. * Module: @ref core
  22. */
  23. /*
  24. * History:
  25. * --------
  26. * 2010-06-07 initial version (from older code) andrei
  27. */
  28. #ifndef _raw_sock_h
  29. #define _raw_sock_h
  30. #include "ip_addr.h"
  31. /** filter for limiting packets received on raw sockets. */
  32. struct raw_filter{
  33. struct net dst;
  34. unsigned short port1;
  35. unsigned short port2;
  36. char proto;
  37. };
  38. extern int raw_ipip;
  39. int raw_socket(int proto, struct ip_addr* ip, str* iface, int iphdr_incl);
  40. int raw_udp4_socket(struct ip_addr* ip, str* iface, int iphdr_incl);
  41. int recvpkt4(int sock, char* buf, int len, union sockaddr_union* from,
  42. union sockaddr_union* to);
  43. int raw_udp4_recv(int rsock, char** buf, int len, union sockaddr_union* from,
  44. union sockaddr_union* to, struct raw_filter* rf);
  45. int raw_udp4_send(int rsock, char* buf, unsigned int len,
  46. union sockaddr_union* from,
  47. union sockaddr_union* to);
  48. int raw_iphdr_udp4_send(int rsock, char* buf, unsigned int len,
  49. union sockaddr_union* from,
  50. union sockaddr_union* to, unsigned short mtu);
  51. #endif /* _raw_sock_h */