Benny Prijono | 8df5b02 | 2006-03-01 19:31:18 +0000 | [diff] [blame^] | 1 | /* $Id$ */ |
| 2 | /* |
| 3 | * Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | */ |
| 19 | #ifndef __PJSIP_PERF_H__ |
| 20 | #define __PJSIP_PERF_H__ |
| 21 | |
| 22 | #include <pjsua-lib/pjsua.h> |
| 23 | |
| 24 | |
| 25 | PJ_BEGIN_DECL |
| 26 | |
| 27 | |
| 28 | typedef struct batch batch; |
| 29 | typedef struct session session; |
| 30 | |
| 31 | /** |
| 32 | * A test batch. |
| 33 | */ |
| 34 | struct batch |
| 35 | { |
| 36 | PJ_DECL_LIST_MEMBER(struct batch); |
| 37 | |
| 38 | unsigned rate; |
| 39 | unsigned started; |
| 40 | unsigned success; |
| 41 | unsigned failed; |
| 42 | pj_time_val start_time; |
| 43 | pj_time_val end_time; |
| 44 | }; |
| 45 | |
| 46 | /** |
| 47 | * Test session. |
| 48 | */ |
| 49 | struct session |
| 50 | { |
| 51 | pj_pool_t *pool; |
| 52 | pj_time_val start_time; |
| 53 | pj_bool_t stopping; |
| 54 | pjsip_method method; |
| 55 | struct batch active_list; |
| 56 | struct batch free_list; |
| 57 | |
| 58 | unsigned outstanding; |
| 59 | unsigned total_created; |
| 60 | }; |
| 61 | |
| 62 | |
| 63 | /** |
| 64 | * Request parameter. |
| 65 | */ |
| 66 | struct request_param |
| 67 | { |
| 68 | pj_str_t dst; |
| 69 | pj_str_t src; |
| 70 | pjsip_cred_info cred; |
| 71 | }; |
| 72 | |
| 73 | |
| 74 | typedef struct request_param request_param; |
| 75 | |
| 76 | |
| 77 | void app_perror(const char *sender, const char *title, pj_status_t status); |
| 78 | |
| 79 | /* OPTIONS test */ |
| 80 | pj_status_t options_handler_init(void); |
| 81 | pj_status_t options_spawn_test(const pj_str_t *target, |
| 82 | const pj_str_t *from, |
| 83 | const pj_str_t *to, |
| 84 | unsigned cred_cnt, |
| 85 | const pjsip_cred_info cred[], |
| 86 | const pjsip_route_hdr *route_set, |
| 87 | void *test_data, |
| 88 | void (*completion_cb)(void*,pj_bool_t)); |
| 89 | |
| 90 | /* CALL test */ |
| 91 | pj_status_t call_handler_init(void); |
| 92 | pj_status_t call_spawn_test( const pj_str_t *target, |
| 93 | const pj_str_t *from, |
| 94 | const pj_str_t *to, |
| 95 | unsigned cred_cnt, |
| 96 | const pjsip_cred_info cred[], |
| 97 | const pjsip_route_hdr *route_set, |
| 98 | void *test_data, |
| 99 | void (*completion_cb)(void*,pj_bool_t)); |
| 100 | |
| 101 | |
| 102 | |
| 103 | /** |
| 104 | * Global settings |
| 105 | */ |
| 106 | struct pjsip_perf_settings |
| 107 | { |
| 108 | /* Global */ |
| 109 | pj_caching_pool cp; |
| 110 | pj_pool_t *pool; |
| 111 | pjsip_endpoint *endpt; |
| 112 | pj_mutex_t *mutex; |
| 113 | |
| 114 | /* Network: */ |
| 115 | int local_port; |
| 116 | |
| 117 | /* Threads. */ |
| 118 | pj_bool_t quit_flag; |
| 119 | int thread_cnt; |
| 120 | pj_thread_t *thread[16]; |
| 121 | |
| 122 | /* Outgoing request method: */ |
| 123 | pjsip_method method; |
| 124 | |
| 125 | /* Default target: */ |
| 126 | pj_str_t target; |
| 127 | |
| 128 | /* Media: */ |
| 129 | pjmedia_endpt *med_endpt; |
| 130 | pjmedia_conf *mconf; |
| 131 | |
| 132 | /* Handling incoming requests: */ |
| 133 | pj_bool_t stateless; |
| 134 | |
| 135 | /* Rate control. */ |
| 136 | pj_uint32_t start_rate; |
| 137 | pj_uint32_t cur_rate; |
| 138 | |
| 139 | /* Capacity control. */ |
| 140 | pj_uint32_t max_capacity; |
| 141 | |
| 142 | /* Duration control: */ |
| 143 | pj_uint32_t duration; |
| 144 | |
| 145 | /* Test control: */ |
| 146 | session *session; |
| 147 | pj_timer_entry timer; |
| 148 | }; |
| 149 | |
| 150 | |
| 151 | typedef struct pjsip_perf_settings pjsip_perf_settings; |
| 152 | |
| 153 | extern pjsip_perf_settings settings; |
| 154 | |
| 155 | |
| 156 | |
| 157 | PJ_END_DECL |
| 158 | |
| 159 | |
| 160 | #endif /* __PJSIP_PERF_H__ */ |
| 161 | |
| 162 | |
| 163 | |
| 164 | |