unixsock.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2005 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. #include "../../str.h"
  28. #include "../../sr_module.h"
  29. #include "../../error.h"
  30. #include "../../mem/mem.h"
  31. #include "../../parser/msg_parser.h"
  32. #include "../../ut.h"
  33. #include "../../dprint.h"
  34. #include "../../pt.h"
  35. #include "unixsock_server.h"
  36. MODULE_VERSION
  37. static int mod_init(void);
  38. static int child_init(int rank);
  39. /*
  40. * Exported functions
  41. */
  42. static cmd_export_t cmds[] = {
  43. {0, 0, 0, 0, 0}
  44. };
  45. /*
  46. * Exported parameters
  47. */
  48. static param_export_t params[] = {
  49. {"socket", PARAM_STRING, &unixsock_name },
  50. {"children", PARAM_INT, &unixsock_children },
  51. {"send_timeout", PARAM_INT, &unixsock_tx_timeout},
  52. {"socket_user", PARAM_STRING, &unixsock_user },
  53. {"socket_mode", PARAM_STRING, &unixsock_mode },
  54. {"socket_group", PARAM_STRING, &unixsock_group },
  55. {0, 0, 0}
  56. };
  57. struct module_exports exports = {
  58. "unixsock",
  59. cmds, /* Exported commands */
  60. 0, /* Exported RPC methods */
  61. params, /* Exported parameters */
  62. mod_init, /* module initialization function */
  63. 0, /* response function*/
  64. 0, /* destroy function */
  65. 0, /* oncancel function */
  66. child_init /* per-child init function */
  67. };
  68. static int mod_init(void)
  69. {
  70. if (init_unixsock_socket() < 0) return -1;
  71. /* Signal to the core that we will be
  72. * creating additional processes
  73. */
  74. if (unixsock_name) register_procs(unixsock_children);
  75. return 0;
  76. }
  77. static int child_init(int rank)
  78. {
  79. if (rank == PROC_MAIN) {
  80. if (init_unixsock_children() < 0) return -1;
  81. }
  82. return 0;
  83. }