* init module function */
| 114 | * init module function |
| 115 | */ |
| 116 | static int mod_init(void) |
| 117 | { |
| 118 | LM_NOTICE("initializing JSON-RPC module ...\n"); |
| 119 | |
| 120 | if (jrpc_connect_timeout <= 0) { |
| 121 | LM_ERR("invalid value for connect timeout (%d)! " |
| 122 | "Please specify a positive value in milliseconds!\n", jrpc_connect_timeout); |
| 123 | return -1; |
| 124 | } |
| 125 | |
| 126 | if (jrpc_write_timeout <= 0) { |
| 127 | LM_ERR("invalid value for write timeout (%d)! " |
| 128 | "Please specify a positive value in milliseconds!\n", jrpc_write_timeout); |
| 129 | return -1; |
| 130 | } |
| 131 | |
| 132 | if (jrpc_read_timeout <= 0) { |
| 133 | LM_ERR("invalid value for read timeout (%d)! " |
| 134 | "Please specify a positive value in milliseconds!\n", jrpc_read_timeout); |
| 135 | return -1; |
| 136 | } |
| 137 | |
| 138 | jsonrpc_id_index = my_pid() & USHRT_MAX; |
| 139 | jsonrpc_id_index |= rand() << sizeof(unsigned short); |
| 140 | return 0; |
| 141 | } |
| 142 | |
| 143 | static union sockaddr_union *jsonrpc_get_dst(str *ip_port) |
| 144 | { |