ctrl_socks.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 _ctrl_socks_h
  32. #define _ctrl_socks_h
  33. #include <sys/types.h>
  34. #include <sys/socket.h>
  35. #include <sys/un.h>
  36. #include <sys/uio.h> /* iovec */
  37. #include "../../ip_addr.h"
  38. #include "init_socks.h"
  39. enum payload_proto { P_BINRPC , P_FIFO };
  40. struct id_list{
  41. char* name;
  42. enum socket_protos proto;
  43. enum payload_proto data_proto;
  44. int port;
  45. char* buf; /* name points somewhere here */
  46. struct id_list* next;
  47. };
  48. union sockaddr_u{
  49. union sockaddr_union sa_in;
  50. struct sockaddr_un sa_un;
  51. };
  52. /* list of control sockets */
  53. struct ctrl_socket{
  54. int fd;
  55. int write_fd; /* used only by fifo */
  56. enum socket_protos transport;
  57. enum payload_proto p_proto;
  58. char* name;
  59. int port;
  60. struct ctrl_socket* next;
  61. union sockaddr_u u;
  62. void *data; /* extra data, socket dependent */
  63. };
  64. struct id_list* parse_listen_id(char*, int, enum socket_protos);
  65. int init_ctrl_sockets(struct ctrl_socket** c_lst, struct id_list* lst,
  66. int def_port, int perm, int uid, int gid);
  67. void free_id_list(struct id_list*);
  68. void free_ctrl_socket_list(struct ctrl_socket* l);
  69. inline static char* payload_proto_name(enum payload_proto p)
  70. {
  71. switch(p){
  72. case P_BINRPC:
  73. return "binrpc";
  74. case P_FIFO:
  75. return "fifo";
  76. default:
  77. ;
  78. }
  79. return "<unknown>";
  80. }
  81. #endif