X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=ie.cpp;h=c44c166d2ea77a545ca535f61ee5dc2a8f52bdc0;hp=0a5f6367662eca0d3fa134ae90f2dd02dd267212;hb=b1ab2b9ac1cfc15d2a8f5850145dd69043cc3ef7;hpb=2ed0fee489c37a6e2d4473f6185ebbe3e746ac11 diff --git a/ie.cpp b/ie.cpp index 0a5f636..c44c166 100644 --- a/ie.cpp +++ b/ie.cpp @@ -26,10 +26,8 @@ static void strnncpy(unsigned char *dest, unsigned char *src, int len, int dst_l /* IE_COMPLETE */ -void Pdss1::enc_ie_complete(unsigned char **ntmode, msg_t *msg, int complete) +void Pdss1::enc_ie_complete(struct l3_msg *l3m, int complete) { - unsigned char *p; - Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN); if (complete<0 || complete>1) { @@ -38,41 +36,29 @@ void Pdss1::enc_ie_complete(unsigned char **ntmode, msg_t *msg, int complete) } if (complete) - printisdn(" complete=%d\n", complete); - - if (complete) { - p = msg_put(msg, 1); - if (p_m_d_ntmode) - { - *ntmode = p; - } else - qi->sending_complete.off = p - (unsigned char *)qi - sizeof(Q931_info_t); - p[0] = IE_COMPLETE; + add_trace("complete", NULL, NULL); + l3m->sending_complete++; } } -void Pdss1::dec_ie_complete(unsigned char *p, Q931_info_t *qi, int *complete) +void Pdss1::dec_ie_complete(struct l3_msg *l3m, int *complete) { *complete = 0; - if (!p_m_d_ntmode) - { - if (qi->sending_complete.off) - *complete = 1; - } else + // special case: p is not a pointer, it's a value + unsigned char p = l3m->sending_complete; if (p) *complete = 1; if (*complete) - printisdn(" complete=%d\n", *complete); + add_trace("complete", NULL, NULL); } /* IE_BEARER */ -void Pdss1::enc_ie_bearer(unsigned char **ntmode, msg_t *msg, int coding, int capability, int mode, int rate, int multi, int user) +void Pdss1::enc_ie_bearer(struct l3_msg *l3m, int coding, int capability, int mode, int rate, int multi, int user) { - unsigned char *p; - Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN); + unsigned char p[256]; int l; if (coding<0 || coding>3) @@ -111,14 +97,14 @@ void Pdss1::enc_ie_bearer(unsigned char **ntmode, msg_t *msg, int coding, int ca multi = -1; } - printisdn(" coding=%d capability=%d mode=%d rate=%d multi=%d user=%d\n", coding, capability, mode, rate, multi, user); + add_trace("bearer", "coding", "%d", coding); + add_trace("bearer", "capability", "%d", capability); + add_trace("bearer", "mode", "%d", mode); + add_trace("bearer", "rate", "%d", rate); + add_trace("bearer", "multi", "%d", multi); + add_trace("bearer", "user", "%d", user); l = 2 + (multi>=0) + (user>=0); - p = msg_put(msg, l+2); - if (p_m_d_ntmode) - *ntmode = p+1; - else - qi->bearer_capability.off = p - (unsigned char *)qi - sizeof(Q931_info_t); p[0] = IE_BEARER; p[1] = l; p[2] = 0x80 + (coding<<5) + capability; @@ -127,9 +113,10 @@ void Pdss1::enc_ie_bearer(unsigned char **ntmode, msg_t *msg, int coding, int ca p[4] = 0x80 + multi; if (user >= 0) p[4+(multi>=0)] = 0xa0 + user; + add_layer3_ie(l3m, p[0], p[1], p+2); } -void Pdss1::dec_ie_bearer(unsigned char *p, Q931_info_t *qi, int *coding, int *capability, int *mode, int *rate, int *multi, int *user) +void Pdss1::dec_ie_bearer(struct l3_msg *l3m, int *coding, int *capability, int *mode, int *rate, int *multi, int *user) { *coding = -1; *capability = -1; @@ -138,17 +125,12 @@ void Pdss1::dec_ie_bearer(unsigned char *p, Q931_info_t *qi, int *coding, int *c *multi = -1; *user = -1; - if (!p_m_d_ntmode) - { - p = NULL; - if (qi->bearer_capability.off) - p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->bearer_capability.off + 1; - } + unsigned char *p = l3m->bearer_capability; if (!p) return; if (p[0] < 2) { - PERROR("IE too short (%d).\n", p[0]); + add_trace("bearer", "error", "IE too short (len=%d)", p[0]); return; } @@ -170,15 +152,19 @@ void Pdss1::dec_ie_bearer(unsigned char *p, Q931_info_t *qi, int *coding, int *c *user = p[3] & 0x1f; } - printisdn(" coding=%d capability=%d mode=%d rate=%d multi=%d user=%d\n", *coding, *capability, *mode, *rate, *multi, *user); + add_trace("bearer", "coding", "%d", *coding); + add_trace("bearer", "capability", "%d", *capability); + add_trace("bearer", "mode", "%d", *mode); + add_trace("bearer", "rate", "%d", *rate); + add_trace("bearer", "multi", "%d", *multi); + add_trace("bearer", "user", "%d", *user); } /* IE_HLC */ -void Pdss1::enc_ie_hlc(unsigned char **ntmode, msg_t *msg, int coding, int interpretation, int presentation, int hlc, int exthlc) +void Pdss1::enc_ie_hlc(struct l3_msg *l3m, int coding, int interpretation, int presentation, int hlc, int exthlc) { - unsigned char *p; - Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN); + unsigned char p[256]; int l; if (coding<0 || coding>3) @@ -207,14 +193,14 @@ void Pdss1::enc_ie_hlc(unsigned char **ntmode, msg_t *msg, int coding, int inter return; } - printisdn(" coding=%d interpretation=%d presentation=%d hlc=%d exthlc=%d\n", coding, interpretation, presentation, hlc, exthlc); + add_trace("hlc", "coding", "%d", coding); + add_trace("hlc", "interpretation", "%d", interpretation); + add_trace("hlc", "presentation", "%d", presentation); + add_trace("hlc", "hlc", "%d", hlc); + if (exthlc >= 0) + add_trace("hlc", "exthlc", "%d", exthlc); l = 2 + (exthlc>=0); - p = msg_put(msg, l+2); - if (p_m_d_ntmode) - *ntmode = p+1; - else - qi->hlc.off = p - (unsigned char *)qi - sizeof(Q931_info_t); p[0] = IE_HLC; p[1] = l; p[2] = 0x80 + (coding<<5) + (interpretation<<2) + presentation; @@ -224,9 +210,10 @@ void Pdss1::enc_ie_hlc(unsigned char **ntmode, msg_t *msg, int coding, int inter p[4] = 0x80 + exthlc; } else p[3] = 0x80 + hlc; + add_layer3_ie(l3m, p[0], p[1], p+2); } -void Pdss1::dec_ie_hlc(unsigned char *p, Q931_info_t *qi, int *coding, int *interpretation, int *presentation, int *hlc, int *exthlc) +void Pdss1::dec_ie_hlc(struct l3_msg *l3m, int *coding, int *interpretation, int *presentation, int *hlc, int *exthlc) { *coding = -1; *interpretation = -1; @@ -234,17 +221,12 @@ void Pdss1::dec_ie_hlc(unsigned char *p, Q931_info_t *qi, int *coding, int *inte *hlc = -1; *exthlc = -1; - if (!p_m_d_ntmode) - { - p = NULL; - if (qi->hlc.off) - p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->hlc.off + 1; - } + unsigned char *p = l3m->hlc; if (!p) return; if (p[0] < 2) { - PERROR("IE too short (%d).\n", p[0]); + add_trace("hlc", "error", "IE too short (len=%d)", p[0]); return; } @@ -257,25 +239,29 @@ void Pdss1::dec_ie_hlc(unsigned char *p, Q931_info_t *qi, int *coding, int *inte *exthlc = p[3] & 0x7f; } - printisdn(" coding=%d interpretation=%d presentation=%d hlc=%d exthlc=%d\n", *coding, *interpretation, *presentation, *hlc, *exthlc); + add_trace("hlc", "coding", "%d", *coding); + add_trace("hlc", "interpretation", "%d", *interpretation); + add_trace("hlc", "presentation", "%d", *presentation); + add_trace("hlc", "hlc", "%d", *hlc); + if (*exthlc >= 0) + add_trace("hlc", "exthlc", "%d", *exthlc); } /* IE_CALL_ID */ -void Pdss1::enc_ie_call_id(unsigned char **ntmode, msg_t *msg, unsigned char *callid, int callid_len) +void Pdss1::enc_ie_call_id(struct l3_msg *l3m, unsigned char *callid, int callid_len) { - unsigned char *p; - Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN); + unsigned char p[256]; int l; - char debug[25]; + char buffer[25]; int i; if (!callid || callid_len<=0) { return; } - if (callid_len>8) + if (callid_len > 8) { PERROR("callid_len(%d) is out of range.\n", callid_len); return; @@ -284,41 +270,32 @@ void Pdss1::enc_ie_call_id(unsigned char **ntmode, msg_t *msg, unsigned char *ca i = 0; while(i < callid_len) { - UPRINT(debug+(i*3), " %02x", callid[i]); + UPRINT(buffer+(i*3), " %02x", callid[i]); i++; } - printisdn(" callid%s\n", debug); + add_trace("callid", NULL, "%s", buffer[0]?buffer+1:""); l = callid_len; - p = msg_put(msg, l+2); - if (p_m_d_ntmode) - *ntmode = p+1; - else - qi->call_id.off = p - (unsigned char *)qi - sizeof(Q931_info_t); p[0] = IE_CALL_ID; p[1] = l; memcpy(p+2, callid, callid_len); + add_layer3_ie(l3m, p[0], p[1], p+2); } -void Pdss1::dec_ie_call_id(unsigned char *p, Q931_info_t *qi, unsigned char *callid, int *callid_len) +void Pdss1::dec_ie_call_id(struct l3_msg *l3m, unsigned char *callid, int *callid_len) { - char debug[25]; + char buffer[25]; int i; *callid_len = -1; - if (!p_m_d_ntmode) - { - p = NULL; - if (qi->call_id.off) - p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->call_id.off + 1; - } + unsigned char *p = l3m->call_id; if (!p) return; if (p[0] > 8) { - PERROR("IE too long (%d).\n", p[0]); + add_trace("callid", "error", "IE too long (len=%d)", p[0]); return; } @@ -328,19 +305,18 @@ void Pdss1::dec_ie_call_id(unsigned char *p, Q931_info_t *qi, unsigned char *cal i = 0; while(i < *callid_len) { - UPRINT(debug+(i*3), " %02x", callid[i]); + UPRINT(buffer+(i*3), " %02x", callid[i]); i++; } - printisdn(" callid%s\n", debug); + add_trace("callid", NULL, "%s", buffer[0]?buffer+1:""); } /* IE_CALLED_PN */ -void Pdss1::enc_ie_called_pn(unsigned char **ntmode, msg_t *msg, int type, int plan, unsigned char *number) +void Pdss1::enc_ie_called_pn(struct l3_msg *l3m, int type, int plan, unsigned char *number) { - unsigned char *p; - Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN); + unsigned char p[256]; int l; if (type<0 || type>7) @@ -359,37 +335,30 @@ void Pdss1::enc_ie_called_pn(unsigned char **ntmode, msg_t *msg, int type, int p return; } - printisdn(" type=%d plan=%d number='%s'\n", type, plan, number); + add_trace("called_pn", "type", "%d", type); + add_trace("called_pn", "plan", "%d", plan); + add_trace("called_pn", "number", "%s", number); l = 1+strlen((char *)number); - p = msg_put(msg, l+2); - if (p_m_d_ntmode) - *ntmode = p+1; - else - qi->called_nr.off = p - (unsigned char *)qi - sizeof(Q931_info_t); p[0] = IE_CALLED_PN; p[1] = l; p[2] = 0x80 + (type<<4) + plan; UNCPY((char *)p+3, (char *)number, strlen((char *)number)); + add_layer3_ie(l3m, p[0], p[1], p+2); } -void Pdss1::dec_ie_called_pn(unsigned char *p, Q931_info_t *qi, int *type, int *plan, unsigned char *number, int number_len) +void Pdss1::dec_ie_called_pn(struct l3_msg *l3m, int *type, int *plan, unsigned char *number, int number_len) { *type = -1; *plan = -1; *number = '\0'; - if (!p_m_d_ntmode) - { - p = NULL; - if (qi->called_nr.off) - p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->called_nr.off + 1; - } + unsigned char *p = l3m->called_nr; if (!p) return; if (p[0] < 2) { - PERROR("IE too short (%d).\n", p[0]); + add_trace("called_pn", "error", "IE too short (len=%d)", p[0]); return; } @@ -397,15 +366,16 @@ void Pdss1::dec_ie_called_pn(unsigned char *p, Q931_info_t *qi, int *type, int * *plan = p[1] & 0xf; strnncpy(number, p+2, p[0]-1, number_len); - printisdn(" type=%d plan=%d number='%s'\n", *type, *plan, number); + add_trace("called_pn", "type", "%d", *type); + add_trace("called_pn", "plan", "%d", *plan); + add_trace("called_pn", "number", "%s", number); } /* IE_CALLING_PN */ -void Pdss1::enc_ie_calling_pn(unsigned char **ntmode, msg_t *msg, int type, int plan, int present, int screen, unsigned char *number) +void Pdss1::enc_ie_calling_pn(struct l3_msg *l3m, int type, int plan, int present, int screen, unsigned char *number) { - unsigned char *p; - Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN); + unsigned char p[256]; int l; if (type<0 || type>7) @@ -429,18 +399,17 @@ void Pdss1::enc_ie_calling_pn(unsigned char **ntmode, msg_t *msg, int type, int return; } - printisdn(" type=%d plan=%d present=%d screen=%d number='%s'\n", type, plan, present, screen, number); + add_trace("calling_pn", "type", "%d", type); + add_trace("calling_pn", "plan", "%d", plan); + add_trace("calling_pn", "present", "%d", present); + add_trace("calling_pn", "screen", "%d", screen); + add_trace("calling_pn", "number", "%s", number); l = 1; if (number) if (number[0]) l += strlen((char *)number); if (present >= 0) l += 1; - p = msg_put(msg, l+2); - if (p_m_d_ntmode) - *ntmode = p+1; - else - qi->calling_nr.off = p - (unsigned char *)qi - sizeof(Q931_info_t); p[0] = IE_CALLING_PN; p[1] = l; if (present >= 0) @@ -455,9 +424,10 @@ void Pdss1::enc_ie_calling_pn(unsigned char **ntmode, msg_t *msg, int type, int if (number) if (number[0]) UNCPY((char *)p+3, (char *)number, strlen((char *)number)); } + add_layer3_ie(l3m, p[0], p[1], p+2); } -void Pdss1::dec_ie_calling_pn(unsigned char *p, Q931_info_t *qi, int *type, int *plan, int *present, int *screen, unsigned char *number, int number_len) +void Pdss1::dec_ie_calling_pn(struct l3_msg *l3m, int *type, int *plan, int *present, int *screen, unsigned char *number, int number_len) { *type = -1; *plan = -1; @@ -465,17 +435,12 @@ void Pdss1::dec_ie_calling_pn(unsigned char *p, Q931_info_t *qi, int *type, int *screen = -1; *number = '\0'; - if (!p_m_d_ntmode) - { - p = NULL; - if (qi->calling_nr.off) - p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->calling_nr.off + 1; - } + unsigned char *p = l3m->calling_nr; if (!p) return; if (p[0] < 1) { - PERROR("IE too short (%d).\n", p[0]); + add_trace("calling_pn", "error", "IE too short (len=%d)", p[0]); return; } @@ -485,7 +450,7 @@ void Pdss1::dec_ie_calling_pn(unsigned char *p, Q931_info_t *qi, int *type, int { if (p[0] < 2) { - PERROR("IE too short (%d).\n", p[0]); + add_trace("calling_pn", "error", "IE too short (len=%d)", p[0]); return; } *present = (p[2]&0x60) >> 5; @@ -496,15 +461,18 @@ void Pdss1::dec_ie_calling_pn(unsigned char *p, Q931_info_t *qi, int *type, int strnncpy(number, p+2, p[0]-1, number_len); } - printisdn(" type=%d plan=%d present=%d screen=%d number='%s'\n", *type, *plan, *present, *screen, number); + add_trace("calling_pn", "type", "%d", *type); + add_trace("calling_pn", "plan", "%d", *plan); + add_trace("calling_pn", "present", "%d", *present); + add_trace("calling_pn", "screen", "%d", *screen); + add_trace("calling_pn", "number", "%s", number); } /* IE_CONNECTED_PN */ -void Pdss1::enc_ie_connected_pn(unsigned char **ntmode, msg_t *msg, int type, int plan, int present, int screen, unsigned char *number) +void Pdss1::enc_ie_connected_pn(struct l3_msg *l3m, int type, int plan, int present, int screen, unsigned char *number) { - unsigned char *p; - Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN); + unsigned char p[256]; int l; if (type<0 || type>7) @@ -528,18 +496,17 @@ void Pdss1::enc_ie_connected_pn(unsigned char **ntmode, msg_t *msg, int type, in return; } - printisdn(" type=%d plan=%d present=%d screen=%d number='%s'\n", type, plan, present, screen, number); + add_trace("connect_pn", "type", "%d", type); + add_trace("connect_pn", "plan", "%d", plan); + add_trace("connect_pn", "present", "%d", present); + add_trace("connect_pn", "screen", "%d", screen); + add_trace("connect_pn", "number", "%s", number); l = 1; if (number) if (number[0]) l += strlen((char *)number); if (present >= 0) l += 1; - p = msg_put(msg, l+2); - if (p_m_d_ntmode) - *ntmode = p+1; - else - qi->connected_nr.off = p - (unsigned char *)qi - sizeof(Q931_info_t); p[0] = IE_CONNECT_PN; p[1] = l; if (present >= 0) @@ -554,9 +521,10 @@ void Pdss1::enc_ie_connected_pn(unsigned char **ntmode, msg_t *msg, int type, in if (number) if (number[0]) UNCPY((char *)p+3, (char *)number, strlen((char *)number)); } + add_layer3_ie(l3m, p[0], p[1], p+2); } -void Pdss1::dec_ie_connected_pn(unsigned char *p, Q931_info_t *qi, int *type, int *plan, int *present, int *screen, unsigned char *number, int number_len) +void Pdss1::dec_ie_connected_pn(struct l3_msg *l3m, int *type, int *plan, int *present, int *screen, unsigned char *number, int number_len) { *type = -1; *plan = -1; @@ -564,17 +532,12 @@ void Pdss1::dec_ie_connected_pn(unsigned char *p, Q931_info_t *qi, int *type, in *screen = -1; *number = '\0'; - if (!p_m_d_ntmode) - { - p = NULL; - if (qi->connected_nr.off) - p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->connected_nr.off + 1; - } + unsigned char *p = l3m->connected_nr; if (!p) return; if (p[0] < 1) { - PERROR("IE too short (%d).\n", p[0]); + add_trace("connect_pn", "error", "IE too short (len=%d)", p[0]); return; } @@ -584,7 +547,7 @@ void Pdss1::dec_ie_connected_pn(unsigned char *p, Q931_info_t *qi, int *type, in { if (p[0] < 2) { - PERROR("IE too short (%d).\n", p[0]); + add_trace("connect_pn", "error", "IE too short (len=%d)", p[0]); return; } *present = (p[2]&0x60) >> 5; @@ -595,15 +558,18 @@ void Pdss1::dec_ie_connected_pn(unsigned char *p, Q931_info_t *qi, int *type, in strnncpy(number, p+2, p[0]-1, number_len); } - printisdn(" type=%d plan=%d present=%d screen=%d number='%s'\n", *type, *plan, *present, *screen, number); + add_trace("connect_pn", "type", "%d", *type); + add_trace("connect_pn", "plan", "%d", *plan); + add_trace("connect_pn", "present", "%d", *present); + add_trace("connect_pn", "screen", "%d", *screen); + add_trace("connect_pn", "number", "%s", number); } /* IE_CAUSE */ -void Pdss1::enc_ie_cause(unsigned char **ntmode, msg_t *msg, int location, int cause) +void Pdss1::enc_ie_cause(struct l3_msg *l3m, int location, int cause) { - unsigned char *p; - Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN); + unsigned char p[256]; int l; if (location<0 || location>7) @@ -617,65 +583,53 @@ void Pdss1::enc_ie_cause(unsigned char **ntmode, msg_t *msg, int location, int c return; } - printisdn(" location=%d cause=%d\n", location, cause); + add_trace("cause", "location", "%d", location); + add_trace("cause", "value", "%d", cause); l = 2; - p = msg_put(msg, l+2); - if (p_m_d_ntmode) - *ntmode = p+1; - else - qi->cause.off = p - (unsigned char *)qi - sizeof(Q931_info_t); p[0] = IE_CAUSE; p[1] = l; p[2] = 0x80 + location; p[3] = 0x80 + cause; + add_layer3_ie(l3m, p[0], p[1], p+2); } -void enc_ie_cause_standalone(unsigned char **ntmode, msg_t *msg, int location, int cause) +void enc_ie_cause_standalone(struct l3_msg *l3m, int location, int cause) { - unsigned char *p = msg_put(msg, 4); - Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN); - if (ntmode) - *ntmode = p+1; - else - qi->cause.off = p - (unsigned char *)qi - sizeof(Q931_info_t); + unsigned char p[256]; p[0] = IE_CAUSE; p[1] = 2; p[2] = 0x80 + location; p[3] = 0x80 + cause; + add_layer3_ie(l3m, p[0], p[1], p+2); } -void Pdss1::dec_ie_cause(unsigned char *p, Q931_info_t *qi, int *location, int *cause) +void Pdss1::dec_ie_cause(struct l3_msg *l3m, int *location, int *cause) { *location = -1; *cause = -1; - if (!p_m_d_ntmode) - { - p = NULL; - if (qi->cause.off) - p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->cause.off + 1; - } + unsigned char *p = l3m->cause; if (!p) return; if (p[0] < 2) { - PERROR("IE too short (%d).\n", p[0]); + add_trace("cause", "error", "IE too short (len=%d)", p[0]); return; } *location = p[1] & 0x0f; *cause = p[2] & 0x7f; - printisdn(" location=%d cause=%d\n", *location, *cause); + add_trace("cause", "location", "%d", *location); + add_trace("cause", "value", "%d", *cause); } /* IE_CHANNEL_ID */ -void Pdss1::enc_ie_channel_id(unsigned char **ntmode, msg_t *msg, int exclusive, int channel) +void Pdss1::enc_ie_channel_id(struct l3_msg *l3m, int exclusive, int channel) { - unsigned char *p; - Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN); + unsigned char p[256]; int l; int pri = p_m_mISDNport->pri; @@ -693,17 +647,23 @@ void Pdss1::enc_ie_channel_id(unsigned char **ntmode, msg_t *msg, int exclusive, return; } - printisdn(" exclusive=%d channel=%d\n", exclusive, channel); + add_trace("channel_id", "exclusive", "%d", exclusive); + switch(channel) + { + case CHANNEL_ANY: + add_trace("channel_id", "channel", "any channel"); + break; + case CHANNEL_NO: + add_trace("channel_id", "channel", "no channel"); + break; + default: + add_trace("channel_id", "channel", "%d", channel); + } if (!pri) { /* BRI */ l = 1; - p = msg_put(msg, l+2); - if (p_m_d_ntmode) - *ntmode = p+1; - else - qi->channel_id.off = p - (unsigned char *)qi - sizeof(Q931_info_t); p[0] = IE_CHANNEL_ID; p[1] = l; if (channel == CHANNEL_NO) @@ -711,6 +671,7 @@ void Pdss1::enc_ie_channel_id(unsigned char **ntmode, msg_t *msg, int exclusive, else if (channel == CHANNEL_ANY) channel = 3; p[2] = 0x80 + (exclusive<<3) + channel; + add_layer3_ie(l3m, p[0], p[1], p+2); } else { /* PRI */ @@ -719,59 +680,46 @@ void Pdss1::enc_ie_channel_id(unsigned char **ntmode, msg_t *msg, int exclusive, if (channel == CHANNEL_ANY) /* any channel */ { l = 1; - p = msg_put(msg, l+2); - if (p_m_d_ntmode) - *ntmode = p+1; - else - qi->channel_id.off = p - (unsigned char *)qi - sizeof(Q931_info_t); p[0] = IE_CHANNEL_ID; p[1] = l; p[2] = 0x80 + 0x20 + 0x03; + add_layer3_ie(l3m, p[0], p[1], p+2); return; /* end */ } l = 3; - p = msg_put(msg, l+2); - if (p_m_d_ntmode) - *ntmode = p+1; - else - qi->channel_id.off = p - (unsigned char *)qi - sizeof(Q931_info_t); p[0] = IE_CHANNEL_ID; p[1] = l; p[2] = 0x80 + 0x20 + (exclusive<<3) + 0x01; p[3] = 0x80 + 3; /* CCITT, Number, B-type */ p[4] = 0x80 + channel; + add_layer3_ie(l3m, p[0], p[1], p+2); } } -void Pdss1::dec_ie_channel_id(unsigned char *p, Q931_info_t *qi, int *exclusive, int *channel) +void Pdss1::dec_ie_channel_id(struct l3_msg *l3m, int *exclusive, int *channel) { int pri = p_m_mISDNport->pri; *exclusive = -1; *channel = -1; - if (!p_m_d_ntmode) - { - p = NULL; - if (qi->channel_id.off) - p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->channel_id.off + 1; - } + unsigned char *p = l3m->channel_id; if (!p) return; if (p[0] < 1) { - PERROR("IE too short (%d).\n", p[0]); + add_trace("channel_id", "error", "IE too short (len=%d)", p[0]); return; } if (p[1] & 0x40) { - PERROR("refering to channels of other interfaces is not supported.\n"); + add_trace("channel_id", "error", "refering to channels of other interfaces is not supported"); return; } if (p[1] & 0x04) { - PERROR("using d-channel is not supported.\n"); + add_trace("channel_id", "error", "using d-channel is not supported"); return; } @@ -781,7 +729,7 @@ void Pdss1::dec_ie_channel_id(unsigned char *p, Q931_info_t *qi, int *exclusive, /* BRI */ if (p[1] & 0x20) { - PERROR("extended channel ID with non PRI interface.\n"); + add_trace("channel_id", "error", "extended channel ID with non PRI interface"); return; } *channel = p[1] & 0x03; @@ -794,12 +742,13 @@ void Pdss1::dec_ie_channel_id(unsigned char *p, Q931_info_t *qi, int *exclusive, /* PRI */ if (p[0] < 1) { - PERROR("IE too short for PRI (%d).\n", p[0]); + + add_trace("channel_id", "error", "IE too short for PRI (len=%d)", p[0]); return; } if (!(p[1] & 0x20)) { - PERROR("basic channel ID with PRI interface.\n"); + add_trace("channel_id", "error", "basic channel ID with PRI interface"); return; } if ((p[1]&0x03) == 0x00) @@ -816,31 +765,41 @@ void Pdss1::dec_ie_channel_id(unsigned char *p, Q931_info_t *qi, int *exclusive, } if (p[0] < 3) { - PERROR("%s: ERROR: IE too short for PRI with channel(%d).\n", __FUNCTION__, p[0]); + add_trace("channel_id", "error", "IE too short for PRI with channel (len=%d)", p[0]); return; } if (p[2] & 0x10) { - PERROR("channel map not supported.\n"); + add_trace("channel_id", "error", "channel map not supported"); return; } *channel = p[3] & 0x7f; if (*channel<1 | *channel==16) { - PERROR("PRI interface channel out of range (%d).\n", *channel); + add_trace("channel_id", "error", "PRI interface channel out of range (%d)", *channel); return; } } - printisdn(" exclusive=%d channel=%d\n", *exclusive, *channel); + add_trace("channel_id", "exclusive", "%d", *exclusive); + switch(*channel) + { + case CHANNEL_ANY: + add_trace("channel_id", "channel", "any channel"); + break; + case CHANNEL_NO: + add_trace("channel_id", "channel", "no channel"); + break; + default: + add_trace("channel_id", "channel", "%d", *channel); + } } /* IE_DATE */ -void Pdss1::enc_ie_date(unsigned char **ntmode, msg_t *msg, time_t ti, int no_seconds) +void Pdss1::enc_ie_date(struct l3_msg *l3m, time_t ti, int no_seconds) { - unsigned char *p; - Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN); + unsigned char p[256]; int l; struct tm *tm; @@ -852,14 +811,10 @@ void Pdss1::enc_ie_date(unsigned char **ntmode, msg_t *msg, time_t ti, int no_se return; } - printisdn(" year=%d month=%d day=%d hour=%d minute=%d second=%d\n", tm->tm_year%100, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); + add_trace("date", "day", "%d.%d.%d", tm->tm_mday, tm->tm_mon+1, tm->tm_year%100); + add_trace("date", "time", "%d:%d:%d", tm->tm_hour, tm->tm_min, tm->tm_sec); l = 5 + (!no_seconds); - p = msg_put(msg, l+2); - if (p_m_d_ntmode) - *ntmode = p+1; - else - qi->date.off = p - (unsigned char *)qi - sizeof(Q931_info_t); p[0] = IE_DATE; p[1] = l; p[2] = tm->tm_year % 100; @@ -869,14 +824,14 @@ void Pdss1::enc_ie_date(unsigned char **ntmode, msg_t *msg, time_t ti, int no_se p[6] = tm->tm_min; if (!no_seconds) p[7] = tm->tm_sec; + add_layer3_ie(l3m, p[0], p[1], p+2); } /* IE_DISPLAY */ -void Pdss1::enc_ie_display(unsigned char **ntmode, msg_t *msg, unsigned char *display) +void Pdss1::enc_ie_display(struct l3_msg *l3m, unsigned char *display) { - unsigned char *p; - Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN); + unsigned char p[256]; int l; if (!display[0]) @@ -891,48 +846,38 @@ void Pdss1::enc_ie_display(unsigned char **ntmode, msg_t *msg, unsigned char *di display[80] = '\0'; } - printisdn(" display='%s' (len=%d)\n", display, strlen((char *)display)); + add_trace("display", NULL, "%s", display); l = strlen((char *)display); - p = msg_put(msg, l+2); - if (p_m_d_ntmode) - *ntmode = p+1; - else - qi->display.off = p - (unsigned char *)qi - sizeof(Q931_info_t); p[0] = IE_DISPLAY; p[1] = l; UNCPY((char *)p+2, (char *)display, strlen((char *)display)); + add_layer3_ie(l3m, p[0], p[1], p+2); } -void Pdss1::dec_ie_display(unsigned char *p, Q931_info_t *qi, unsigned char *display, int display_len) +void Pdss1::dec_ie_display(struct l3_msg *l3m, unsigned char *display, int display_len) { *display = '\0'; - if (!p_m_d_ntmode) - { - p = NULL; - if (qi->display.off) - p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->display.off + 1; - } + unsigned char *p = l3m->display; if (!p) return; if (p[0] < 1) { - PERROR("IE too short (%d).\n", p[0]); + add_trace("display", "error", "IE too short (len=%d)", p[0]); return; } strnncpy(display, p+1, p[0], display_len); - printisdn(" display='%s'\n", display); + add_trace("display", NULL, "%s", display); } /* IE_KEYPAD */ -void Pdss1::enc_ie_keypad(unsigned char **ntmode, msg_t *msg, unsigned char *keypad) +void Pdss1::enc_ie_keypad(struct l3_msg *l3m, unsigned char *keypad) { - unsigned char *p; - Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN); + unsigned char p[256]; int l; if (!keypad[0]) @@ -941,48 +886,38 @@ void Pdss1::enc_ie_keypad(unsigned char **ntmode, msg_t *msg, unsigned char *key return; } - printisdn(" keypad='%s'\n", keypad); + add_trace("keypad", NULL, "%s", keypad); l = strlen((char *)keypad); - p = msg_put(msg, l+2); - if (p_m_d_ntmode) - *ntmode = p+1; - else - qi->keypad.off = p - (unsigned char *)qi - sizeof(Q931_info_t); p[0] = IE_KEYPAD; p[1] = l; UNCPY((char *)p+2, (char *)keypad, strlen((char *)keypad)); + add_layer3_ie(l3m, p[0], p[1], p+2); } -void Pdss1::dec_ie_keypad(unsigned char *p, Q931_info_t *qi, unsigned char *keypad, int keypad_len) +void Pdss1::dec_ie_keypad(struct l3_msg *l3m, unsigned char *keypad, int keypad_len) { *keypad = '\0'; - if (!p_m_d_ntmode) - { - p = NULL; - if (qi->keypad.off) - p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->keypad.off + 1; - } + unsigned char *p = l3m->keypad; if (!p) return; if (p[0] < 1) { - PERROR("IE too short (%d).\n", p[0]); + add_trace("keypad", "error", "IE too short (len=%d)", p[0]); return; } strnncpy(keypad, p+1, p[0], keypad_len); - printisdn(" keypad='%s'\n", keypad); + add_trace("keypad", NULL, "%s", keypad); } /* IE_NOTIFY */ -void Pdss1::enc_ie_notify(unsigned char **ntmode, msg_t *msg, int notify) +void Pdss1::enc_ie_notify(struct l3_msg *l3m, int notify) { - unsigned char *p; - Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN); + unsigned char p[256]; int l; if (notify<0 || notify>0x7f) @@ -991,48 +926,38 @@ void Pdss1::enc_ie_notify(unsigned char **ntmode, msg_t *msg, int notify) return; } - printisdn(" notify=%d\n", notify); + add_trace("notify", NULL, "%d", notify); l = 1; - p = msg_put(msg, l+2); - if (p_m_d_ntmode) - *ntmode = p+1; - else - qi->notify.off = p - (unsigned char *)qi - sizeof(Q931_info_t); p[0] = IE_NOTIFY; p[1] = l; p[2] = 0x80 + notify; + add_layer3_ie(l3m, p[0], p[1], p+2); } -void Pdss1::dec_ie_notify(unsigned char *p, Q931_info_t *qi, int *notify) +void Pdss1::dec_ie_notify(struct l3_msg *l3m, int *notify) { *notify = -1; - if (!p_m_d_ntmode) - { - p = NULL; - if (qi->notify.off) - p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->notify.off + 1; - } + unsigned char *p = l3m->notify; if (!p) return; if (p[0] < 1) { - PERROR("IE too short (%d).\n", p[0]); + add_trace("notify", "error", "IE too short (len=%d)", p[0]); return; } *notify = p[1] & 0x7f; - printisdn(" notify=%d\n", *notify); + add_trace("notify", NULL, "%d", *notify); } /* IE_PROGRESS */ -void Pdss1::enc_ie_progress(unsigned char **ntmode, msg_t *msg, int coding, int location, int progress) +void Pdss1::enc_ie_progress(struct l3_msg *l3m, int coding, int location, int progress) { - unsigned char *p; - Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN); + unsigned char p[256]; int l; if (coding<0 || coding>0x03) @@ -1051,37 +976,30 @@ void Pdss1::enc_ie_progress(unsigned char **ntmode, msg_t *msg, int coding, int return; } - printisdn(" coding=%d location=%d progress=%d\n", coding, location, progress); + add_trace("progress", "codeing", "%d", coding); + add_trace("progress", "location", "%d", location); + add_trace("progress", "indicator", "%d", progress); l = 2; - p = msg_put(msg, l+2); - if (p_m_d_ntmode) - *ntmode = p+1; - else - qi->progress.off = p - (unsigned char *)qi - sizeof(Q931_info_t); p[0] = IE_PROGRESS; p[1] = l; p[2] = 0x80 + (coding<<5) + location; p[3] = 0x80 + progress; + add_layer3_ie(l3m, p[0], p[1], p+2); } -void Pdss1::dec_ie_progress(unsigned char *p, Q931_info_t *qi, int *coding, int *location, int *progress) +void Pdss1::dec_ie_progress(struct l3_msg *l3m, int *coding, int *location, int *progress) { *coding = -1; *location = -1; *progress = -1; - if (!p_m_d_ntmode) - { - p = NULL; - if (qi->progress.off) - p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->progress.off + 1; - } + unsigned char *p = l3m->progress; if (!p) return; if (p[0] < 1) { - PERROR("IE too short (%d).\n", p[0]); + add_trace("progress", "error", "IE too short (len=%d)", p[0]); return; } @@ -1089,15 +1007,16 @@ void Pdss1::dec_ie_progress(unsigned char *p, Q931_info_t *qi, int *coding, int *location = p[1] & 0x0f; *progress = p[2] & 0x7f; - printisdn(" coding=%d location=%d progress=%d\n", *coding, *location, *progress); + add_trace("progress", "codeing", "%d", *coding); + add_trace("progress", "location", "%d", *location); + add_trace("progress", "indicator", "%d", *progress); } /* IE_REDIR_NR (redirecting = during MT_SETUP) */ -void Pdss1::enc_ie_redir_nr(unsigned char **ntmode, msg_t *msg, int type, int plan, int present, int screen, int reason, unsigned char *number) +void Pdss1::enc_ie_redir_nr(struct l3_msg *l3m, int type, int plan, int present, int screen, int reason, unsigned char *number) { - unsigned char *p; - Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN); + unsigned char p[256]; int l; if (type<0 || type>7) @@ -1126,7 +1045,12 @@ void Pdss1::enc_ie_redir_nr(unsigned char **ntmode, msg_t *msg, int type, int pl return; } - printisdn(" type=%d plan=%d present=%d screen=%d readon=%d number='%s'\n", type, plan, present, screen, reason, number); + add_trace("redir'ing", "type", "%d", type); + add_trace("redir'ing", "plan", "%d", plan); + add_trace("redir'ing", "present", "%d", present); + add_trace("redir'ing", "screen", "%d", screen); + add_trace("redir'ing", "reason", "%d", reason); + add_trace("redir'ing", "number", "%s", number); l = 1; if (number) @@ -1137,11 +1061,6 @@ void Pdss1::enc_ie_redir_nr(unsigned char **ntmode, msg_t *msg, int type, int pl if (reason >= 0) l += 1; } - p = msg_put(msg, l+2); - if (p_m_d_ntmode) - *ntmode = p+1; - else - qi->redirect_nr.off = p - (unsigned char *)qi - sizeof(Q931_info_t); p[0] = IE_REDIR_NR; p[1] = l; if (present >= 0) @@ -1166,9 +1085,10 @@ void Pdss1::enc_ie_redir_nr(unsigned char **ntmode, msg_t *msg, int type, int pl if (number) if (number[0]) UNCPY((char *)p+3, (char *)number, strlen((char *)number)); } + add_layer3_ie(l3m, p[0], p[1], p+2); } -void Pdss1::dec_ie_redir_nr(unsigned char *p, Q931_info_t *qi, int *type, int *plan, int *present, int *screen, int *reason, unsigned char *number, int number_len) +void Pdss1::dec_ie_redir_nr(struct l3_msg *l3m, int *type, int *plan, int *present, int *screen, int *reason, unsigned char *number, int number_len) { *type = -1; *plan = -1; @@ -1177,17 +1097,12 @@ void Pdss1::dec_ie_redir_nr(unsigned char *p, Q931_info_t *qi, int *type, int *p *reason = -1; *number = '\0'; - if (!p_m_d_ntmode) - { - p = NULL; - if (qi->redirect_nr.off) - p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->redirect_nr.off + 1; - } + unsigned char *p = l3m->redirect_nr; if (!p) return; if (p[0] < 1) { - PERROR("IE too short (%d).\n", p[0]); + add_trace("redir'ing", "error", "IE too short (len=%d)", p[0]); return; } @@ -1210,15 +1125,19 @@ void Pdss1::dec_ie_redir_nr(unsigned char *p, Q931_info_t *qi, int *type, int *p strnncpy(number, p+2, p[0]-1, number_len); } - printisdn(" type=%d plan=%d present=%d screen=%d reason=%d number='%s'\n", *type, *plan, *present, *screen, *reason, number); + add_trace("redir'ing", "type", "%d", *type); + add_trace("redir'ing", "plan", "%d", *plan); + add_trace("redir'ing", "present", "%d", *present); + add_trace("redir'ing", "screen", "%d", *screen); + add_trace("redir'ing", "reason", "%d", *reason); + add_trace("redir'ing", "number", "%s", number); } /* IE_REDIR_DN (redirection = during MT_NOTIFY) */ -void Pdss1::enc_ie_redir_dn(unsigned char **ntmode, msg_t *msg, int type, int plan, int present, unsigned char *number) +void Pdss1::enc_ie_redir_dn(struct l3_msg *l3m, int type, int plan, int present, unsigned char *number) { - unsigned char *p; - Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN); + unsigned char p[256]; int l; if (type<0 || type>7) @@ -1237,18 +1156,16 @@ void Pdss1::enc_ie_redir_dn(unsigned char **ntmode, msg_t *msg, int type, int pl return; } - printisdn(" type=%d plan=%d present=%d number='%s'\n", type, plan, present, number); + add_trace("redir'tion", "type", "%d", type); + add_trace("redir'tion", "plan", "%d", plan); + add_trace("redir'tion", "present", "%d", present); + add_trace("redir'tion", "number", "%s", number); l = 1; if (number) l += strlen((char *)number); if (present >= 0) l += 1; - p = msg_put(msg, l+2); - if (p_m_d_ntmode) - *ntmode = p+1; - else - qi->redirect_dn.off = p - (unsigned char *)qi - sizeof(Q931_info_t); p[0] = IE_REDIR_DN; p[1] = l; if (present >= 0) @@ -1263,26 +1180,22 @@ void Pdss1::enc_ie_redir_dn(unsigned char **ntmode, msg_t *msg, int type, int pl if (number) UNCPY((char *)p+3, (char *)number, strlen((char *)number)); } + add_layer3_ie(l3m, p[0], p[1], p+2); } -void Pdss1::dec_ie_redir_dn(unsigned char *p, Q931_info_t *qi, int *type, int *plan, int *present, unsigned char *number, int number_len) +void Pdss1::dec_ie_redir_dn(struct l3_msg *l3m, int *type, int *plan, int *present, unsigned char *number, int number_len) { *type = -1; *plan = -1; *present = -1; *number = '\0'; - if (!p_m_d_ntmode) - { - p = NULL; - if (qi->redirect_dn.off) - p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->redirect_dn.off + 1; - } + unsigned char *p = l3m->redirect_dn; if (!p) return; if (p[0] < 1) { - PERROR("IE too short (%d).\n", p[0]); + add_trace("redir'tion", "error", "IE too short (len=%d)", p[0]); return; } @@ -1297,18 +1210,20 @@ void Pdss1::dec_ie_redir_dn(unsigned char *p, Q931_info_t *qi, int *type, int *p strnncpy(number, p+2, p[0]-1, number_len); } - printisdn(" type=%d plan=%d present=%d number='%s'\n", *type, *plan, *present, number); + add_trace("redir'tion", "type", "%d", *type); + add_trace("redir'tion", "plan", "%d", *plan); + add_trace("redir'tion", "present", "%d", *present); + add_trace("redir'tion", "number", "%s", number); } /* IE_FACILITY */ -void Pdss1::enc_ie_facility(unsigned char **ntmode, msg_t *msg, unsigned char *facility, int facility_len) +void Pdss1::enc_ie_facility(struct l3_msg *l3m, unsigned char *facility, int facility_len) { - unsigned char *p; - Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN); + unsigned char p[256]; int l; - char debug[768]; + char buffer[768]; int i; if (!facility || facility_len<=0) @@ -1319,36 +1234,27 @@ void Pdss1::enc_ie_facility(unsigned char **ntmode, msg_t *msg, unsigned char *f i = 0; while(i < facility_len) { - UPRINT(debug+(i*3), " %02x", facility[i]); + UPRINT(buffer+(i*3), " %02x", facility[i]); i++; } - printisdn(" facility%s\n", debug); + add_trace("facility", NULL, "%s", buffer+1); l = facility_len; - p = msg_put(msg, l+2); - if (p_m_d_ntmode) - *ntmode = p+1; - else - qi->facility.off = p - (unsigned char *)qi - sizeof(Q931_info_t); p[0] = IE_FACILITY; p[1] = l; memcpy(p+2, facility, facility_len); + add_layer3_ie(l3m, p[0], p[1], p+2); } -void Pdss1::dec_ie_facility(unsigned char *p, Q931_info_t *qi, unsigned char *facility, int *facility_len) +void Pdss1::dec_ie_facility(struct l3_msg *l3m, unsigned char *facility, int *facility_len) { char debug[768]; int i; *facility_len = 0; - if (!p_m_d_ntmode) - { - p = NULL; - if (qi->facility.off) - p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->facility.off + 1; - } + unsigned char *p = l3m->facility; if (!p) return; @@ -1363,63 +1269,11 @@ void Pdss1::dec_ie_facility(unsigned char *p, Q931_info_t *qi, unsigned char *fa } debug[i*3] = '\0'; - printisdn(" facility%s\n", debug); + add_trace("facility", NULL, "%s", debug[0]?debug+1:""); } -/* facility for siemens CENTEX (known parts implemented only) */ -void Pdss1::enc_facility_centrex(unsigned char **ntmode, msg_t *msg, unsigned char *cnip, int setup) -{ - unsigned char centrex[256]; - int i = 0; - - if (!cnip) - return; - - /* centrex facility */ - centrex[i++] = CENTREX_FAC; - centrex[i++] = CENTREX_ID; - - /* cnip */ - if (strlen((char *)cnip) > 15) - { - PDEBUG(DEBUG_PORT, "%s: CNIP/CONP text too long (max 13 chars), cutting.\n"); - cnip[15] = '\0'; - } - // dunno what the 8 bytes mean - if (setup) - { - centrex[i++] = 0x17; - centrex[i++] = 0x02; - centrex[i++] = 0x02; - centrex[i++] = 0x44; - centrex[i++] = 0x18; - centrex[i++] = 0x02; - centrex[i++] = 0x01; - centrex[i++] = 0x09; - } else - { - centrex[i++] = 0x18; - centrex[i++] = 0x02; - centrex[i++] = 0x02; - centrex[i++] = 0x81; - centrex[i++] = 0x09; - centrex[i++] = 0x02; - centrex[i++] = 0x01; - centrex[i++] = 0x0a; - } - - centrex[i++] = 0x80; - centrex[i++] = strlen((char *)cnip); - UCPY((char *)(¢rex[i]), (char *)cnip); - i += strlen((char *)cnip); - printisdn(" cnip='%s'\n", cnip); - - /* encode facility */ - enc_ie_facility(ntmode, msg, centrex, i); -} - -void Pdss1::dec_facility_centrex(unsigned char *p, Q931_info_t *qi, unsigned char *cnip, int cnip_len) +void Pdss1::dec_facility_centrex(struct l3_msg *l3m, unsigned char *cnip, int cnip_len) { unsigned char centrex[256]; char debug[768]; @@ -1427,7 +1281,7 @@ void Pdss1::dec_facility_centrex(unsigned char *p, Q931_info_t *qi, unsigned cha int i = 0, j; *cnip = '\0'; - dec_ie_facility(p, qi, centrex, &facility_len); + dec_ie_facility(l3m, centrex, &facility_len); if (facility_len >= 2) { if (centrex[i++] != CENTREX_FAC) @@ -1448,7 +1302,7 @@ void Pdss1::dec_facility_centrex(unsigned char *p, Q931_info_t *qi, unsigned cha { case 0x80: strnncpy(cnip, ¢rex[i+2], centrex[i+1], cnip_len); - printisdn(" CENTREX cnip='%s'\n", cnip); + add_trace("facility", "cnip", "%s", cnip); break; default: @@ -1458,7 +1312,7 @@ void Pdss1::dec_facility_centrex(unsigned char *p, Q931_info_t *qi, unsigned cha UPRINT(debug+(j*3), " %02x", centrex[i+1+j]); i++; } - printisdn(" CENTREX unknown=0x%2x len=%d%s\n", centrex[i], centrex[i+1], debug); + add_trace("facility", "CENTREX", "unknown=0x%02x len=%d%s\n", centrex[i], centrex[i+1], debug); } i += 1+centrex[i+1]; } @@ -1466,13 +1320,12 @@ void Pdss1::dec_facility_centrex(unsigned char *p, Q931_info_t *qi, unsigned cha /* IE_USERUSER */ -void Pdss1::enc_ie_useruser(unsigned char **ntmode, msg_t *msg, int protocol, unsigned char *user, int user_len) +void Pdss1::enc_ie_useruser(struct l3_msg *l3m, int protocol, unsigned char *user, int user_len) { - unsigned char *p; - Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN); + unsigned char p[256]; int l; - char debug[768]; + char buffer[768]; int i; if (protocol<0 || protocol>127) @@ -1488,38 +1341,30 @@ void Pdss1::enc_ie_useruser(unsigned char **ntmode, msg_t *msg, int protocol, un i = 0; while(i < user_len) { - UPRINT(debug+(i*3), " %02x", user[i]); + UPRINT(buffer+(i*3), " %02x", user[i]); i++; } - printisdn(" protocol=%d user-user%s\n", protocol, debug); + add_trace("useruser", "protocol", "%d", protocol); + add_trace("useruser", "value", "%s", buffer); l = user_len; - p = msg_put(msg, l+3); - if (p_m_d_ntmode) - *ntmode = p+1; - else - qi->useruser.off = p - (unsigned char *)qi - sizeof(Q931_info_t); p[0] = IE_USER_USER; p[1] = l; p[2] = 0x80 + protocol; memcpy(p+3, user, user_len); + add_layer3_ie(l3m, p[0], p[1], p+2); } -void Pdss1::dec_ie_useruser(unsigned char *p, Q931_info_t *qi, int *protocol, unsigned char *user, int *user_len) +void Pdss1::dec_ie_useruser(struct l3_msg *l3m, int *protocol, unsigned char *user, int *user_len) { - char debug[768]; + char buffer[768]; int i; *user_len = 0; *protocol = -1; - if (!p_m_d_ntmode) - { - p = NULL; - if (qi->useruser.off) - p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->useruser.off + 1; - } + unsigned char *p = l3m->useruser; if (!p) return; @@ -1532,12 +1377,13 @@ void Pdss1::dec_ie_useruser(unsigned char *p, Q931_info_t *qi, int *protocol, un i = 0; while(i < *user_len) { - UPRINT(debug+(i*3), " %02x", user[i]); + UPRINT(buffer+(i*3), " %02x", user[i]); i++; } - debug[i*3] = '\0'; + buffer[i*3] = '\0'; - printisdn(" protocol=%d user-user%s\n", *protocol, debug); + add_trace("useruser", "protocol", "%d", *protocol); + add_trace("useruser", "value", "%s", buffer); }