init_socks.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2006 iptelorg GmbH
  5. *
  6. * This file is part of ser, a free SIP server.
  7. *
  8. * ser is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version
  12. *
  13. * For a license to use the ser software under conditions
  14. * other than those described here, or to purchase support for this
  15. * software, please contact iptel.org by e-mail at the following addresses:
  16. * [email protected]
  17. *
  18. * ser is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  26. */
  27. /* History:
  28. * --------
  29. * 2006-02-14 created by andrei
  30. */
  31. #ifndef _init_socks_h
  32. #define _init_socks_h
  33. #include <sys/types.h>
  34. #include <sys/un.h>
  35. #include "../../ip_addr.h"
  36. enum socket_protos { UNKNOWN_SOCK=0, UDP_SOCK, TCP_SOCK,
  37. UNIXS_SOCK, UNIXD_SOCK
  38. #ifdef USE_FIFO
  39. , FIFO_SOCK
  40. #endif
  41. };
  42. int init_unix_sock(struct sockaddr_un* su, char* name, int type,
  43. int perm, int uid, int gid);
  44. int init_tcpudp_sock(union sockaddr_union* su, char* address, int port,
  45. enum socket_protos type);
  46. int init_sock_opt(int s, enum socket_protos type);
  47. inline static char* socket_proto_name(enum socket_protos p)
  48. {
  49. switch(p){
  50. case UDP_SOCK:
  51. return "udp";
  52. case TCP_SOCK:
  53. return "tcp";
  54. case UNIXS_SOCK:
  55. return "unix_stream";
  56. case UNIXD_SOCK:
  57. return "unix_dgram";
  58. #ifdef USE_FIFO
  59. case FIFO_SOCK:
  60. return "fifo";
  61. #endif
  62. default:
  63. ;
  64. }
  65. return "<unknown>";
  66. }
  67. #endif