/* * called in the OpenSIPS initialization phase by the main process. * forks the binary packet UDP receivers. * * @return: 0 on success */ int start_bin_receivers(void) { pid_t pid; int i; if (udp_init_listener(bin, 0) != 0) return -1; for (i = 1; i <= bin_children; i++) { if ((pid = internal_fork("BIN receiver")) < 0) { LM_CRIT("Cannot fork binary packet receiver process!\n"); return -1; } if (pid == 0) { LM_DBG("CHILD sock: %d\n", bin->socket); child_index = i; set_proc_attrs("BIN receiver %.*s ", bin->sock_str.len, bin->sock_str.s); bind_address = bin; if (init_child(PROC_BIN) < 0) { LM_ERR("init_child failed for BIN listener\n"); report_failure_status(); exit(-1); } bin_receive_loop(); exit(-1); } else LM_DBG("PARENT sock: %d\n", bin->socket); } return 0; }
static int proto_hep_init_listener(struct socket_info *si) { /* we do not do anything particular, so * transparently use the generic listener init from net TCP layer * or net UDP depending on hep version */ int ret = -1; switch (hep_version) { case 1: case 2: ret = udp_init_listener(si, hep_async?O_NONBLOCK:0); break; case 3: ret = tcp_init_listener(si); break; default: LM_ERR("hep version [%d] not implemented\n", hep_version); } return ret; }
static int proto_udp_init_listener(struct socket_info *si) { /* we do not do anything particular to UDP plain here, so * transparently use the generic listener init from net UDP layer */ return udp_init_listener(si, O_NONBLOCK); }
static int proto_hep_init_udp_listener(struct socket_info *si) { return udp_init_listener(si, hep_async?O_NONBLOCK:0); }