int cds2sms(struct incame_sms *sms, struct modem *mdm, char *s, int s_len) { char *data; char *ptr; char tmp; int n; /* pdu starts after 2 "\r\n" */ ptr = s; for ( n=0 ; n<2 && (ptr=strstr(ptr,"\r\n")) ; n++,ptr+=2 ); if (n<2) { LM_ERR("failed to find pdu beginning in CDS!\n"); goto error; } data = ptr; /* pdu end with "\r\n" */ if (!(ptr=strstr(data,"\r\n"))) { LM_ERR("failed to find pdu end in CDS!\n"); goto error; } tmp = ptr[0]; ptr[0] = 0; /* decode the pdu */ n = decode_pdu(mdm,data-3,sms); ptr[0] = tmp; if (n==-1) goto error; return 1; error: return -1; }
int getsms( struct incame_sms *sms, struct modem *mdm, int sim) { char pdu[512]; int found; int ret; found = fetchsms(mdm,sim,pdu); if ( !found ) { LM_ERR("failed to fetch sms %d!\n",sim); return -1; } /* decode the pdu */ ret = decode_pdu(mdm,pdu,sms); /* delete the sms*/ deletesms(mdm,found); return ret; }
static void dissect_nsip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint8 pdu_type; build_info_t bi = { NULL, 0, NULL, NULL, NULL, NULL }; proto_tree *nsip_tree; bi.tvb = tvb; bi.pinfo = pinfo; bi.parent_tree = tree; pinfo->current_proto = "GPRS-NS"; if (!nsip_is_recursive) { col_set_str(pinfo->cinfo, COL_PROTOCOL, "GPRS-NS"); col_clear(pinfo->cinfo, COL_INFO); } pdu_type = tvb_get_guint8(tvb, 0); bi.offset++; if (tree) { bi.ti = proto_tree_add_item(tree, proto_nsip, tvb, 0, -1, ENC_NA); nsip_tree = proto_item_add_subtree(bi.ti, ett_nsip); proto_tree_add_item(nsip_tree, hf_nsip_pdu_type, tvb, 0, 1, ENC_NA); proto_item_append_text(bi.ti, ", PDU type: %s", val_to_str_const(pdu_type, tab_nsip_pdu_types, "Unknown")); bi.nsip_tree = nsip_tree; } if (!nsip_is_recursive) { col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(pdu_type, tab_nsip_pdu_types, "Unknown PDU type")); } else { col_append_sep_fstr(pinfo->cinfo, COL_INFO, NSIP_SEP, "%s", val_to_str_const(pdu_type, tab_nsip_pdu_types, "Unknown PDU type")); } decode_pdu(pdu_type, &bi); }