List,
Good Day,
This is my first contribution to the list.
Functionality added to the sendota interface to allow mclass and priority to be set.
Also added some more logging (These have been copied over from the sendsms interface) just to keep them in sync.
Cheers,
Edward
--- smsbox.c 2006-12-05 17:34:49.000000000 -0400
+++ smsbox.c.ota 2006-12-06 15:10:04.000000000 -0400
@@ -2817,13 +2817,18 @@
CfgGroup *grp;
Octstr *returnerror;
Octstr *stored_uuid = NULL;
+ Octstr *tmp_ota_string;
List *grplist;
Octstr *p;
URLTranslation *t;
Msg *msg;
int ret, ota_type;
+
+ int mclass, priority;
id = phonenumber = smsc = account = NULL;
+
+ mclass = priority = SMS_PARAM_UNDEFINED;
/* check the username and password */
t = authorise_user(list, client_ip);
@@ -2959,9 +2964,37 @@
} else
msg->sms.smsc_id = NULL;
+ /* Account Args Check */
account = http_cgi_variable(list, "account");
- if (octstr_len(account) > 0)
- msg->sms.account = octstr_duplicate(account);
+ if (octstr_len(account) > 0) {
+ returnerror = octstr_create("Account field misformed, rejected");
+ goto field_error_ota;
+ }
+ msg->sms.account = octstr_duplicate(account);
+
+ /* Mclass Args derive from HTTP */
+ tmp_ota_string = http_cgi_variable(list, "mclass");
+ if (tmp_ota_string != NULL )
+ sscanf(octstr_get_cstr(tmp_ota_string), "%d" ,&mclass);
+
+ /* Priority Args derive from HTTP */
+ tmp_ota_string = http_cgi_variable(list, "priority");
+ if (tmp_ota_string != NULL )
+ sscanf(octstr_get_cstr(tmp_ota_string), "%d" ,&priority);
+
+ /* Mclass Args check */
+ if ( mclass < -1 || mclass > 3 ) {
+ returnerror = octstr_create("MClass field misformed, rejected");
+ goto field_error_ota;
+ }
+ msg->sms.mclass = mclass;
+
+ /* Priority Args Check */
+ if (priority != SMS_PARAM_UNDEFINED && (priority < 0 || priority > 3)) {
+ returnerror = octstr_create("Priority field misformed, rejected");
+ goto field_error_ota;
+ }
+ msg->sms.priority = priority;
octstr_dump(msg->sms.msgdata, 0);
@@ -2973,6 +3006,7 @@
dict_put(client_dict, stored_uuid, client);
}
+ /* Send OTA Message and return number of splits */
ret = send_message(t, msg);
if (ret == -1) {
@@ -2985,10 +3019,19 @@
returnerror = octstr_create("Sent.");
}
+cleanup:
msg_destroy(msg);
octstr_destroy(stored_uuid);
return returnerror;
+
+field_error_ota:
+ alog("send-OTA request failed - %s",
+ octstr_get_cstr(returnerror));
+ *status = HTTP_BAD_REQUEST;
+
+ goto cleanup;
+
}
@@ -3006,7 +3049,7 @@
{
Octstr *name, *val, *ret;
Octstr *from, *to, *id, *user, *pass, *smsc;
- Octstr *type, *charset, *doc_type, *ota_doc, *sec, *pin;
+ Octstr *type, *charset, *doc_type, *ota_doc, *sec, *pin, *priority,
*mclass;
Octstr *stored_uuid = NULL;
URLTranslation *t;
Msg *msg;
@@ -3057,6 +3100,15 @@
pin = octstr_duplicate(val);
octstr_strip_blanks(pin);
}
+ else if (octstr_case_compare(name, octstr_imm("X-Kannel-Priority")) ==
0) {
+ pin = octstr_duplicate(val);
+ octstr_strip_blanks(priority);
+ }
+
+ else if (octstr_case_compare(name, octstr_imm("X-Kannel-Mclass")) ==
0) {
+ pin = octstr_duplicate(val);
+ octstr_strip_blanks(mclass);
+ }
}
/* apply defaults */
@@ -3249,7 +3301,7 @@
status = HTTP_NOT_FOUND;
}
- debug("sms.http", 0, "Status: %d Answer: <%s>", status,
+ debug("sms.http", 0, "Status: %d Answer: <%s>", status,
octstr_get_cstr(answer));
octstr_destroy(ip);
