📄 isdn_msg_parser.c
字号:
static void parse_connect_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) {#ifdef DEBUG printf("Parsing CONNECT_ACKNOWLEDGE Msg\n"); #endif }static msg_t *build_connect_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; CONNECT_ACKNOWLEDGE_t *connect_acknowledge; msg_t *msg =(msg_t*)create_l3msg(CC_CONNECT | RESPONSE, MT_CONNECT, bc?bc->l3_id:-1, sizeof(CONNECT_ACKNOWLEDGE_t) ,nt); connect_acknowledge=(CONNECT_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN)); enc_ie_channel_id(&connect_acknowledge->CHANNEL_ID, msg, 1, bc->channel, nt,bc); #ifdef DEBUG printf("Building CONNECT_ACKNOWLEDGE Msg\n"); #endif return msg; }static void parse_user_information (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) {#ifdef DEBUG printf("Parsing USER_INFORMATION Msg\n"); #endif }static msg_t *build_user_information (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; USER_INFORMATION_t *user_information; msg_t *msg =(msg_t*)create_l3msg(CC_USER_INFORMATION | REQUEST, MT_USER_INFORMATION, bc?bc->l3_id:-1, sizeof(USER_INFORMATION_t) ,nt); user_information=(USER_INFORMATION_t*)((msg->data+HEADER_LEN)); #ifdef DEBUG printf("Building USER_INFORMATION Msg\n"); #endif return msg; }static void parse_suspend_reject (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) {#ifdef DEBUG printf("Parsing SUSPEND_REJECT Msg\n"); #endif }static msg_t *build_suspend_reject (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; SUSPEND_REJECT_t *suspend_reject; msg_t *msg =(msg_t*)create_l3msg(CC_SUSPEND_REJECT | REQUEST, MT_SUSPEND_REJECT, bc?bc->l3_id:-1, sizeof(SUSPEND_REJECT_t) ,nt); suspend_reject=(SUSPEND_REJECT_t*)((msg->data+HEADER_LEN)); #ifdef DEBUG printf("Building SUSPEND_REJECT Msg\n"); #endif return msg; }static void parse_resume_reject (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) {#ifdef DEBUG printf("Parsing RESUME_REJECT Msg\n"); #endif }static msg_t *build_resume_reject (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; RESUME_REJECT_t *resume_reject; msg_t *msg =(msg_t*)create_l3msg(CC_RESUME_REJECT | REQUEST, MT_RESUME_REJECT, bc?bc->l3_id:-1, sizeof(RESUME_REJECT_t) ,nt); resume_reject=(RESUME_REJECT_t*)((msg->data+HEADER_LEN)); #ifdef DEBUG printf("Building RESUME_REJECT Msg\n"); #endif return msg; }static void parse_hold (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) {#ifdef DEBUG printf("Parsing HOLD Msg\n"); #endif }static msg_t *build_hold (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; HOLD_t *hold; msg_t *msg =(msg_t*)create_l3msg(CC_HOLD | REQUEST, MT_HOLD, bc?bc->l3_id:-1, sizeof(HOLD_t) ,nt); hold=(HOLD_t*)((msg->data+HEADER_LEN)); #ifdef DEBUG printf("Building HOLD Msg\n"); #endif return msg; }static void parse_suspend (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) {#ifdef DEBUG printf("Parsing SUSPEND Msg\n"); #endif }static msg_t *build_suspend (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; SUSPEND_t *suspend; msg_t *msg =(msg_t*)create_l3msg(CC_SUSPEND | REQUEST, MT_SUSPEND, bc?bc->l3_id:-1, sizeof(SUSPEND_t) ,nt); suspend=(SUSPEND_t*)((msg->data+HEADER_LEN)); #ifdef DEBUG printf("Building SUSPEND Msg\n"); #endif return msg; }static void parse_resume (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) {#ifdef DEBUG printf("Parsing RESUME Msg\n"); #endif }static msg_t *build_resume (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; RESUME_t *resume; msg_t *msg =(msg_t*)create_l3msg(CC_RESUME | REQUEST, MT_RESUME, bc?bc->l3_id:-1, sizeof(RESUME_t) ,nt); resume=(RESUME_t*)((msg->data+HEADER_LEN)); #ifdef DEBUG printf("Building RESUME Msg\n"); #endif return msg; }static void parse_hold_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) {#ifdef DEBUG printf("Parsing HOLD_ACKNOWLEDGE Msg\n"); #endif }static msg_t *build_hold_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; HOLD_ACKNOWLEDGE_t *hold_acknowledge; msg_t *msg =(msg_t*)create_l3msg(CC_HOLD_ACKNOWLEDGE | REQUEST, MT_HOLD_ACKNOWLEDGE, bc?bc->l3_id:-1, sizeof(HOLD_ACKNOWLEDGE_t) ,nt); hold_acknowledge=(HOLD_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN)); #ifdef DEBUG printf("Building HOLD_ACKNOWLEDGE Msg\n"); #endif return msg; }static void parse_suspend_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) {#ifdef DEBUG printf("Parsing SUSPEND_ACKNOWLEDGE Msg\n"); #endif }static msg_t *build_suspend_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; SUSPEND_ACKNOWLEDGE_t *suspend_acknowledge; msg_t *msg =(msg_t*)create_l3msg(CC_SUSPEND_ACKNOWLEDGE | REQUEST, MT_SUSPEND_ACKNOWLEDGE, bc?bc->l3_id:-1, sizeof(SUSPEND_ACKNOWLEDGE_t) ,nt); suspend_acknowledge=(SUSPEND_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN)); #ifdef DEBUG printf("Building SUSPEND_ACKNOWLEDGE Msg\n"); #endif return msg; }static void parse_resume_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) {#ifdef DEBUG printf("Parsing RESUME_ACKNOWLEDGE Msg\n"); #endif }static msg_t *build_resume_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; RESUME_ACKNOWLEDGE_t *resume_acknowledge; msg_t *msg =(msg_t*)create_l3msg(CC_RESUME_ACKNOWLEDGE | REQUEST, MT_RESUME_ACKNOWLEDGE, bc?bc->l3_id:-1, sizeof(RESUME_ACKNOWLEDGE_t) ,nt); resume_acknowledge=(RESUME_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN)); #ifdef DEBUG printf("Building RESUME_ACKNOWLEDGE Msg\n"); #endif return msg; }static void parse_hold_reject (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) {#ifdef DEBUG printf("Parsing HOLD_REJECT Msg\n"); #endif }static msg_t *build_hold_reject (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; HOLD_REJECT_t *hold_reject; msg_t *msg =(msg_t*)create_l3msg(CC_HOLD_REJECT | REQUEST, MT_HOLD_REJECT, bc?bc->l3_id:-1, sizeof(HOLD_REJECT_t) ,nt); hold_reject=(HOLD_REJECT_t*)((msg->data+HEADER_LEN)); #ifdef DEBUG printf("Building HOLD_REJECT Msg\n"); #endif return msg; }static void parse_retrieve (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) {#ifdef DEBUG printf("Parsing RETRIEVE Msg\n"); #endif }static msg_t *build_retrieve (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; RETRIEVE_t *retrieve; msg_t *msg =(msg_t*)create_l3msg(CC_RETRIEVE | REQUEST, MT_RETRIEVE, bc?bc->l3_id:-1, sizeof(RETRIEVE_t) ,nt); retrieve=(RETRIEVE_t*)((msg->data+HEADER_LEN)); #ifdef DEBUG printf("Building RETRIEVE Msg\n"); #endif return msg; }static void parse_retrieve_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) {#ifdef DEBUG printf("Parsing RETRIEVE_ACKNOWLEDGE Msg\n"); #endif }static msg_t *build_retrieve_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; RETRIEVE_ACKNOWLEDGE_t *retrieve_acknowledge; msg_t *msg =(msg_t*)create_l3msg(CC_RETRIEVE_ACKNOWLEDGE | REQUEST, MT_RETRIEVE_ACKNOWLEDGE, bc?bc->l3_id:-1, sizeof(RETRIEVE_ACKNOWLEDGE_t) ,nt); retrieve_acknowledge=(RETRIEVE_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN)); enc_ie_channel_id(&retrieve_acknowledge->CHANNEL_ID, msg, 1, bc->channel, nt,bc);#ifdef DEBUG printf("Building RETRIEVE_ACKNOWLEDGE Msg\n"); #endif return msg; }static void parse_retrieve_reject (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) {#ifdef DEBUG printf("Parsing RETRIEVE_REJECT Msg\n"); #endif }static msg_t *build_retrieve_reject (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; RETRIEVE_REJECT_t *retrieve_reject; msg_t *msg =(msg_t*)create_l3msg(CC_RETRIEVE_REJECT | REQUEST, MT_RETRIEVE_REJECT, bc?bc->l3_id:-1, sizeof(RETRIEVE_REJECT_t) ,nt); retrieve_reject=(RETRIEVE_REJECT_t*)((msg->data+HEADER_LEN)); #ifdef DEBUG printf("Building RETRIEVE_REJECT Msg\n"); #endif return msg; }static void parse_disconnect (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; DISCONNECT_t *disconnect=(DISCONNECT_t*)((unsigned long)(msg->data+HEADER_LEN)); int location; int cause; dec_ie_cause(disconnect->CAUSE, (Q931_info_t *)(disconnect), &location, &cause, nt,bc); if (cause>0) bc->cause=cause; dec_ie_progress(disconnect->PROGRESS, (Q931_info_t *)disconnect, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc);#ifdef DEBUG printf("Parsing DISCONNECT Msg\n"); #endif }static msg_t *build_disconnect (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; DISCONNECT_t *disconnect; msg_t *msg =(msg_t*)create_l3msg(CC_DISCONNECT | REQUEST, MT_DISCONNECT, bc?bc->l3_id:-1, sizeof(DISCONNECT_t) ,nt); disconnect=(DISCONNECT_t*)((msg->data+HEADER_LEN)); enc_ie_cause(&disconnect->CAUSE, msg, (nt)?1:0, bc->out_cause,nt,bc); if (nt) enc_ie_progress(&disconnect->PROGRESS, msg, 0, nt?1:5, 8 ,nt,bc); if (bc->uulen) { int protocol=4; enc_ie_useruser(&disconnect->USER_USER, msg, protocol, bc->uu, bc->uulen, nt,bc); cb_log(1,bc->port,"ENCODING USERUESRINFO:%s\n",bc->uu); } #ifdef DEBUG printf("Building DISCONNECT Msg\n"); #endif return msg; }static void parse_restart (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; RESTART_t *restart=(RESTART_t*)((unsigned long)(msg->data+HEADER_LEN)); struct misdn_stack *stack=get_stack_by_bc(bc); #ifdef DEBUG printf("Parsing RESTART Msg\n");#endif { int exclusive; dec_ie_channel_id(restart->CHANNEL_ID, (Q931_info_t *)restart, &exclusive, &bc->restart_channel, nt,bc); cb_log(3, stack->port, "CC_RESTART Request on channel:%d on this port.\n", bc->restart_channel); } }static msg_t *build_restart (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; RESTART_t *restart; msg_t *msg =(msg_t*)create_l3msg(CC_RESTART | REQUEST, MT_RESTART, bc?bc->l3_id:-1, sizeof(RESTART_t) ,nt); restart=(RESTART_t*)((msg->data+HEADER_LEN)); #ifdef DEBUG printf("Building RESTART Msg\n"); #endif if (bc->channel > 0) { enc_ie_channel_id(&restart->CHANNEL_ID, msg, 1,bc->channel, nt,bc); enc_ie_restart_ind(&restart->RESTART_IND, msg, 0x80, nt, bc); } else { enc_ie_restart_ind(&restart->RESTART_IND, msg, 0x87, nt, bc); } cb_log(0,bc->port, "Restarting channel %d\n", bc->channel); return msg; }static void parse_release (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; RELEASE_t *release=(RELEASE_t*)((unsigned long)(msg->data+HEADER_LEN)); int location; int cause; dec_ie_cause(release->CAUSE, (Q931_info_t *)(release), &location, &cause, nt,bc); if (cause>0) bc->cause=cause;#ifdef DEBUG printf("Parsing RELEASE Msg\n"); #endif }static msg_t *build_release (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; RELEASE_t *release; msg_t *msg =(msg_t*)create_l3msg(CC_RELEASE | REQUEST, MT_RELEASE, bc?bc->l3_id:-1, sizeof(RELEASE_t) ,nt); release=(RELEASE_t*)((msg->data+HEADER_LEN)); if (bc->out_cause>= 0) enc_ie_cause(&release->CAUSE, msg, nt?1:0, bc->out_cause, nt,bc); if (bc->uulen) { int protocol=4; enc_ie_useruser(&release->USER_USER, msg, protocol, bc->uu, bc->uulen, nt,bc); cb_log(1,bc->port,"ENCODING USERUESRINFO:%s\n",bc->uu); } #ifdef DEBUG printf("Building RELEASE Msg\n"); #endif return msg; }static void parse_release_complete (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) { int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; RELEASE_COMPLETE_t *release_complete=(RELEASE_COMPLETE_t*)((unsigned long)(msg->data+HEADER_LEN)); int location;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -