+ TID_RESP *tresp = NULL;
+ json_error_t rc;
+ json_t *jresult = NULL;
+ json_t *jrp_realm = NULL;
+ json_t *jrealm = NULL;
+ json_t *jcomm = NULL;
+ json_t *jorig_coi = NULL;
+ json_t *jservers = NULL;
+ int msize;
+
+ if (!(tresp = malloc(sizeof(TID_RESP)))) {
+ fprintf (stderr, "tr_msg_decode_tidresp(): Error allocating TID_RESP structure.\n");
+ return NULL;
+ }
+
+ memset(tresp, 0, sizeof(TID_RESP));
+
+ /* store required fields from request */
+ if (((msize = json_object_size(jresp)) < 5) ||
+ (NULL == (jresult = json_object_get(jresp, "result"))) ||
+ (!json_is_string(jresult)) ||
+ (NULL == (jrp_realm = json_object_get(jresp, "rp_realm"))) ||
+ (!json_is_string(jrp_realm)) ||
+ (NULL == (jrealm = json_object_get(jresp, "realm"))) ||
+ (!json_is_string(jrealm)) ||
+ (NULL == (jcomm = json_object_get(jresp, "comm"))) ||
+ (!json_is_string(jcomm)) ||
+ (NULL == (jservers = json_object_get(jresp, "servers"))) ||
+ (!json_is_object(jservers))) {
+ fprintf (stderr, "tr_msg_decode(): Error parsing message.\n");
+ free(tresp);
+ return NULL;
+ }
+
+ tresp->result->buf = json_string_value(jresult);
+ tresp->result->len = strlen(tresp->result->buf);
+ tresp->rp_realm->buf = json_string_value(jrp_realm);
+ tresp->rp_realm->len = strlen(tresp->rp_realm->buf);
+ tresp->realm->buf = json_string_value(jrealm);
+ tresp->realm->len = strlen(tresp->realm->buf);
+ tresp->comm->buf = json_string_value(jcomm);
+ tresp->comm->len = strlen(tresp->comm->buf);
+
+ /* store optional "orig_coi" field */
+ if ((NULL != (jorig_coi = json_object_get(jresp, "orig_coi"))) &&
+ (!json_is_object(jorig_coi))) {
+ tresp->orig_coi->buf = json_string_value(jorig_coi);
+ tresp->orig_coi->len = strlen(tresp->orig_coi->buf);
+ }