/* * Identify ourself to bearerbox for smsbox-specific routing inside bearerbox. * Do this even while no smsbox-id is given to unlock the sender thread in * bearerbox. */ static void identify_to_bearerbox(void) { Msg *msg; msg = msg_create(admin); msg->admin.command = cmd_identify; msg->admin.boxc_id = octstr_duplicate(smsbox_id); write_to_bearerbox(msg); }
/* * Send IP datagram as it is, segment SMS datagram if necessary. */ static void dispatch_datagram(WAPEvent *dgram) { Msg *msg, *part; List *sms_datagrams; static unsigned long msg_sequence = 0L; /* Used only by this function */ msg = part = NULL; sms_datagrams = NULL; if (dgram == NULL) { error(0, "WDP: dispatch_datagram received empty datagram, ignoring."); } else if (dgram->type != T_DUnitdata_Req) { warning(0, "WDP: dispatch_datagram received event of unexpected type."); wap_event_dump(dgram); } else if (dgram->u.T_DUnitdata_Req.address_type == ADDR_IPV4) { #ifdef HAVE_WTLS_OPENSSL if (dgram->u.T_DUnitdata_Req.addr_tuple->local->port >= WTLS_CONNECTIONLESS_PORT) wtls_dispatch_resp(dgram); else #endif /* HAVE_WTLS_OPENSSL */ { msg = pack_ip_datagram(dgram); write_to_bearerbox(msg); } } else { msg_sequence = counter_increase(sequence_counter) & 0xff; msg = pack_sms_datagram(dgram); sms_datagrams = sms_split(msg, NULL, NULL, NULL, NULL, concatenation, msg_sequence, max_messages, MAX_SMS_OCTETS); debug("wap",0,"WDP (wapbox): delivering %ld segments to bearerbox", gwlist_len(sms_datagrams)); while ((part = gwlist_extract_first(sms_datagrams)) != NULL) { write_to_bearerbox(part); } gwlist_destroy(sms_datagrams, NULL); msg_destroy(msg); } wap_event_destroy(dgram); }
static void run_connects(void) { unsigned int i; Msg *msg; for (i = 1; i <= no_conn; i++) { /* connect to Kannel's bearerbox */ connect_to_bearerbox(host, port, 0, NULL); /* identify ourself to bearerbox */ msg = msg_create(admin); msg->admin.command = cmd_identify; msg->admin.boxc_id = octstr_create("test-smsbox"); write_to_bearerbox(msg); /* do something, like passing MT messages */ /* close connection and shutdown */ close_connection_to_bearerbox(); } }