#include "msg.h"#include "smscconn.h"Include dependency graph for bb_smscconn_cb.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Enumerations | |
| enum | { SMSCCONN_SUCCESS = 0, SMSCCONN_QUEUED, SMSCCONN_FAILED_SHUTDOWN, SMSCCONN_FAILED_REJECTED, SMSCCONN_FAILED_MALFORMED, SMSCCONN_FAILED_TEMPORARILY, SMSCCONN_FAILED_DISCARDED, SMSCCONN_FAILED_QFULL } |
Functions | |
| void | bb_smscconn_ready (SMSCConn *conn) |
| void | bb_smscconn_connected (SMSCConn *conn) |
| void | bb_smscconn_killed (void) |
| void | bb_smscconn_sent (SMSCConn *conn, Msg *sms, Octstr *reply) |
| void | bb_smscconn_send_failed (SMSCConn *conn, Msg *sms, int reason, Octstr *reply) |
| long | bb_smscconn_receive (SMSCConn *conn, Msg *sms) |
|
|
Definition at line 107 of file bb_smscconn_cb.h. 00107 {
00108 SMSCCONN_SUCCESS = 0,
00109 SMSCCONN_QUEUED,
00110 SMSCCONN_FAILED_SHUTDOWN,
00111 SMSCCONN_FAILED_REJECTED,
00112 SMSCCONN_FAILED_MALFORMED,
00113 SMSCCONN_FAILED_TEMPORARILY,
00114 SMSCCONN_FAILED_DISCARDED,
00115 SMSCCONN_FAILED_QFULL
00116 };
|
|
|
Definition at line 168 of file bb_smscconn.c. References gwthread_wakeup(), router_thread, and SMSCConn. Referenced by at2_device_thread(), cgw_open_send_connection(), cgw_sender(), fake_listener(), handle_pdu(), io_thread(), open_send_connection(), reconnect(), and soap_listener(). 00169 {
00170 if (router_thread >= 0)
00171 gwthread_wakeup(router_thread);
00172 }
|
Here is the call graph for this function:

|
|
Definition at line 175 of file bb_smscconn.c. References flow_threads, gwlist_remove_producer(), and incoming_sms. Referenced by at2_device_thread(), cgw_sender(), cimd2_shutdown_cb(), emi2_sender(), fake_listener(), httpsmsc_send_cb(), oisd_shutdown_cb(), shutdown_cb(), soap_listener(), and wrapper_sender(). 00176 {
00177 /* NOTE: after status has been set to SMSCCONN_DEAD, bearerbox
00178 * is free to release/delete 'conn'
00179 */
00180 gwlist_remove_producer(incoming_sms);
00181 gwlist_remove_producer(flow_threads);
00182 }
|
Here is the call graph for this function:

|
|
Definition at line 161 of file bb_smscconn.c. References flow_threads, gwlist_add_producer(), incoming_sms, and SMSCConn. Referenced by smscconn_create(). 00162 {
00163 gwlist_add_producer(flow_threads);
00164 gwlist_add_producer(incoming_sms);
00165 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 350 of file bb_smscconn.c. References ack_failed, bb_alog_sms(), black_list, black_list_regex, check_concatenation(), concat_complete, concat_error, concat_none, concat_pending, counter_increase(), gwthread_sleep(), handle_concatenated_mo, smscconn::id, incoming_sms_counter, info(), msg_destroy(), msg_duplicate(), normalize_number(), numhash_find_number(), octstr_get_cstr, panic, smscconn::received, route_incoming_to_boxc(), route_incoming_to_smsc(), sms, SMSCConn, SMSCCONN_FAILED_QFULL, SMSCCONN_SUCCESS, store_save, store_save_ack, unified_prefix, smscconn::unified_prefix, warning(), white_list, and white_list_regex. Referenced by at2_wait_modem_command(), bb_smscconn_send_failed(), bb_smscconn_sent(), brunet_receive_sms(), cgw_handle_op(), clear_old_concat_parts(), clickatell_receive_sms(), handle_operation(), handle_pdu(), io_thread(), kannel_receive_sms(), main_connection_loop(), msg_to_bb(), soap_parse_dlr(), soap_parse_mo(), wrapper_receiver(), and xidris_receive_sms(). 00351 {
00352 char *uf;
00353 int rc;
00354 Msg *copy;
00355
00356 /*
00357 * First normalize in smsc level and then on global level.
00358 * In outbound direction it's vise versa, hence first global then smsc.
00359 */
00360 uf = (conn && conn->unified_prefix) ? octstr_get_cstr(conn->unified_prefix) : NULL;
00361 normalize_number(uf, &(sms->sms.sender));
00362
00363 uf = unified_prefix ? octstr_get_cstr(unified_prefix) : NULL;
00364 normalize_number(uf, &(sms->sms.sender));
00365
00366 if (white_list &&
00367 numhash_find_number(white_list, sms->sms.sender) < 1) {
00368 info(0, "Number <%s> is not in white-list, message discarded",
00369 octstr_get_cstr(sms->sms.sender));
00370 bb_alog_sms(conn, sms, "REJECTED - not white-listed SMS");
00371 msg_destroy(sms);
00372 return SMSCCONN_FAILED_REJECTED;
00373 }
00374
00375 if (white_list_regex && gw_regex_match_pre(white_list_regex, sms->sms.sender) == 0) {
00376 info(0, "Number <%s> is not in white-list, message discarded",
00377 octstr_get_cstr(sms->sms.sender));
00378 bb_alog_sms(conn, sms, "REJECTED - not white-regex-listed SMS");
00379 msg_destroy(sms);
00380 return SMSCCONN_FAILED_REJECTED;
00381 }
00382
00383 if (black_list &&
00384 numhash_find_number(black_list, sms->sms.sender) == 1) {
00385 info(0, "Number <%s> is in black-list, message discarded",
00386 octstr_get_cstr(sms->sms.sender));
00387 bb_alog_sms(conn, sms, "REJECTED - black-listed SMS");
00388 msg_destroy(sms);
00389 return SMSCCONN_FAILED_REJECTED;
00390 }
00391
00392 if (black_list_regex && gw_regex_match_pre(black_list_regex, sms->sms.sender) == 0) {
00393 info(0, "Number <%s> is not in black-list, message discarded",
00394 octstr_get_cstr(sms->sms.sender));
00395 bb_alog_sms(conn, sms, "REJECTED - black-regex-listed SMS");
00396 msg_destroy(sms);
00397 return SMSCCONN_FAILED_REJECTED;
00398 }
00399
00400 /* fix sms type if not set already */
00401 if (sms->sms.sms_type != report_mo)
00402 sms->sms.sms_type = mo;
00403
00404 /* write to store (if enabled) */
00405 if (store_save(sms) == -1) {
00406 msg_destroy(sms);
00407 return SMSCCONN_FAILED_TEMPORARILY;
00408 }
00409
00410 copy = msg_duplicate(sms);
00411
00412 /*
00413 * Try to reroute internally to an smsc-id without leaving
00414 * actually bearerbox scope.
00415 * Scope: internal routing (to smsc-ids)
00416 */
00417 if ((rc = route_incoming_to_smsc(conn, copy)) == -1) {
00418 int ret;
00419 /* Before routing to some box, do concat handling
00420 * and replace copy as such.
00421 */
00422 if (handle_concatenated_mo && copy->sms.sms_type == mo) {
00423 ret = check_concatenation(©, (conn ? conn->id : NULL));
00424 switch(ret) {
00425 case concat_pending:
00426 counter_increase(incoming_sms_counter); /* ?? */
00427 if (conn != NULL)
00428 counter_increase(conn->received);
00429 msg_destroy(sms);
00430 return SMSCCONN_SUCCESS;
00431 case concat_complete:
00432 /* Combined sms received! save new one since it is now combined. */
00433 msg_destroy(sms);
00434 /* Change the sms. */
00435 sms = msg_duplicate(copy);
00436 break;
00437 case concat_error:
00438 /* failed to save, go away. */
00439 msg_destroy(sms);
00440 return SMSCCONN_FAILED_TEMPORARILY;
00441 case concat_none:
00442 break;
00443 default:
00444 panic(0, "Internal error: Unhandled concat result.");
00445 break;
00446 }
00447 }
00448 /*
00449 * Now try to route the message to a specific smsbox
00450 * connection based on the existing msg->sms.boxc_id or
00451 * the registered receiver numbers for specific smsbox'es.
00452 * Scope: external routing (to smsbox connections)
00453 */
00454 rc = route_incoming_to_boxc(copy);
00455 }
00456
00457 if (rc == -1 || (rc != SMSCCONN_SUCCESS && rc != SMSCCONN_QUEUED)) {
00458 warning(0, "incoming messages queue too long, dropping a message");
00459 if (sms->sms.sms_type == report_mo)
00460 bb_alog_sms(conn, sms, "DROPPED Received DLR");
00461 else
00462 bb_alog_sms(conn, sms, "DROPPED Received SMS");
00463
00464 /* put nack into store-file */
00465 store_save_ack(sms, ack_failed);
00466
00467 msg_destroy(copy);
00468 msg_destroy(sms);
00469 gwthread_sleep(0.1); /* letting the queue go down */
00470 return (rc == -1 ? SMSCCONN_FAILED_QFULL : rc);
00471 }
00472
00473 if (sms->sms.sms_type != report_mo)
00474 bb_alog_sms(conn, sms, "Receive SMS");
00475 else
00476 bb_alog_sms(conn, sms, "Receive DLR");
00477
00478 counter_increase(incoming_sms_counter);
00479 if (conn != NULL) counter_increase(conn->received);
00480
00481 msg_destroy(sms);
00482
00483 return SMSCCONN_SUCCESS;
00484 }
|
Here is the call graph for this function:

|
||||||||||||||||||||
|
Definition at line 281 of file bb_smscconn.c. References ack_failed, bb_alog_sms(), bb_smscconn_receive(), counter_increase(), create_dlr_from_msg(), DLR_IS_FAIL, DLR_IS_SMSC_FAIL, DLR_SMSC_FAIL, smscconn::failed, gwlist_produce(), handle_split(), smscconn::id, msg_destroy(), smscconn::name, octstr_create, octstr_destroy(), octstr_insert_data(), outgoing_sms, reason, sms, sms_resend_retry, SMSCConn, SMSCCONN_FAILED_DISCARDED, SMSCCONN_FAILED_SHUTDOWN, SMSCCONN_FAILED_TEMPORARILY, smscconn_status(), store_save_ack, and warning(). Referenced by at2_send_one_message(), at2_shutdown_cb(), brunet_parse_reply(), cgw_handle_op(), cgw_open_send_connection(), cgw_sender(), cgw_shutdown_cb(), cimd2_shutdown_cb(), cimd2_submit_msg(), clickatell_parse_reply(), do_queue_cleanup(), emi2_handle_smscreq(), emi2_sender(), fake_listener(), generic_parse_reply(), handle_pdu(), handle_split(), io_thread(), kannel_parse_reply(), main_connection_loop(), oisd_shutdown_cb(), oisd_submit_msg(), open_send_connection(), reconnect(), send_messages(), shutdown_cb(), sms_send(), smsc2_rout(), soap_listener(), soap_read_response(), soap_send_loop(), soap_shutdown_cb(), wapme_smsproxy_parse_reply(), wrapper_sender(), wrapper_shutdown(), and xidris_parse_reply(). 00282 {
00283 if (sms->sms.split_parts != NULL) {
00284 handle_split(conn, sms, reason);
00285 octstr_destroy(reply);
00286 return;
00287 }
00288
00289 switch (reason) {
00290 case SMSCCONN_FAILED_TEMPORARILY:
00291 /*
00292 * Check if SMSC link alive and if so increase resend_try and set resend_time.
00293 * If SMSC link is not active don't increase resend_try and don't set resend_time
00294 * because we don't want to delay messages because of connection broken.
00295 */
00296 if (conn && smscconn_status(conn) == SMSCCONN_ACTIVE) {
00297 /*
00298 * Check if sms_resend_retry set and this msg has exceeded a limit also
00299 * honor "single shot" with sms_resend_retry set to zero.
00300 */
00301 if (sms_resend_retry >= 0 && sms->sms.resend_try >= sms_resend_retry) {
00302 warning(0, "Maximum retries for message exceeded, discarding it!");
00303 bb_smscconn_send_failed(NULL, sms, SMSCCONN_FAILED_DISCARDED,
00304 octstr_create("Retries Exceeded"));
00305 break;
00306 }
00307 sms->sms.resend_try = (sms->sms.resend_try > 0 ? sms->sms.resend_try + 1 : 1);
00308 time(&sms->sms.resend_time);
00309 }
00310 gwlist_produce(outgoing_sms, sms);
00311 break;
00312
00313 case SMSCCONN_FAILED_SHUTDOWN:
00314 gwlist_produce(outgoing_sms, sms);
00315 break;
00316
00317 default:
00318 /* write NACK to store file */
00319 store_save_ack(sms, ack_failed);
00320
00321 if (conn) counter_increase(conn->failed);
00322 if (reason == SMSCCONN_FAILED_DISCARDED)
00323 bb_alog_sms(conn, sms, "DISCARDED SMS");
00324 else
00325 bb_alog_sms(conn, sms, "FAILED Send SMS");
00326
00327 /* generate relay confirmancy message */
00328 if (DLR_IS_SMSC_FAIL(sms->sms.dlr_mask) ||
00329 DLR_IS_FAIL(sms->sms.dlr_mask)) {
00330 Msg *dlrmsg;
00331
00332 if (reply == NULL)
00333 reply = octstr_create("");
00334
00335 octstr_insert_data(reply, 0, "NACK/", 5);
00336 dlrmsg = create_dlr_from_msg((conn ? (conn->id?conn->id:conn->name) : NULL), sms,
00337 reply, DLR_SMSC_FAIL);
00338 if (dlrmsg != NULL) {
00339 bb_smscconn_receive(conn, dlrmsg);
00340 }
00341 }
00342
00343 msg_destroy(sms);
00344 break;
00345 }
00346
00347 octstr_destroy(reply);
00348 }
|
Here is the call graph for this function:

|
||||||||||||||||
Here is the call graph for this function:
