#include "../../public/src/include/pub_include.h" #include "../../snmp/src/include/snmp.h" #include "../../snmp/src/include/macro.h" #include "../../snmp/src/include/heartbeat.h" #include "./include/mtp3.h" #ifdef _INCLUDE_M2UA #include "../../m2ua/src/include/m2ua.h" #endif #include "./include/mtpstm.h" #include "./include/mtpext.h" #include "./include/mtpfunc.h" /*@ignore@*/ char mtpconfile[] = {"./conf/mtp3.conf"}; FILE *mtpfpConf; char MTP_OBJECT_LKA[20]={"[LINK ATTRIBUTE]\n"}; char MTP_OBJECT_NSP[80]={"[NATIONAL NETWORK SP]\n"}; char MTP_OBJECT_NSSP[80]={"[NATIONAL NETWORK SPARE SP]\n"}; char MTP_OBJECT_ISP[80]={"[INTERNATIONAL NETWORK SP]\n"}; char MTP_OBJECT_ISSP[80]={"[INTERNATIONAL NETWORK SPARE SP]\n"}; char MTP_OBJECT_LSA[40]={"[LINKSET ATTRIBUTE]\n"}; char MTP_OBJECT_LSP[20]={"[LOCAL SP]\n"}; char MTP_OBJECT_SNL[40]={"[SERVICE NETWORK SP LEN]\n"}; char MTP_OBJECT_SG[40]={"[SG ATTRIBUTES]\n"}; char MTP_OBJECT_MTP3LITE_PORT[40]={"[MTP3LITE TCP PORT]"}; long atol(const char *nptr); void hmrt_tcoc_update_routing_tables(WORD chl); void hmrt_tcbc_update_routing_tables(WORD chl); void update_timer(int link); BOOL Alinkset_status(BYTE routine); BOOL Nlinkset_status(BYTE routine); void mark_normal_linkset_available(BYTE *routine); void mark_alternative_linkset_unavailable(BYTE *routine); void mark_alternative_linkset_available(BYTE *routine); void mark_normal_linkset_unavailable(BYTE *routine); void mark_dstSP_inaccessible(BYTE *routine); void hmrt_tfrc_update_routing_tables(WORD dst, BYTE nw); void otherMTP3_managed_link_unavailable(WORD chl); void mtp3_reload_data(); int MTP3_LinkIP_List(ulong IP,BYTE mode); void deactive_mtp3lite_lk(WORD link); void mtp3_snmp_registration(void); //extern from sccp/sccpfun.c extern ull Bcd2Ull(BYTE *pBcd, int BcdLen); extern int ParseLine(char *str, char (*row)[128], int maxrow); extern int Str2Bcd(BYTE *pBcd, char *pStr, int maxLen); extern void deactive_m3ua_lk(WORD link); static u32 peer_hb_timer = 0; static u32 mtp3_primomcip=0; // primary omc ip address static u32 mtp3_secdomcip=0; // secondary omc ip address static BYTE mtp3SaveFlag[]={0xaa,0,0xaa}; static u32 mtp2_object_id[] = {1,3,6,1,4,1,1373,1,3,1,1,3}; #define MTP2_PREOID_LEN 12 int checkMtp3SaveFlag() { if(mtp3SaveFlag[0]==0xaa && mtp3SaveFlag[2]==0xaa && mtp3SaveFlag[1]<2) return mtp3SaveFlag[1]; else { mtp3_debug(MTP3DB_ERROR,"WARNING, some stuff change mtp3SaveFlag= %x %x %x unexpectedly!!!",mtp3SaveFlag[0],mtp3SaveFlag[1],mtp3SaveFlag[2]); return 0; } } void mtp3EnableSaveFlag() { mtp3SaveFlag[1] = 1; } void mtp3DisableSaveFlag() { mtp3SaveFlag[1] = 0; } void mtp3_send_mtp2_alarm(WORD component,BYTE alarm)//??? { snmp_pdu snmp_buf; snmp_addr snmp_addr; time_t cur_time; u8 *buf; snmp_addr.remote_port = 4957; snmp_addr.local_port = 4957; snmp_addr.broadcast = 0; snmp_buf.pdu_type = 7; snmp_buf.var_num = 1; memcpy(snmp_buf.var[0].oid, mtp2_object_id, MTP2_PREOID_LEN*4); snmp_buf.var[0].oid[MTP2_PREOID_LEN] = 4; snmp_buf.var[0].oidlen = MTP2_PREOID_LEN + 1; snmp_buf.var[0].vartype = 4; buf = snmp_buf.var[0].msg; buf[0] = mtp2_module; // system id buf[1] = mtp2_systemid; cur_time = time(NULL); buf[2] = cur_time >> 24; // time stamp buf[3] = cur_time >> 16; buf[4] = cur_time >> 8; buf[5] = cur_time; // byte 6--13 16 LED status (green continuous: 0x09, yellow continuous: 0x0a) buf[6] = 0x99; if (alarm != 0) buf[7] = 0xaf; else buf[7] = 0x9f; memset(buf+8, 0xff, 6); buf[14] = component>>8; // first byte of component id buf[15] = component&255; // second byte of component id buf[16] = alarm; // alarm level buf[17] = 0; buf[18] = 0;//length 1 buf[19] = 0;//component id buf[20] = 0;//component id buf[21] = 0; buf[22] = 20;//length 2 // memcpy(buf+30, hlr_vm_ptr->sys_param.hlr_seqnum, HLR_SEQNUM_LEN); // snmp_buf.var[0].msglen = 37 + HLR_SEQNUM_LEN; snmp_buf.var[0].msglen = 23; // snmp_addr.remote_ip = 0x81ea12ac; if (mtp3_primomcip != 0) { snmp_addr.remote_ip = mtp3_primomcip; snmp_send(&snmp_buf, &snmp_addr); } if (mtp3_secdomcip != 0) { snmp_addr.remote_ip = mtp3_secdomcip; snmp_send(&snmp_buf, &snmp_addr); } } int Mtp3BinSearchIndex(WORD low, WORD high,ull key, BYTE nw) { mtp3DPCIndex *sort_rec = &mtp3SortRoutine.nw[nw]; static int mid; static long long midvalue; if(low>high) { // LogErr("BinSearchIndex ERR,low=%d,high=%d,key=%lld",low,high,key); return low; } if(high == low+1 ) { if(key<=sort_rec->dpc[low]) return low; else if(key<=sort_rec->dpc[high]) return high; else return high+1; } if(low == high) { if(key<=sort_rec->dpc[low]) return low; else return low+1; } mid = (low + high)/2; midvalue = sort_rec->dpc[mid]; if(key == midvalue) { return mid; } else if(keyhigh) { // LogErr("BinSearchIndex ERR,low=%d,high=%d,key=%lld",low,high,key); return -1; } if (sort_rec->sortedNum <= 0) return -1; if (high > sort_rec->sortedNum-1) high = sort_rec->sortedNum-1; if(high == low+1 ) { if(key==sort_rec->dpc[low]) return low; else if(key==sort_rec->dpc[high]) return high; else return -1; } if(low == high) { if(key==sort_rec->dpc[low]) return low; else return -1; } mid = (low + high)/2; midvalue = sort_rec->dpc[mid]; if(key == midvalue) { return mid; } else if(keysortedNum > MAX_ROUTE - 1) { mtp3SortRoutine.nw[nw].sortedNum = MAX_ROUTE - 1; return 0; } if(opc == mtp3_para->nw[nw].opc14) opc = 0; opc_dpc = opc; opc_dpc = (opc_dpc<<32)|dpc; if(sort_rec->sortedNum == 0) { index1 = 0; sort_rec->dpc[index1] = opc_dpc; sort_rec->sortedNum = 1; sort_rec->index[index1] = real_index; return 1; } else { index1 = Mtp3BinSearchValue(0,MAX_ROUTE-1,nw,opc_dpc); if (index1>=0 && index1 < sort_rec->sortedNum)//already has this record return 0; while(sort_rec->dpc[0] > sort_rec->dpc[sort_rec->sortedNum - 1]) sort_rec->sortedNum = (sort_rec->sortedNum - 1) % MAX_ROUTE; //LogErr("--AddSortRec,start BinSearchIndex key=%lld",key); index1 = Mtp3BinSearchIndex(0,sort_rec->sortedNum-1,opc_dpc,nw); if (index1 >= sort_rec->sortedNum) { if (sort_rec->sortedNum >= MAX_ROUTE-1) { return 0; } sort_rec->dpc[sort_rec->sortedNum] = opc_dpc; sort_rec->index[sort_rec->sortedNum] = real_index; sort_rec->sortedNum ++; } // LogErr("---AddSortRec: index1=%d,store_i=%d,old_key=%lld",index1,index,sort_rec[index1].key); } if (sort_rec->dpc[index1] != opc_dpc) {// insert a item int moveNum = (sort_rec->sortedNum-index1) % MAX_ROUTE; if (sort_rec->sortedNum >= MAX_ROUTE) { return 0; } memmove(&sort_rec->dpc[index1+1],&sort_rec->dpc[index1],moveNum*sizeof(ull)); memmove(&sort_rec->index[index1+1],&sort_rec->index[index1],moveNum*sizeof(u_long)); sort_rec->dpc[index1]=opc_dpc; sort_rec->index[index1]=real_index; sort_rec->sortedNum ++; return 1; } //LogErr("--rearrange:%lld,%lld,%lld",sort_rec[index1-1].key,key,sort_rec[index1+1].key); return 1; } int Mtp3DeleteRecord(ull key,BYTE nw) //VLR_RECORD vlr_record) { mtp3DPCIndex *sort_rec = &mtp3SortRoutine.nw[nw]; // long long imsi=key; ulong MoveNum; int index=-1; if (sort_rec->sortedNum == 0) { return 0; } index = Mtp3BinSearchValue(0,MAX_ROUTE-1,nw,key); // index = BinSearchIndex(1,vlr_record_number,key); if(index<0 || index>=sort_rec->sortedNum) { // LogMsg("VLR--ERROR!Delete Record index=%ld",index); return 0; } MoveNum = (sort_rec->sortedNum-index) % MAX_ROUTE; memmove(&sort_rec->dpc[index],&sort_rec->dpc[index+1],MoveNum*sizeof(ull)); memmove(&sort_rec->index[index],&sort_rec->index[index+1],MoveNum*sizeof(u_long)); // LogErr("----After del %lld,%lld,%lld",sort_rec[index-1].key,sort_rec[index].key,sort_rec[index+1].key); sort_rec->dpc[sort_rec->sortedNum]=0; sort_rec->index[sort_rec->sortedNum]=0; sort_rec->sortedNum--; return 1; } BYTE mtp_encode_integer(BYTE *buf,u_long val,BYTE value_len) { if(val<128) { if (value_len == 4) { buf[0] = 0; buf[1] = 0; buf[2]=val; return 3; } else { buf[0] = val; return 1; } } else if(val<0x8000) { if (value_len == 4) { buf[0] = 0; buf[1]=val >>8; buf[2]=val & 0xFF; return 3; } else { buf[0]=val; return 1; } } else if(val <0x800000) { buf[0]=val >>16; buf[1]=(val & 0xFF00)>>8; buf[2]=val & 0xFF; return 3; } // else if(val <0x80000000) else { buf[0]=(val & 0xFF0000)>>16; buf[1]=(val & 0xFF00)>>8; buf[2]=val & 0xFF; return 3; } } int mtp3_reset_sccp() { DWORD oid[20] = {1,3,6,1,4,1,1373,2,3,2,3,3,2};//SCCP_OID BYTE value=0; return set_response(13,oid,&value,1); } void del_1dst_from_table(ls_info *ls, WORD dpc_place, BYTE ud_select) { WORD dst_num; int i; switch (ud_select) { case UPDATE_NLS: dst_num = ls->influ_dstnum_asNLS; if (dst_num == 0) return; ls->influ_dstnum_asNLS --; for (i=0; iinflu_dstplace_intable_asNLS[i] == dpc_place) { memcpy(&ls->influ_dstplace_intable_asNLS[i], &ls->influ_dstplace_intable_asNLS[i+1],dst_num-i-1); ls->influ_dstplace_intable_asNLS[dst_num-1] = 0; ls->links_nls_asp_ac_send_flag[dpc_place] = 0x00; return; } } break; case 1: dst_num = ls->influ_dstnum_asALS; if (dst_num == 0) return; ls->influ_dstnum_asALS --; for (i=0; iinflu_dstplace_intable_asALS[i] == dpc_place) { memcpy(&ls->influ_dstplace_intable_asALS[i], &ls->influ_dstplace_intable_asALS[i+1],dst_num-i-1); ls->influ_dstplace_intable_asALS[dst_num-1] = 0; ls->links_als_asp_ac_send_flag[dpc_place] = 0x00; return; } } break; } } void add_1dst_to_table(ls_info *ls, WORD place,BYTE ud_select) { WORD dst_num; switch (ud_select) { case UPDATE_NLS: dst_num = ls->influ_dstnum_asNLS; ls->influ_dstplace_intable_asNLS[dst_num] = place; ls->influ_dstnum_asNLS = dst_num + 1; ls->links_nls_asp_ac_send_flag[place] = 0x00; break; case UPDATE_ALS: dst_num = ls->influ_dstnum_asALS; ls->influ_dstplace_intable_asALS[dst_num] = place; ls->influ_dstnum_asALS = dst_num + 1; ls->links_als_asp_ac_send_flag[place] = 0x00; break; } } void scan_conf_right_or_not(BYTE nw) { static BYTE index=0; BYTE nls; BYTE lsnw; return; nls = mtp3_para->nw[nw].routing[index].normal_ls; if (nls < 128) { lsnw = mtp3_para->ls_pro[nls].nw_id; if ((lsnw != nw) && (mtp3_para->nw[nw].routing[index].dpc != 0)) printf("configure error,nw %d,dpc=%lx normal linkset belong to network %d\n",nw,mtp3_para->nw[nw].routing[index].dpc ,lsnw); } index ++; } void mtp3lite_upd_route_status(WORD chl, BYTE flag) { ls_info *ls; int i; BYTE nw; WORD dpc_index, lsno; lsno = mtp3_para->lk[chl].e1_to_linkset; if (lsno >= MAX_LS) return; ls = &mtp3.ls[lsno]; nw = mtp3_para->ls_pro[lsno].nw_id; for (i = 0; i < ls->influ_dstnum_asNLS; i++) { dpc_index = ls->influ_dstplace_intable_asNLS[i]; if (!flag) mark_normal_linkset_unavailable(&mtp3.nw[nw].routine[dpc_index]); else mark_normal_linkset_available(&mtp3.nw[nw].routine[dpc_index]); if ((mtp3.nw[nw].routine[dpc_index] & 0x0f) == 0x0a)// all road unavailable mark_dstSP_inaccessible(&mtp3.nw[nw].routine[dpc_index]); hmrt_tfrc_update_routing_tables(dpc_index,nw); } } void change_the_whole_ls(WORD lsno,BYTE oldnw,BYTE nw) { ls_info *ls; int i; nw_para *nwpara; BYTE *routine; BYTE ls_available; WORD dpc_index; int added=0; ull opc_dpc=0; ls = &mtp3.ls[lsno]; // printf("oldnw = %d,newnw=%d\n",oldnw,nw); for (i=0;iinflu_dstnum_asNLS;i++) { dpc_index = ls->influ_dstplace_intable_asNLS[i]; mark_normal_linkset_unavailable(&mtp3.nw[oldnw].routine[dpc_index]); if ((mtp3.nw[oldnw].routine[dpc_index] & 0x0f) == 0x0a)// all road unavailable mark_dstSP_inaccessible(&mtp3.nw[oldnw].routine[dpc_index]); hmrt_tfrc_update_routing_tables(dpc_index,oldnw); ls->influ_dstplace_intable_asNLS[i] = 0xff; opc_dpc = mtp3_para->nw[oldnw].routing[dpc_index].opc; opc_dpc = (opc_dpc<<32)| mtp3_para->nw[oldnw].routing[dpc_index].dpc ; Mtp3DeleteRecord(opc_dpc, oldnw); } for (i=0;iinflu_dstnum_asALS;i++) { dpc_index = ls->influ_dstplace_intable_asALS[i]; mark_alternative_linkset_unavailable(&mtp3.nw[oldnw].routine[dpc_index]); if ((mtp3.nw[oldnw].routine[dpc_index] & 0x0f) == 0x0a)// all road unavailable mark_dstSP_inaccessible(&mtp3.nw[oldnw].routine[dpc_index]); hmrt_tfrc_update_routing_tables(dpc_index,oldnw); ls->influ_dstplace_intable_asALS[i] = 0xff; opc_dpc = mtp3_para->nw[oldnw].routing[dpc_index].opc ; opc_dpc = (opc_dpc<<32) | mtp3_para->nw[oldnw].routing[dpc_index].dpc ; Mtp3DeleteRecord(opc_dpc,oldnw); } ls->influ_dstnum_asNLS = 0; ls->influ_dstnum_asALS = 0; if (mtp3.ls[lsno].links_available_t > 0) ls_available = TRUE; else ls_available = FALSE; nwpara = &mtp3_para->nw[nw]; for (i=0;i<256;i++) { if (nwpara->routing[i].dpc == 0) continue; routine = &mtp3.nw[nw].routine[i]; if (nwpara->routing[i].normal_ls == lsno) { if (ls_available == TRUE) mark_normal_linkset_available(routine); else mark_normal_linkset_unavailable(routine); add_1dst_to_table(&mtp3.ls[lsno],i,UPDATE_NLS); Mtp3AddSortRec(nw,nwpara->routing[i].dpc, i, nwpara->routing[i].opc);//??- added = 1; } if ((nwpara->routing[i].alternative_ls == lsno) && (nwpara->routing[i].normal_ls < MAX_LS) ) { if (ls_available == TRUE) mark_alternative_linkset_available(routine); else mark_alternative_linkset_unavailable(routine); add_1dst_to_table(&mtp3.ls[lsno],i,UPDATE_ALS); if (!added) Mtp3AddSortRec(nw,nwpara->routing[i].dpc, i, nwpara->routing[i].opc);//??- } hmrt_tfrc_update_routing_tables(i,nw); added=0; } } void update_ls_influence_dst_table(BYTE nw, long dst, WORD place, WORD nls, WORD als, DWORD rc, long opc)//??- { BYTE *routine; ulong pc_new, rc_new, opc_new; WORD nls_old; WORD als_old; ulong pc_old; WORD nlsnw; WORD alsnw; ull opc_dpc_new=0, opc_dpc_old=0; pc_new = dst;//decode_integer((BYTE*)&dst,4); rc_new = rc;//decode_integer((BYTE*)&rc,4); opc_new = opc;//decode_integer((BYTE*)&opc,4); routine = &mtp3.nw[nw].routine[place]; nls_old = mtp3_para->nw[nw].routing[place].normal_ls; als_old = mtp3_para->nw[nw].routing[place].alternative_ls; pc_old = mtp3_para->nw[nw].routing[place].dpc; nlsnw = mtp3_para->ls_pro[nls].nw_id; alsnw = mtp3_para->ls_pro[als].nw_id; if ((pc_old == pc_new) && (nls_old == nls) && (als_old == als) && (mtp3_para->nw[nw].routing[place].rc == rc_new)&& (mtp3_para->nw[nw].routing[place].opc == opc_new)) return; /* if(opc_new == 0 && pc_new != 0) { if(pc_length(nw) == MTP3_24BIT_PC) opc_new = mtp3_para->nw[nw].opc24; else opc_new = mtp3_para->nw[nw].opc14; } */ opc_dpc_new = opc_new; opc_dpc_new = (opc_dpc_new<<32)|pc_new; opc_dpc_old = mtp3_para->nw[nw].routing[place].opc; opc_dpc_old = (opc_dpc_old<<32)|pc_old; if (pc_old > 0) Mtp3DeleteRecord(opc_dpc_old,nw);//delect this pc from sort table //??- if (pc_new > 0) { if ((nls 0) mark_normal_linkset_available(routine); else mark_normal_linkset_unavailable(routine); if (nls != nls_old) add_1dst_to_table(&mtp3.ls[nls],place,UPDATE_NLS); } else mark_normal_linkset_unavailable(routine); if ((als < MAX_LS) && (nls < MAX_LS) &&// if one spc doesn't has normal linkset,it can not has alternative linkset (alsnw == nw)) { if (mtp3.ls[als].links_available_t > 0) mark_alternative_linkset_available(routine); else mark_alternative_linkset_unavailable(routine); if ((als != als_old) || (nls_old >= MAX_LS) ) { // printf("renew alternative linkset %d,num=%d\n",als,mtp3.ls[als].influ_dstnum_asALS); add_1dst_to_table(&mtp3.ls[als],place,UPDATE_ALS); // printf("renew alternative linkset %d,num=%d\n",als,mtp3.ls[als].influ_dstnum_asALS); } } else mark_alternative_linkset_unavailable(routine); if ((mtp3.nw[nw].routine[place] & 0x0f) == 0x0a) mark_dstSP_inaccessible(routine); hmrt_tfrc_update_routing_tables(place,nw); mtp3_para->nw[nw].routing[place].dpc = pc_new; mtp3_para->nw[nw].routing[place].opc = opc_new; mtp3_para->nw[nw].routing[place].normal_ls = nls; mtp3_para->nw[nw].routing[place].alternative_ls = als; if ( (nls_old < MAX_LS) && (nls_old != nls) ) del_1dst_from_table(&mtp3.ls[nls_old],place,UPDATE_NLS); if ( (als_old < MAX_LS) && (als_old != als) ) del_1dst_from_table(&mtp3.ls[als_old],place,UPDATE_ALS); } if (mtp3_para->ls_pro[nls].ls_op_pc == pc_new) mtp3.ls[nls].adjacent_sp_place = place; mtp3_para->nw[nw].routing[place].dpc = pc_new; mtp3_para->nw[nw].routing[place].opc = opc_new; mtp3_para->nw[nw].routing[place].rc = rc_new; } int mtp3_write_para() { int i; nw_route *ptr=NULL; ls_para *ls_ptr=NULL; lk_pro *lk_ptr=NULL; char tmp_buf[128]={0}; mtpfpConf = fopen(mtpconfile,"w"); if (mtpfpConf == NULL) return -1; fprintf(mtpfpConf,"#MTP3 CONFIGURE FILE\n"); fprintf(mtpfpConf,"\n"); fprintf(mtpfpConf,"[system]\n"); fprintf(mtpfpConf,"mtp3litePort=%04x\n",mtp3_para->mtp3lite_port); fprintf(mtpfpConf,"\n"); fprintf(mtpfpConf,"[internationalNetworkRouting]\n"); fprintf(mtpfpConf,"opc=%06lx\n", mtp3_para->nw[0].opc14); fprintf(mtpfpConf,"pclen=%d\n", mtp3_para->nw[0].pc_len); fprintf(mtpfpConf,"pctype=%d\n", mtp3_para->nw[0].pc_type); Bcd2Str(tmp_buf, mtp3_para->nw[0].local_acn, MAX_ACN_NUM); fprintf(mtpfpConf,"localACN=%s\n", tmp_buf); fprintf(mtpfpConf,"#[index.title.dpc.opc.normal_ls.alter_ls.m3ua_rc.acn]\n"); for(i=0; inw[0].routing[i].title[0]==0) continue; ptr = &mtp3_para->nw[0].routing[i]; Bcd2Str(tmp_buf, ptr->acn, MAX_ACN_NUM); fprintf(mtpfpConf,"[%4d.%s.%06lx.%06lx.%04x.%04x.%08lx.%s]\t\n",i, ptr->title, ptr->dpc, ptr->opc, ptr->normal_ls, ptr->alternative_ls, ptr->rc, tmp_buf); } fprintf(mtpfpConf, "\n"); fprintf(mtpfpConf,"[internationalSpareNetworkRouting]\n"); fprintf(mtpfpConf,"opc=%06lx\n", mtp3_para->nw[1].opc14); fprintf(mtpfpConf,"pclen=%d\n", mtp3_para->nw[1].pc_len); fprintf(mtpfpConf,"pctype=%d\n", mtp3_para->nw[1].pc_type); Bcd2Str(tmp_buf, mtp3_para->nw[1].local_acn, MAX_ACN_NUM); fprintf(mtpfpConf,"localACN=%s\n", tmp_buf); fprintf(mtpfpConf,"#[index.title.dpc.opc.normal_ls.alter_ls.m3ua_rc.acn]\n"); for(i=0; inw[1].routing[i].title[0]==0) continue; ptr = &mtp3_para->nw[1].routing[i]; Bcd2Str(tmp_buf, ptr->acn, MAX_ACN_NUM); fprintf(mtpfpConf,"[%4d.%s.%06lx.%06lx.%04x.%04x.%08lx.%s]\t\n",i, ptr->title, ptr->dpc, ptr->opc, ptr->normal_ls, ptr->alternative_ls, ptr->rc, tmp_buf); } fprintf(mtpfpConf, "\n"); fprintf(mtpfpConf,"[nationalNetworkRouting]\n"); fprintf(mtpfpConf,"opc=%06lx\n", mtp3_para->nw[2].opc14); fprintf(mtpfpConf,"pclen=%d\n", mtp3_para->nw[2].pc_len); fprintf(mtpfpConf,"pctype=%d\n", mtp3_para->nw[2].pc_type); Bcd2Str(tmp_buf, mtp3_para->nw[2].local_acn, MAX_ACN_NUM); fprintf(mtpfpConf,"localACN=%s\n", tmp_buf); fprintf(mtpfpConf,"#[index.title.dpc.opc.normal_ls.alter_ls.m3ua_rc.acn]\n"); for(i=0; inw[2].routing[i].title[0]==0) continue; ptr = &mtp3_para->nw[2].routing[i]; Bcd2Str(tmp_buf, ptr->acn, MAX_ACN_NUM); fprintf(mtpfpConf,"[%4d.%s.%06lx.%06lx.%04x.%04x.%08lx.%s]\t\n",i, ptr->title, ptr->dpc, ptr->opc, ptr->normal_ls, ptr->alternative_ls, ptr->rc, tmp_buf); } fprintf(mtpfpConf, "\n"); fprintf(mtpfpConf,"[nationalSpareNetworkRouting]\n"); fprintf(mtpfpConf,"opc=%06lx\n", mtp3_para->nw[3].opc14); fprintf(mtpfpConf,"pclen=%d\n", mtp3_para->nw[3].pc_len); fprintf(mtpfpConf,"pctype=%d\n", mtp3_para->nw[3].pc_type); Bcd2Str(tmp_buf, mtp3_para->nw[3].local_acn, MAX_ACN_NUM); fprintf(mtpfpConf,"localACN=%s\n", tmp_buf); fprintf(mtpfpConf,"#[index.title.dpc.opc.normal_ls.alter_ls.m3ua_rc.acn]\n"); for(i=0; inw[3].routing[i].title[0]==0) continue; ptr = &mtp3_para->nw[3].routing[i]; Bcd2Str(tmp_buf, ptr->acn, MAX_ACN_NUM); fprintf(mtpfpConf,"[%4d.%s.%06lx.%06lx.%04x.%04x.%08lx.%s]\t\n",i, ptr->title, ptr->dpc, ptr->opc, ptr->normal_ls, ptr->alternative_ls, ptr->rc, tmp_buf); } fprintf(mtpfpConf, "\n"); fprintf(mtpfpConf,"[linkset]\n"); fprintf(mtpfpConf,"#[index.title.admin.nw.dpc.loop_flag.opc]\n"); for(i=0; ils_pro[i].title[0]==0) continue; ls_ptr = &mtp3_para->ls_pro[i]; fprintf(mtpfpConf,"[%4d.%s.%02x.%02x.%06lx.%02x.%06lx]\t\n",i, ls_ptr->title, ls_ptr->admin_state, ls_ptr->nw_id, ls_ptr->ls_op_pc, ls_ptr->loopback_opt, ls_ptr->ls_opc); } fprintf(mtpfpConf, "\n"); fprintf(mtpfpConf,"[link]\n"); fprintf(mtpfpConf,"#[index.title.admin.type.linkset.slc.hostIP.alterIP.sg.iid.mtp3lite_mode.mtp3lite_remoteIP.inactive.inactive_times]\n"); for(i=0; ilk[i].title[0]==0) continue; lk_ptr = &mtp3_para->lk[i]; fprintf(mtpfpConf,"[%4d.%s.%02x.%02x.%04x.%02x.%08lx.%08lx.%04x.%02x.%02x.%08lx.%02x.%02x]\t\n",i, lk_ptr->title, lk_ptr->admin_state,\ lk_ptr->e1_lk_type, lk_ptr->e1_to_linkset, lk_ptr->e1_to_slc, lk_ptr->e1_to_mtp3, lk_ptr->e1_to_alterMTP3,\ lk_ptr->e1_to_sg, lk_ptr->e1_to_iid, lk_ptr->mtp3lite_apl_mode, lk_ptr->remote_ip, lk_ptr->inactive, lk_ptr->inactive_tm);; } fprintf(mtpfpConf, "\n"); fprintf(mtpfpConf, "[signalingGateway]\n"); fprintf(mtpfpConf,"#[index.admin.server.data_ack.sgIP.clientSourceIP.clientSourcePort]\n"); for (i = 0; i < 256; i++) { if(mtp3_para->sg[i].ip==0&&mtp3_para->sg[i].enable==0) continue; fprintf(mtpfpConf, "[%4d.%02X.%02X.%02X.%08X.%08X.%04X.%04X]\t\n",i, mtp3_para->sg[i].enable, mtp3_para->sg[i].server, mtp3_para->sg[i].data_ack, mtp3_para->sg[i].ip, mtp3_para->sg[i].source_ip, mtp3_para->sg[i].source_port, mtp3_para->sg[i].dst_port); } fprintf(mtpfpConf, "\n"); fclose(mtpfpConf); return 1; } int mtp3_write_parameter()//??? { int i,j; int ix4; mtpfpConf = fopen(mtpconfile,"w"); if (mtpfpConf == NULL) return -1; fprintf(mtpfpConf,"#MTP3 CONFIGURE FILE\n"); fprintf(mtpfpConf,"\n"); fprintf(mtpfpConf,"[SERVICE NETWORK SP LEN]\n"); fprintf(mtpfpConf,"[%02x]\n",mtp3_para->nw_pro); fprintf(mtpfpConf,"\n"); fprintf(mtpfpConf,"[MTP3LITE TCP PORT]\n"); fprintf(mtpfpConf,"[%04x]\n",mtp3_para->mtp3lite_port); fprintf(mtpfpConf,"\n"); fprintf(mtpfpConf,"[LOCAL SP]\n"); fprintf(mtpfpConf,"[%06lx]\t[%06lx]\t[%06lx]\t[%06lx]\t\n",mtp3_para->nw[0].opc14, mtp3_para->nw[1].opc14,mtp3_para->nw[2].opc14,mtp3_para->nw[3].opc14); fprintf(mtpfpConf,"[%06lx]\t[%06lx]\t[%06lx]\t[%06lx]\t\n",mtp3_para->nw[0].opc24, mtp3_para->nw[1].opc24,mtp3_para->nw[2].opc24,mtp3_para->nw[3].opc24); fprintf(mtpfpConf,"\n"); /* e1 to linkset */ fprintf(mtpfpConf,"[LINK ATTRIBUTE]\n"); for (i=0; i<256; i++) { ix4 = i*4; for (j=0; j<4; j++) { fprintf(mtpfpConf,"[%02x.%02x.%08lx.%02x.%02x.%02x.%08lx.%02x.%02x.%08lx]\t",mtp3_para->lk[ix4+j].e1_to_linkset, mtp3_para->lk[ix4+j].e1_to_slc,mtp3_para->lk[ix4+j].e1_to_mtp3,mtp3_para->lk[ix4+j].e1_lk_type,mtp3_para->lk[ix4+j].e1_to_sg,mtp3_para->lk[ix4+j].e1_to_iid, mtp3_para->lk[ix4+j].remote_ip,mtp3_para->lk[ix4+j].inactive,mtp3_para->lk[ix4+j].inactive_tm,mtp3_para->lk[ix4+j].e1_to_alterMTP3); } fprintf(mtpfpConf,"\n"); } fprintf(mtpfpConf,"\n"); /* linkset remote sp */ fprintf(mtpfpConf,"[LINKSET ATTRIBUTE]\n"); for (i=0; i<128; i++) { ix4 = i*4; for (j=0; j<4; j++) { if (1) { char ls_reserved[128]={0}; char temp[16]; int k; for (k=0;k<16;k++) { sprintf(temp,"%02x",mtp3_para->ls_pro[ix4+j].ls_reserved[k]); strcat(ls_reserved,temp); } fprintf(mtpfpConf,"[%06lx.%02x.%-16s.%08lx]\t",mtp3_para->ls_pro[ix4+j].ls_op_pc,mtp3_para->ls_pro[ix4+j].admin_state,ls_reserved, mtp3_para->ls_pro[ix4+j].ls_opc); } } fprintf(mtpfpConf,"\n"); } fprintf(mtpfpConf,"\n"); /* SG */ fprintf(mtpfpConf, "[SG ATTRIBUTES]\n"); for (i = 0; i < 64; i++) { ix4 = i * 4; for (j = 0; j < 4; j++) { fprintf(mtpfpConf, "[%02X.%02X.%02X.%08X]\t", mtp3_para->sg[ix4+j].enable, mtp3_para->sg[ix4+j].server, mtp3_para->sg[ix4+j].data_ack, mtp3_para->sg[ix4+j].ip); } fprintf(mtpfpConf, "\n"); } fprintf(mtpfpConf, "\n"); /* NATIONAL NETWORK SP */ fprintf(mtpfpConf,"[NATIONAL NETWORK SP]\n"); for (i=0; i<256; i++) { ix4 = i*4; for (j=0; j<4; j++) { fprintf(mtpfpConf,"[%06lx.%02x.%02x.%08lx.%08lx]\t",mtp3_para->nw[2].routing[ix4+j].dpc,mtp3_para->nw[2].routing[ix4+j].normal_ls, mtp3_para->nw[2].routing[ix4+j].alternative_ls, mtp3_para->nw[2].routing[ix4+j].rc, mtp3_para->nw[2].routing[ix4+j].opc); } fprintf(mtpfpConf,"\n"); } fprintf(mtpfpConf,"\n"); /* NATIONAL NETWORK SPARE SP */ fprintf(mtpfpConf,"[NATIONAL NETWORK SPARE SP]\n"); for (i=0; i<256; i++) { ix4 = i*4; for (j=0; j<4; j++) { fprintf(mtpfpConf,"[%06lx.%02x.%02x.%08lx.%08lx]\t",mtp3_para->nw[3].routing[ix4+j].dpc,mtp3_para->nw[3].routing[ix4+j].normal_ls , mtp3_para->nw[3].routing[ix4+j].alternative_ls , mtp3_para->nw[3].routing[ix4+j].rc, mtp3_para->nw[3].routing[ix4+j].opc); } fprintf(mtpfpConf,"\n"); } fprintf(mtpfpConf,"\n"); /* INTERNATIONAL NETWORK SP */ fprintf(mtpfpConf,"[INTERNATIONAL NETWORK SP]\n"); for (i=0; i<256; i++) { ix4 = i*4; for (j=0; j<4; j++) { fprintf(mtpfpConf,"[%06lx.%02x.%02x.%08lx.%08lx]\t",mtp3_para->nw[0].routing[ix4+j].dpc ,mtp3_para->nw[0].routing[ix4+j].normal_ls , mtp3_para->nw[0].routing[ix4+j].alternative_ls , mtp3_para->nw[0].routing[ix4+j].rc , mtp3_para->nw[0].routing[ix4+j].opc ); } fprintf(mtpfpConf,"\n"); } fprintf(mtpfpConf,"\n"); /* INTERNATIONAL NETWORK SP */ fprintf(mtpfpConf,"[INTERNATIONAL NETWORK SPARE SP]\n"); for (i=0; i<256; i++) { ix4 = i*4; for (j=0; j<4; j++) { fprintf(mtpfpConf,"[%06lx.%02x.%02x.%08lx.%08lx]\t",mtp3_para->nw[1].routing[ix4+j].dpc ,mtp3_para->nw[1].routing[ix4+j].normal_ls , mtp3_para->nw[1].routing[ix4+j].alternative_ls , mtp3_para->nw[1].routing[ix4+j].rc, mtp3_para->nw[1].routing[ix4+j].opc ); } fprintf(mtpfpConf,"\n"); } fprintf(mtpfpConf,"\n"); fprintf(mtpfpConf,"[LOCAL ACN]\n"); for(i=0;ilocalAcn[i]); } fprintf(mtpfpConf,"\n\n"); fprintf(mtpfpConf,"[INTERNATIONAL NETWORK ACN]\n"); for (i=0; i<256; i++) { for (j=0;jnw[0].routing[i].acn[j]); } fprintf(mtpfpConf,"\n"); } fprintf(mtpfpConf,"\n"); fprintf(mtpfpConf,"[INTERNATIONAL NETWORK SPARE ACN]\n"); for (i=0; i<256; i++) { for (j=0;jnw[1].routing[i].acn[j]); } fprintf(mtpfpConf,"\n"); } fprintf(mtpfpConf,"\n"); fprintf(mtpfpConf,"[NATIONAL NETWORK ACN]\n"); for (i=0; i<256; i++) { for (j=0;jnw[2].routing[i].acn[j]); } fprintf(mtpfpConf,"\n"); } fprintf(mtpfpConf,"\n"); fprintf(mtpfpConf,"[NATIONAL NETWORK SPARE ACN]\n"); for (i=0; i<256; i++) { for (j=0;jnw[3].routing[i].acn[j]); } fprintf(mtpfpConf,"\n"); } fprintf(mtpfpConf,"\n"); fclose(mtpfpConf); return 1; } static int issquare(char c) { if ((c=='[') || (c==']') || (c==' ') || (c=='\t')) return 1; return 0; } static int isdot(char c) { if ((c=='.')) return 1; return 0; } int ParseLineWithSquare(char *str, char (*row)[128], int maxrow) { char *pstr = str; int len, index = 0, i; BOOL black = 0; len = strlen(str); for(i = 0; i < len && index < maxrow; i++) { if(issquare(str[i])) { if(black == 0) pstr = str + i + 1; else { str[i] = '\0'; if(strlen(pstr) > 128) pstr[127] = 0; sprintf(row[index++], "%s", pstr); pstr = str + i + 1; } black = 0; } else black = 1; } if(black == 1) { if(strlen(pstr) > 128) pstr[127] = 0; sprintf(row[index++], "%s", pstr); } return index; } int ParseLineWithDot(char *str, char (*row)[128], int maxrow) { char *pstr = str; int len, index = 0, i; BOOL black = 0; len = strlen(str); for(i = 0; i < len && index < maxrow; i++) { if(isdot(str[i])) { // if(black == 0) // pstr = str + i + 1; // else // { str[i] = '\0'; if(strlen(pstr) > 128) pstr[127] = 0; sprintf(row[index++], "%s", pstr); pstr = str + i + 1; // } black = 0; } else black = 1; } if(black == 1) { if(strlen(pstr) > 128) pstr[127] = 0; sprintf(row[index++], "%s", pstr); } return index; } int ReadMtp3NetworkPara(char *s) { char LineInfo[1][128]; int rtn; rtn = ParseLineWithSquare(s, LineInfo, 1); mtp3_para->nw_pro = strtoll(LineInfo[0],NULL,16); mtp3_para->nw[0].pc_len = mtp3_para->nw_pro&1; mtp3_para->nw[0].pc_type = (mtp3_para->nw_pro>>4)&1; mtp3_para->nw[1].pc_len = (mtp3_para->nw_pro>>1)&1; mtp3_para->nw[1].pc_type = (mtp3_para->nw_pro>>5)&1; mtp3_para->nw[2].pc_len = (mtp3_para->nw_pro>>2)&1; mtp3_para->nw[2].pc_type = (mtp3_para->nw_pro>>6)&1; mtp3_para->nw[3].pc_len = (mtp3_para->nw_pro>>3)&1; mtp3_para->nw[3].pc_type = (mtp3_para->nw_pro>>7)&1; return 1; } int ReadMtp3LitePortPara(char *s) { char LineInfo[1][128]; int rtn; rtn = ParseLineWithSquare(s, LineInfo, 1); mtp3_para->mtp3lite_port = strtoll(LineInfo[0],NULL,16); return 1; } int ReadMtp3OPCPara(char *s) { char LineInfo[8][128]; int rtn; int instance; static int Base=0; rtn = ParseLineWithSquare(s, LineInfo, 4);//each line four links if (Base==0) { for (instance=0;instance<4;instance++) { mtp3_para->nw[instance].opc14 = strtoll(LineInfo[instance],NULL,16); mtp3_para->nw[instance].opc24 = mtp3_para->nw[instance].opc14; } } else { /* for (instance=0;instance<4;instance++) { mtp3_para->nw[instance].opc24 = strtoll(LineInfo[instance],NULL,16); } */ } Base++; if (Base > 1) { Base = 0; return 1; } return 0; } int ReadMtp3LinkPara(char *s) { char LineInfo[8][128]; char DetailInfo[10][128]; int rtn; int Instance; static int Base=0; ulong mtp3ip; rtn = ParseLineWithSquare(s, LineInfo, 4);//each line four links for (Instance=0;Instance<4;Instance++) { rtn = ParseLineWithDot(LineInfo[Instance],DetailInfo,10); mtp3_para->lk[Base+Instance].e1_to_linkset = strtoll(DetailInfo[0],NULL,16); mtp3_para->lk[Base+Instance].e1_to_slc = strtoll(DetailInfo[1],NULL,16); mtp3ip = strtoll(DetailInfo[2],NULL,16); if (rtn == 3) { if (mtp3ip == 0xff) mtp3_para->lk[Base+Instance].e1_to_mtp3 = 0xffffffff; else mtp3_para->lk[Base+Instance].e1_to_mtp3 = 0x010012ac | ((mtp3ip & 0xff) << 16); mtp3_para->lk[Base+Instance].e1_lk_type = 0x01; mtp3_para->lk[Base+Instance].e1_to_alterMTP3 = 0xffffffff; } else { mtp3_para->lk[Base+Instance].e1_to_mtp3 = mtp3ip; mtp3_para->lk[Base+Instance].e1_lk_type = strtoll(DetailInfo[3],NULL,16); mtp3_para->lk[Base+Instance].admin_state = mtp3_para->lk[Base+Instance].e1_lk_type &0x1; mtp3_para->lk[Base+Instance].e1_lk_type = mtp3_para->lk[Base+Instance].e1_lk_type>>1; mtp3_para->lk[Base+Instance].e1_to_sg = strtoll(DetailInfo[4],NULL,16); mtp3_para->lk[Base+Instance].e1_to_iid = strtoll(DetailInfo[5],NULL,16); mtp3_para->lk[Base+Instance].remote_ip = strtoll(DetailInfo[6],NULL,16); mtp3_para->lk[Base+Instance].inactive = strtoll(DetailInfo[7],NULL,16); mtp3_para->lk[Base+Instance].inactive_tm = strtoll(DetailInfo[8],NULL,16); mtp3_para->lk[Base+Instance].e1_to_alterMTP3 = strtoll(DetailInfo[9],NULL,16); if(mtp3_para->lk[Base+Instance].e1_to_alterMTP3 == mtp3_para->lk[Base+Instance].e1_to_mtp3) { mtp3_para->lk[Base+Instance].e1_to_alterMTP3 = 0xffffffff; } if(mtp3_para->lk[Base+Instance].admin_state==1) mtp3_para->lk[Base+Instance].title[0]='-'; } #ifdef _INCLUDE_M2UA set_m2ua_link(Base+Instance, (BYTE *) &mtp3_para->lk[Base+Instance]); #endif } Base+=4; if (Base >= MAX_LK) { Base = 0; return 1; } return 0; } int ReadMtp3LinksetPara(char *s) { char LineInfo[8][128]; char DetailInfo[10][128]; int rtn; int Instance; static int Base=0; rtn = ParseLineWithSquare(s, LineInfo, 4);//each line four linksets for (Instance=0;Instance<4;Instance++) { rtn = ParseLineWithDot(LineInfo[Instance],DetailInfo,4); mtp3_para->ls_pro[Base+Instance].ls_op_pc = strtoll(DetailInfo[0],NULL,16); mtp3_para->ls_pro[Base+Instance].nw_id= strtoll(DetailInfo[1],NULL,16); mtp3_para->ls_pro[Base+Instance].admin_state = (mtp3_para->ls_pro[Base+Instance].nw_id>>2) & 0x1; mtp3_para->ls_pro[Base+Instance].nw_id = mtp3_para->ls_pro[Base+Instance].nw_id & 0x3; mtp3_para->ls_pro[Base+Instance].loopback_opt = (mtp3_para->ls_pro[Base+Instance].nw_id>>3) & 0x1; if (rtn == 3) Str2Bcd((BYTE *)mtp3_para->ls_pro[Base+Instance].ls_reserved,DetailInfo[2],16); mtp3_para->ls_pro[Base+Instance].ls_opc = strtoll(DetailInfo[3],NULL,16); if(mtp3_para->ls_pro[Base+Instance].ls_op_pc != 0) mtp3_para->ls_pro[Base+Instance].title[0] = '-'; } Base+=4; if (Base >= MAX_LS) { Base = 0; return 1; } return 0; } int ReadMtp3SGPara(char *s) { char LineInfo[8][128]; char DetailInfo[10][128]; int rtn; int Instance; static int Base=0; rtn = ParseLineWithSquare(s, LineInfo, 4);//each line four linksets for (Instance=0;Instance<4;Instance++) { rtn = ParseLineWithDot(LineInfo[Instance],DetailInfo,4); mtp3_para->sg[Base+Instance].enable = strtoll(DetailInfo[0],NULL,16); mtp3_para->sg[Base+Instance].server = strtoll(DetailInfo[1],NULL,16); mtp3_para->sg[Base+Instance].data_ack = strtoll(DetailInfo[2],NULL,16); mtp3_para->sg[Base+Instance].ip = strtoll(DetailInfo[3],NULL,16); #ifdef _INCLUDE_M2UA set_m2ua_sg(Base+Instance, (BYTE *) &mtp3_para->sg[Base+Instance]); #endif } Base+=4; if (Base >= 256) { Base = 0; return 1; } return 0; } int ReadMtp3NATPara(char *s) { char LineInfo[8][128]; char DetailInfo[10][128]; int rtn; int Instance; static int Base=0; rtn = ParseLineWithSquare(s, LineInfo, 4);//each line four linksets for (Instance=0;Instance<4;Instance++) { rtn = ParseLineWithDot(LineInfo[Instance],DetailInfo,5);//4);//3); mtp3_para->nw[2].routing[Base+Instance].dpc = strtoll(DetailInfo[0],NULL,16); mtp3_para->nw[2].routing[Base+Instance].normal_ls = strtoll(DetailInfo[1],NULL,16); mtp3_para->nw[2].routing[Base+Instance].alternative_ls = strtoll(DetailInfo[2],NULL,16); mtp3_para->nw[2].routing[Base+Instance].rc = strtoll(DetailInfo[3],NULL,16); mtp3_para->nw[2].routing[Base+Instance].opc = strtoll(DetailInfo[4],NULL,16); if(mtp3_para->nw[2].routing[Base+Instance].dpc != 0) mtp3_para->nw[2].routing[Base+Instance].title[0]='-'; } Base+=4; if (Base >= MAX_ROUTE) { Base = 0; return 1; } return 0; } int ReadMtp3NATsPara(char *s) { char LineInfo[8][128]; char DetailInfo[10][128]; int rtn; int Instance; static int Base=0; rtn = ParseLineWithSquare(s, LineInfo, 4);//each line four linksets for (Instance=0;Instance<4;Instance++) { rtn = ParseLineWithDot(LineInfo[Instance],DetailInfo,5); mtp3_para->nw[3].routing[Base+Instance].dpc = strtoll(DetailInfo[0],NULL,16); mtp3_para->nw[3].routing[Base+Instance].normal_ls = strtoll(DetailInfo[1],NULL,16); mtp3_para->nw[3].routing[Base+Instance].alternative_ls = strtoll(DetailInfo[2],NULL,16); mtp3_para->nw[3].routing[Base+Instance].rc = strtoll(DetailInfo[3],NULL,16); mtp3_para->nw[3].routing[Base+Instance].opc = strtoll(DetailInfo[4],NULL,16); if(mtp3_para->nw[3].routing[Base+Instance].dpc != 0) mtp3_para->nw[3].routing[Base+Instance].title[0]='-'; } Base+=4; if (Base >= MAX_ROUTE) { Base = 0; return 1; } return 0; } int ReadMtp3INTPara(char *s) { char LineInfo[8][128]; char DetailInfo[10][128]; int rtn; int Instance; static int Base=0; rtn = ParseLineWithSquare(s, LineInfo, 4);//each line four linksets for (Instance=0;Instance<4;Instance++) { rtn = ParseLineWithDot(LineInfo[Instance],DetailInfo,5); mtp3_para->nw[0].routing[Base+Instance].dpc = strtoll(DetailInfo[0],NULL,16); mtp3_para->nw[0].routing[Base+Instance].normal_ls = strtoll(DetailInfo[1],NULL,16); mtp3_para->nw[0].routing[Base+Instance].alternative_ls = strtoll(DetailInfo[2],NULL,16); mtp3_para->nw[0].routing[Base+Instance].rc = strtoll(DetailInfo[3],NULL,16); mtp3_para->nw[0].routing[Base+Instance].opc = strtoll(DetailInfo[4],NULL,16); if(mtp3_para->nw[0].routing[Base+Instance].dpc != 0) mtp3_para->nw[0].routing[Base+Instance].title[0]='-'; } Base+=4; if (Base >= MAX_ROUTE) { Base = 0; return 1; } return 0; } int ReadMtp3INTsPara(char *s) { char LineInfo[8][128]; char DetailInfo[10][128]; int rtn; int Instance; static int Base=0; rtn = ParseLineWithSquare(s, LineInfo, 4);//each line four linksets for (Instance=0;Instance<4;Instance++) { rtn = ParseLineWithDot(LineInfo[Instance],DetailInfo,5); mtp3_para->nw[1].routing[Base+Instance].dpc = strtoll(DetailInfo[0],NULL,16); mtp3_para->nw[1].routing[Base+Instance].normal_ls = strtoll(DetailInfo[1],NULL,16); mtp3_para->nw[1].routing[Base+Instance].alternative_ls = strtoll(DetailInfo[2],NULL,16); mtp3_para->nw[1].routing[Base+Instance].rc = strtoll(DetailInfo[3],NULL,16); mtp3_para->nw[1].routing[Base+Instance].opc = strtoll(DetailInfo[4],NULL,16); if(mtp3_para->nw[1].routing[Base+Instance].dpc != 0) mtp3_para->nw[1].routing[Base+Instance].title[0]='-'; } Base+=4; if (Base >= MAX_ROUTE) { Base = 0; return 1; } return 0; } int ReadMtp3LocalACNPara(char *s) { char LineInfo[1][128]; int rtn; rtn = ParseLine(s, LineInfo, 1);//each line four linksets AsciiToBcd(mtp3_para->localAcn,LineInfo[0],MAX_ACN_NUM*2); memcpy(mtp3_para->nw[0].local_acn, mtp3_para->localAcn,MAX_ACN_NUM); memcpy(mtp3_para->nw[1].local_acn, mtp3_para->localAcn,MAX_ACN_NUM); memcpy(mtp3_para->nw[2].local_acn, mtp3_para->localAcn,MAX_ACN_NUM); memcpy(mtp3_para->nw[3].local_acn, mtp3_para->localAcn,MAX_ACN_NUM); return 1; } int ReadMtp3INTACNPara(char *s) { char LineInfo[1][128]; int rtn; static int Base=0; rtn = ParseLine(s, LineInfo, 1);//each line four linksets AsciiToBcd(mtp3_para->nw[0].routing[Base].acn,LineInfo[0],MAX_ACN_NUM*2); Base++; if (Base >= 256) { Base = 0; return 1; } return 0; } int ReadMtp3INTsACNPara(char *s) { char LineInfo[1][128]; int rtn; static int Base=0; rtn = ParseLine(s, LineInfo, 1);//each line four linksets AsciiToBcd(mtp3_para->nw[1].routing[Base].acn,LineInfo[0],MAX_ACN_NUM*2); Base++; if (Base >= 256) { Base = 0; return 1; } return 0; } int ReadMtp3NATACNPara(char *s) { char LineInfo[1][128]; int rtn; static int Base=0; rtn = ParseLine(s, LineInfo, 1);//each line four linksets AsciiToBcd(mtp3_para->nw[2].routing[Base].acn ,LineInfo[0],MAX_ACN_NUM*2); Base++; if (Base >= 256) { Base = 0; return 1; } return 0; } int ReadMtp3NATSACNPara(char *s) { char LineInfo[1][128]; int rtn; static int Base=0; rtn = ParseLine(s, LineInfo, 1);//each line four linksets AsciiToBcd(mtp3_para->nw[3].routing[Base].acn ,LineInfo[0],MAX_ACN_NUM*2); Base++; if (Base >= 256) { Base = 0; return 1; } return 0; } int ReadMtp3SystemPara(char *s) { char LineInfo[1][128]; int rtn; rtn = ParseLine(s, LineInfo, 1); if(strstr(LineInfo[0], "mtp3litePort=")!=NULL) mtp3_para->mtp3lite_port = strtol(&LineInfo[0][13],NULL,16); return 1; } int ReadMtp3IntNWPara(char *s) { char LineInfo[8][128]; char DetailInfo[10][128]; int rtn; int Instance; u8 nw = 0; nw_route *ptr; if(strstr(s, "opc=")!=NULL) { mtp3_para->nw[nw].opc14 = strtoll(s+4, NULL, 16); mtp3_para->nw[nw].opc24 = mtp3_para->nw[nw].opc14; return 0; } else if(strstr(s, "pclen=")!=NULL) { mtp3_para->nw[nw].pc_len = strtoll(s+6, NULL, 16); return 0; } else if(strstr(s, "pctype=")!=NULL) { mtp3_para->nw[nw].pc_type = strtoll(s+7, NULL, 16); return 0; } else if(strstr(s, "localACN=")!=NULL) { Str2Bcd(mtp3_para->nw[nw].local_acn, s+9, MAX_ACN_NUM); return 0; } //route unit rtn = ParseLineWithSquare(s, LineInfo, 1);//each line four linksets rtn = ParseLineWithDot(LineInfo[0],DetailInfo,8); Instance = strtoll(DetailInfo[0],NULL,10); if(Instance >= MAX_ROUTE) { printf("mtp3 int nw route para index error!\n"); return 0; } ptr = &mtp3_para->nw[nw].routing[Instance]; strncpy(ptr->title, DetailInfo[1], 16); ptr->dpc = strtoll(DetailInfo[2],NULL,16); ptr->opc = strtoll(DetailInfo[3],NULL,16); ptr->normal_ls = strtoll(DetailInfo[4],NULL,16); ptr->alternative_ls = strtoll(DetailInfo[5],NULL,16); ptr->rc = strtoll(DetailInfo[6],NULL,16); AsciiToBcd(ptr->acn ,DetailInfo[7],MAX_ACN_NUM*2); if(ptr->dpc != 0 && ptr->title[0]==0) ptr->title[0]='-'; return 0; } int ReadMtp3IntsNWPara(char *s) { char LineInfo[8][128]; char DetailInfo[10][128]; int rtn; int Instance; u8 nw = 1; nw_route *ptr; if(strstr(s, "opc=")!=NULL) { mtp3_para->nw[nw].opc14 = strtoll(s+4, NULL, 16); mtp3_para->nw[nw].opc24 = mtp3_para->nw[nw].opc14; return 0; } else if(strstr(s, "pclen=")!=NULL) { mtp3_para->nw[nw].pc_len = strtoll(s+6, NULL, 16); return 0; } else if(strstr(s, "pctype=")!=NULL) { mtp3_para->nw[nw].pc_type = strtoll(s+7, NULL, 16); return 0; } else if(strstr(s, "localACN=")!=NULL) { Str2Bcd(mtp3_para->nw[nw].local_acn, s+9, MAX_ACN_NUM); return 0; } //route unit rtn = ParseLineWithSquare(s, LineInfo, 1);//each line four linksets rtn = ParseLineWithDot(LineInfo[0],DetailInfo,8); Instance = strtoll(DetailInfo[0],NULL,10); if(Instance >= MAX_ROUTE) { printf("mtp3 ints nw route para index error!\n"); return 0; } ptr = &mtp3_para->nw[nw].routing[Instance]; strncpy(ptr->title, DetailInfo[1], 16); ptr->dpc = strtoll(DetailInfo[2],NULL,16); ptr->opc = strtoll(DetailInfo[3],NULL,16); ptr->normal_ls = strtoll(DetailInfo[4],NULL,16); ptr->alternative_ls = strtoll(DetailInfo[5],NULL,16); ptr->rc = strtoll(DetailInfo[6],NULL,16); AsciiToBcd(ptr->acn ,DetailInfo[7],MAX_ACN_NUM*2); if(ptr->dpc != 0 && ptr->title[0]==0) ptr->title[0]='-'; return 0; } int ReadMtp3NaNWPara(char *s) { char LineInfo[8][128]; char DetailInfo[10][128]; int rtn; int Instance; u8 nw = 2; nw_route *ptr; if(strstr(s, "opc=")!=NULL) { mtp3_para->nw[nw].opc14 = strtoll(s+4, NULL, 16); mtp3_para->nw[nw].opc24 = mtp3_para->nw[nw].opc14; return 0; } else if(strstr(s, "pclen=")!=NULL) { mtp3_para->nw[nw].pc_len = strtoll(s+6, NULL, 16); return 0; } else if(strstr(s, "pctype=")!=NULL) { mtp3_para->nw[nw].pc_type = strtoll(s+7, NULL, 16); return 0; } else if(strstr(s, "localACN=")!=NULL) { Str2Bcd(mtp3_para->nw[nw].local_acn, s+9, MAX_ACN_NUM); return 0; } //route unit rtn = ParseLineWithSquare(s, LineInfo, 1);//each line four linksets rtn = ParseLineWithDot(LineInfo[0],DetailInfo,8); Instance = strtoll(DetailInfo[0],NULL,10); if(Instance >= MAX_ROUTE) { printf("mtp3 na nw route para index error!\n"); return 0; } ptr = &mtp3_para->nw[nw].routing[Instance]; strncpy(ptr->title, DetailInfo[1], 16); ptr->dpc = strtoll(DetailInfo[2],NULL,16); ptr->opc = strtoll(DetailInfo[3],NULL,16); ptr->normal_ls = strtoll(DetailInfo[4],NULL,16); ptr->alternative_ls = strtoll(DetailInfo[5],NULL,16); ptr->rc = strtoll(DetailInfo[6],NULL,16); AsciiToBcd(ptr->acn ,DetailInfo[7],MAX_ACN_NUM*2); if(ptr->dpc != 0 && ptr->title[0]==0) ptr->title[0]='-'; return 0; } int ReadMtp3NasNWPara(char *s) { char LineInfo[8][128]; char DetailInfo[10][128]; int rtn; int Instance; u8 nw = 3; nw_route *ptr; if(strstr(s, "opc=")!=NULL) { mtp3_para->nw[nw].opc14 = strtoll(s+4, NULL, 16); mtp3_para->nw[nw].opc24 = mtp3_para->nw[nw].opc14; return 0; } else if(strstr(s, "pclen=")!=NULL) { mtp3_para->nw[nw].pc_len = strtoll(s+6, NULL, 16); return 0; } else if(strstr(s, "pctype=")!=NULL) { mtp3_para->nw[nw].pc_type = strtoll(s+7, NULL, 16); return 0; } else if(strstr(s, "localACN=")!=NULL) { Str2Bcd(mtp3_para->nw[nw].local_acn, s+9, MAX_ACN_NUM); return 0; } //route unit rtn = ParseLineWithSquare(s, LineInfo, 1);//each line four linksets rtn = ParseLineWithDot(LineInfo[0],DetailInfo,8); Instance = strtoll(DetailInfo[0],NULL,10); if(Instance >= MAX_ROUTE) { printf("mtp3 na nw route para index error!\n"); return 0; } ptr = &mtp3_para->nw[nw].routing[Instance]; strncpy(ptr->title, DetailInfo[1], 16); ptr->dpc = strtoll(DetailInfo[2],NULL,16); ptr->opc = strtoll(DetailInfo[3],NULL,16); ptr->normal_ls = strtoll(DetailInfo[4],NULL,16); ptr->alternative_ls = strtoll(DetailInfo[5],NULL,16); ptr->rc = strtoll(DetailInfo[6],NULL,16); AsciiToBcd(ptr->acn ,DetailInfo[7],MAX_ACN_NUM*2); if(ptr->dpc != 0 && ptr->title[0]==0) ptr->title[0]='-'; return 0; } int ReadMtp3LsPara(char * s) { char LineInfo[8][128]; char DetailInfo[10][128]; int rtn; int Instance; ls_para *ptr; rtn = ParseLineWithSquare(s, LineInfo, 1);//each line four linksets rtn = ParseLineWithDot(LineInfo[0],DetailInfo, 7); Instance = strtoll(DetailInfo[0],NULL,10); if(Instance >= MAX_LS) { printf("mtp3 na nw route para index error!\n"); return 0; } ptr = &mtp3_para->ls_pro[Instance]; strncpy(ptr->title, DetailInfo[1], 16); ptr->admin_state = strtoll(DetailInfo[2],NULL,16); ptr->nw_id = strtoll(DetailInfo[3],NULL,16); ptr->ls_op_pc = strtoll(DetailInfo[4],NULL,16); ptr->loopback_opt = strtoll(DetailInfo[5],NULL,16); ptr->ls_opc = strtoll(DetailInfo[6],NULL,16); if(ptr->title[0]==0 && ptr->ls_op_pc != 0) ptr->title[0] = '-'; return 0; } int ReadMtp3LkPara(char * s) { char LineInfo[8][128]; char DetailInfo[15][128]; int rtn; int Instance; lk_pro *ptr; rtn = ParseLineWithSquare(s, LineInfo, 1);//each line four linksets rtn = ParseLineWithDot(LineInfo[0],DetailInfo, 14); Instance = strtoll(DetailInfo[0],NULL,10); if(Instance >= MAX_LK) { printf("mtp3 na nw route para index error!\n"); return 0; } ptr = &mtp3_para->lk[Instance]; strncpy(ptr->title, DetailInfo[1], 16); ptr->admin_state = strtoll(DetailInfo[2],NULL,16); ptr->e1_lk_type = strtoll(DetailInfo[3],NULL,16); ptr->e1_to_linkset = strtoll(DetailInfo[4],NULL,16); ptr->e1_to_slc = strtoll(DetailInfo[5],NULL,16); ptr->e1_to_mtp3 = strtoll(DetailInfo[6],NULL,16); ptr->e1_to_alterMTP3 = strtoll(DetailInfo[7],NULL,16); ptr->e1_to_sg = strtoll(DetailInfo[8],NULL,16); ptr->e1_to_iid = strtoll(DetailInfo[9],NULL,16); ptr->mtp3lite_apl_mode = strtoll(DetailInfo[10],NULL,16); ptr->remote_ip = strtoll(DetailInfo[11],NULL,16); ptr->inactive = strtoll(DetailInfo[12],NULL,16); ptr->inactive_tm = strtoll(DetailInfo[13],NULL,16); #ifdef _INCLUDE_M2UA set_m2ua_link(Instance, (BYTE *) &mtp3_para->lk[Instance]); #endif if(ptr->admin_state != 0 && ptr->title[0]==0) ptr->title[0]='-'; return 0; } int ReadMtp3SgPara(char * s) { char LineInfo[10][128]={{0}, {0}}; char DetailInfo[10][128]={{0}, {0}}; int rtn; int Instance; sg_para *ptr; rtn = ParseLineWithSquare(s, LineInfo, 1);//each line four linksets rtn = ParseLineWithDot(LineInfo[0],DetailInfo, 8); Instance = strtoll(DetailInfo[0],NULL,10); if(Instance >= 256) { printf("mtp3 na nw route para index error!\n"); return 0; } ptr = &mtp3_para->sg[Instance]; ptr->enable = strtoll(DetailInfo[1],NULL,16); ptr->server = strtoll(DetailInfo[2],NULL,16); ptr->data_ack = strtoll(DetailInfo[3],NULL,16); ptr->ip = strtoll(DetailInfo[4],NULL,16); ptr->source_ip = strtoll(DetailInfo[5],NULL,16); ptr->source_port = strtoll(DetailInfo[6],NULL,16); ptr->dst_port = strtoll(DetailInfo[7],NULL,16); #ifdef _INCLUDE_M2UA set_m2ua_sg(Instance, (BYTE *) &mtp3_para->sg[Instance]); #endif return 0; } void mtp3_readpara_from_disk() { char s[1024]={0}; int len; BYTE state = 0; FILE *fp; fp = fopen(mtpconfile,"rb"); if (fp==NULL) { printf("mtp3 config file %s missed!!\n",mtpconfile); return; } s[0] = 0; while ( fgets(s,1024,fp) != (char *)0 ) { if ( (int *)strchr(s,'#') != NULL ) continue; if ( (len=strlen(s))==0 ) continue; if(s[0]=='\n')continue; if(strstr(s,"[system]") != NULL) { state = 21; continue; } else if(strstr(s,"[internationalNetworkRouting]") != NULL) { state = 22; continue; } else if(strstr(s,"[internationalSpareNetworkRouting]") != NULL) { state = 23; continue; } else if(strstr(s,"[nationalNetworkRouting]") != NULL) { state = 24; continue; } else if(strstr(s,"[nationalSpareNetworkRouting]") != NULL) { state = 25; continue; } else if(strstr(s,"[linkset]") != NULL) { state = 26; continue; } else if(strstr(s,"[link]") != NULL) { state = 27; continue; } else if(strstr(s,"[signalingGateway]") != NULL) { state = 28; continue; } else if ( strstr(s,"[SERVICE NETWORK SP LEN]") != NULL ) { state = 1; continue; } else if ( strstr(s,"[MTP3LITE TCP PORT]") != NULL ) { state = 2; continue; } else if ( strstr(s,"[LOCAL SP]") != NULL ) { state = 3; continue; } else if ( strstr(s,"[LINK ATTRIBUTE]") != NULL ) { state = 4; continue; } else if ( strstr(s,"[LINKSET ATTRIBUTE]") != NULL ) { state = 5; continue; } else if ( strstr(s,"[SG ATTRIBUTES]") != NULL ) { state = 6; continue; } else if ( strstr(s,"[NATIONAL NETWORK SP]") != NULL ) { state = 7; continue; } else if ( strstr(s,"[NATIONAL NETWORK SPARE SP]") != NULL ) { state = 8; continue; } else if ( strstr(s,"[INTERNATIONAL NETWORK SP]") != NULL ) { state = 9; continue; } else if ( strstr(s,"[INTERNATIONAL NETWORK SPARE SP]") != NULL ) { state = 10; continue; } else if ( strstr(s,"[LOCAL ACN]") != NULL ) { state = 11; continue; } else if ( strstr(s,"[INTERNATIONAL NETWORK ACN]") != NULL ) { state = 12; continue; } else if ( strstr(s,"[INTERNATIONAL NETWORK SPARE ACN]") != NULL ) { state = 13; continue; } else if ( strstr(s,"[NATIONAL NETWORK ACN]") != NULL ) { state = 14; continue; } else if ( strstr(s,"[NATIONAL NETWORK SPARE ACN]") != NULL ) { state = 15; continue; } switch (state) { case 1: if (ReadMtp3NetworkPara(s)) state = 0; break; case 2: if (ReadMtp3LitePortPara(s)) state = 0; break; case 3: if (ReadMtp3OPCPara(s)) state = 0; break; case 4: if (ReadMtp3LinkPara(s)) state = 0; break; case 5: if (ReadMtp3LinksetPara(s)) state = 0; break; case 6: if (ReadMtp3SGPara(s)) state = 0; break; case 7: if (ReadMtp3NATPara(s)) state = 0; break; case 8: if (ReadMtp3NATsPara(s)) state = 0; break; case 9: if (ReadMtp3INTPara(s)) state = 0; break; case 10: if (ReadMtp3INTsPara(s)) state = 0; break; case 11: if (ReadMtp3LocalACNPara(s)) state = 0; break; case 12: if (ReadMtp3INTACNPara(s)) state = 0; break; case 13: if (ReadMtp3INTsACNPara(s)) state = 0; break; case 14: if (ReadMtp3NATACNPara(s)) state = 0; break; case 15: if (ReadMtp3NATSACNPara(s)) state = 0; break; case 21: if(ReadMtp3SystemPara( s)) state = 0; break; case 22: if(ReadMtp3IntNWPara(s)) state = 0; break; case 23: if(ReadMtp3IntsNWPara(s)) state = 0; break; case 24: if(ReadMtp3NaNWPara(s)) state = 0; break; case 25: if(ReadMtp3NasNWPara(s)) state = 0; break; case 26: if(ReadMtp3LsPara(s)) state = 0; break; case 27: if(ReadMtp3LkPara(s)) state = 0; break; case 28: if(ReadMtp3SgPara(s)) state = 0; break; default: break; } } fclose(fp); } void mtp3_setlink_to_IDLE(WORD link) { WORD oldls; BYTE oldslc; ulong oldip; BYTE oldtp; oldls = mtp3_para->lk[link].e1_to_linkset; oldslc = mtp3_para->lk[link].e1_to_slc; oldip = mtp3_para->lk[link].e1_to_mtp3; oldtp = mtp3_para->lk[link].e1_lk_type; if (mtp3ObjState.link_l3_state[link] == AVAILABLE) { if ((MTP3_LINK_TYPE(link) == LKTYPE_MTP3_LITE) && // Not MTP3LITE (mtp3_para->lk[link].admin_state& 0x01)) // Enabled {//sccp lite link deactive_mtp3lite_lk(link); } else if((MTP3_LINK_TYPE(link) == LKTYPE_M3UA) && // Not M3UA (mtp3_para->lk[link].admin_state& 0x01)) // Enabled {//sccp lite link deactive_m3ua_lk(link); } else { mtp3ObjInput.sltc_input[link] = SLTC_STOP; sltc_proc(link); init_lsac_state[link] = TRUE; lsac_proc(link); init_tlac_state[link] = TRUE; tlac_proc(link); if (mtp3ObjState.link_l3_state[link] == AVAILABLE) otherMTP3_managed_link_unavailable(link); mtp3ObjState.link_l2_state[link] = UNAVAILABLE; mtp3ObjState.link_l3_state[link] = UNAVAILABLE; } } if (mtp3ObjState.lk_configured[link] == PARA_CONFIGURED) { mtp3.ls[oldls].linksNum_configured--; ls_slc[oldls*16+oldslc] = 0xff; update_sls_to_link_table(oldls); } mtp3ObjState.lk_configured[link] = PARA_NOT_CONFIGURED; // printf("link %d update para,new ls=%d,new slc = %d,new ip=%lx\n",link,newls,newslc,newip); } int mtp_setmib(BYTE oidlen, DWORD *oid, BYTE *pdata,WORD datalen) { int instance; ulong pc; BYTE command; int ls; int slc; ulong ip; ulong ip1; int tp; int i; ulong oldpc, opc; WORD old_lsnw; WORD new_lsnw; ulong oldpar, rc; BOOL para_changed=0; if ( oidlen < MTP3_OID_LEN) { printf("set failed,object id length not correct\n"); return -1; } mtp3EnableSaveFlag(); if ( oid[MTP3_OID_LEN] == 2 )/* configure */ { switch (oid[MTP3_OID_LEN+1]) { case 2: case 3: case 4: case 5: switch(oid[MTP3_OID_LEN+2]) { case 1: oldpar = mtp3_para->nw[oid[MTP3_OID_LEN+1]-2].opc14; SET_INTEGER(mtp3_para->nw[oid[MTP3_OID_LEN+1]-2].opc14); mtp3_para->nw[oid[MTP3_OID_LEN+1]-2].opc24 = mtp3_para->nw[oid[MTP3_OID_LEN+1]-2].opc14; if (oldpar != mtp3_para->nw[oid[MTP3_OID_LEN+1]-2].opc14) { mtp3_reset_sccp(); mtp3_delete_opc(oid[MTP3_OID_LEN+1]-2,oldpar); } return datalen; case 2: SET_INTEGER(mtp3_para->nw[oid[MTP3_OID_LEN+1]-2].pc_len); mtp3_reset_sccp(); return datalen; case 3: SET_INTEGER(mtp3_para->nw[oid[MTP3_OID_LEN+1]-2].pc_type); mtp3_reset_sccp(); return datalen; case 4: SET_OPAQUE(mtp3_para->nw[oid[MTP3_OID_LEN+1]-2].local_acn, MAX_ACN_NUM); return datalen; default: break; } break; default: break; } switch (oid[MTP3_OID_LEN+1]) { case 1:/* sp/stp */ break; case 2:/* 14/24bit (for four service networks) */ oldpar = mtp3_para->nw_pro; mtp3_para->nw_pro = decode_integer(pdata,datalen); if (oldpar != mtp3_para->nw_pro) mtp3_reset_sccp(); return 1; case 3:/* opc */ memcpy(&pc,pdata,4); pc = pc << 8; switch (oid[MTP3_OID_LEN+2]) { case 1: oldpar = mtp3_para->nw[0].opc14; mtp3_para->nw[0].opc14 = decode_integer((BYTE*)&pc,4); if (oldpar != mtp3_para->nw[0].opc14) { mtp3_reset_sccp(); mtp3_delete_opc(0, mtp3_para->nw[0].opc14); } return 3; case 2: oldpar = mtp3_para->nw[1].opc14; mtp3_para->nw[1].opc14 = decode_integer((BYTE*)&pc,4); if (oldpar != mtp3_para->nw[1].opc14) { mtp3_reset_sccp(); mtp3_delete_opc(1, mtp3_para->nw[1].opc14); } return 3; case 3: oldpar = mtp3_para->nw[2].opc14; mtp3_para->nw[2].opc14 = decode_integer((BYTE*)&pc,4); if (oldpar != mtp3_para->nw[2].opc14) { mtp3_reset_sccp(); mtp3_delete_opc(2, mtp3_para->nw[2].opc14); } return 3; case 4: oldpar = mtp3_para->nw[3].opc14; mtp3_para->nw[3].opc14 = decode_integer((BYTE*)&pc,4); if (oldpar != mtp3_para->nw[3].opc14) { mtp3_reset_sccp(); mtp3_delete_opc(3, mtp3_para->nw[3].opc14); } return 3; case 5: oldpar = mtp3_para->nw[0].opc24; mtp3_para->nw[0].opc24 = decode_integer((BYTE*)&pc,4); if (oldpar != mtp3_para->nw[0].opc24) { mtp3_reset_sccp(); mtp3_delete_opc(0, mtp3_para->nw[0].opc24); } return 3; case 6: oldpar = mtp3_para->nw[1].opc24; mtp3_para->nw[1].opc24 = decode_integer((BYTE*)&pc,4); if (oldpar != mtp3_para->nw[1].opc24) { mtp3_reset_sccp(); mtp3_delete_opc(1, mtp3_para->nw[1].opc24); } return 3; case 7: oldpar = mtp3_para->nw[2].opc24; mtp3_para->nw[2].opc24 = decode_integer((BYTE*)&pc,4); if (oldpar != mtp3_para->nw[2].opc24) { mtp3_reset_sccp(); mtp3_delete_opc(2, mtp3_para->nw[2].opc24); } return 3; case 8: oldpar = mtp3_para->nw[3].opc24; mtp3_para->nw[3].opc24 = decode_integer((BYTE*)&pc,4); if (oldpar != mtp3_para->nw[3].opc24) { mtp3_reset_sccp(); mtp3_delete_opc(3, mtp3_para->nw[3].opc24); } return 3; default: return -1; } break; case 4:/* linkset */ instance = oid[MTP3_OID_LEN+3]; if (instance > 127) return -1; switch (oid[MTP3_OID_LEN+2]) { case 1: oldpc = mtp3_para->ls_pro[instance].ls_op_pc; old_lsnw = mtp3_para->ls_pro[instance].nw_id; new_lsnw = pdata[3] & 3; memcpy(&pc,pdata,4); memcpy(&opc, &pdata[4], 4); pc = pc << 8; mtp3_para->ls_pro[instance].ls_op_pc = decode_integer((BYTE*)&pc,4); /* linkset adjacent sp */ mtp3_para->ls_pro[instance].nw_id= pdata[3]; memcpy(&mtp3_para->ls_pro[instance].ls_reserved,&pdata[4],16); if (old_lsnw != new_lsnw) { change_the_whole_ls(instance,old_lsnw,new_lsnw); } if ((oldpc != mtp3_para->ls_pro[instance].ls_op_pc) || (old_lsnw != new_lsnw) ) { pc = mtp3_para->ls_pro[instance].ls_op_pc; for (i=0;inw[new_lsnw].routing[i].dpc == pc && mtp3_para->nw[new_lsnw].routing[i].opc == opc)//??? { mtp3.ls[instance].adjacent_sp_place = i; return 4; } } // printf("not found pc in table\n"); mtp3.ls[instance].adjacent_sp_place = 0xffff; } return 20; default: return -1; } break; case 5:/* link */ instance = oid[MTP3_OID_LEN+3]; switch (oid[MTP3_OID_LEN+2]) { case 1:/* e1 to linkset */ ls = pdata[0]; slc = pdata[1]; memcpy(&ip,&pdata[2],4); memcpy(&ip1,&pdata[15],4); // ip = pdata[2]; tp = pdata[6]; if(ip == ip1 && ip1 != 0xffffff) {//ip can not be same as ip1 ip1 = 0xffffffff; memcpy(&pdata[15], &ip1, 4); } if (ls!=mtp3_para->lk[instance].e1_to_linkset || slc!=mtp3_para->lk[instance].e1_to_slc || ip!=mtp3_para->lk[instance].e1_to_mtp3 || ip1!=mtp3_para->lk[instance].e1_to_alterMTP3 || tp != mtp3_para->lk[instance].e1_lk_type) { mtp3_setlink_to_IDLE(instance); para_changed = 1; } if (datalen<19) memcpy((BYTE *)&mtp3_para->lk[instance].e1_to_linkset, pdata, 15); else memcpy((BYTE *)&mtp3_para->lk[instance].e1_to_linkset, pdata, 19); mtp3ObjState.link_type[instance] = mtp3_para->lk[instance].e1_lk_type; if (para_changed) { if (update_ls_slc_table(instance) == 1) { update_sls_to_link_table(ls); MTP3_LinkIP_List(mtp3_para->lk[instance].e1_to_mtp3,1); MTP3_LinkIP_List(mtp3_para->lk[instance].e1_to_alterMTP3,1); } } #ifdef _INCLUDE_M2UA set_m2ua_link(instance & 0xff, pdata); #endif return 19; case 2:/* link command */ mtp3ObjState.lk_command[instance] = pdata[0]; if (mtp3ObjState.lk_mtp3[instance] != mtp3_localip) return 1; if (MTP3_LINK_TYPE(instance) == LKTYPE_MTP3_LITE) { if (pdata[0]==0)//disable deactive_mtp3lite_lk(instance); return 1; } else if (MTP3_LINK_TYPE(instance) == LKTYPE_M3UA) { if (pdata[0]==0)//disable deactive_m3ua_lk(instance); return 1; } else { command = pdata[0]; if (command < 2) { mtp3ObjInput.lsac_input_from_mgmt[instance] = command; return 1; } else if (command < 4) { mtp3ObjInput.tlac_input_from_mgmt[instance] = command - 1; return 1; } else return -1; } case 3:/* MTP3LITE TCP Port */ mtp3_para->mtp3lite_port = pdata[1]; mtp3_para->mtp3lite_port = (mtp3_para->mtp3lite_port << 8) | pdata[0]; return 2; default: return -1; } break; case 6:/* routine table */ instance = oid[MTP3_OID_LEN+3]; memcpy(&pc,pdata,4); memcpy(&rc,&pdata[5],4); pc = pc << 8; memcpy(&opc, &pdata[9], 4); if ((oid[MTP3_OID_LEN+2] > 4) || (oid[MTP3_OID_LEN+2] < 1)) return -1; update_ls_influence_dst_table((oid[MTP3_OID_LEN+2]-1),pc,instance,pdata[3],pdata[4], rc, opc); return 13; case 7:/* dpc->acn */ instance = oid[MTP3_OID_LEN+3]; if (oid[MTP3_OID_LEN+2] == 1) { memcpy(mtp3_para->localAcn,pdata,MAX_ACN_NUM); } else if ((oid[MTP3_OID_LEN+2] > 1) && (oid[MTP3_OID_LEN+2] < 6)) { memcpy(mtp3_para->nw[oid[MTP3_OID_LEN+2]-2].routing[instance].acn,pdata,MAX_ACN_NUM); } else return -1; return MAX_ACN_NUM; case 8:/* timer */ instance = oid[MTP3_OID_LEN+3]; switch (oid[MTP3_OID_LEN+2]) { case 1:/* link timer */ memcpy(&mtp3_para->lt[instance].t1,pdata,10); update_timer(instance); return 10; default: return -1; } return -1; case 9:/* sg */ instance = oid[MTP3_OID_LEN+2]; memcpy(&mtp3_para->sg[instance],pdata,7); #ifdef _INCLUDE_M2UA set_m2ua_sg(instance & 0xff, pdata); return 7; #else return 7; #endif default: return -1; } return -1; } else if (oid[MTP3_OID_LEN] == 3)/* status */ { switch (oid[MTP3_OID_LEN+1]) { case 7: case 8:/* command */ switch (pdata[0]) { case 1: reset_mtp3(); break; case 2: printf("save parameter\n"); return mtp3_write_para(); break; case 3://load data mtp3_reload_data(); break; default: break; } return 1; default: return -1; } } else return -1; } void mtp3_data_reverse(BYTE *pdata,BYTE *csta,BYTE len,BYTE data_type) { int i; int j=0; for (i=0; i 15) temp = 15; mtp3_measure.measure[portion_num].lk_measure1[instance][i] = temp; } break; case 1: temp = mtp3_measure.measure[portion_num].ls_measure[instance][0]; temp = (temp + 3) / 6; if (temp > 15) temp = 15; mtp3_measure.measure[portion_num].ls_measure[instance][0] = temp; temp = mtp3_measure.measure[portion_num].ls_measure[instance][6]; temp = (temp + 3) / 6; if (temp > 15) temp = 15; mtp3_measure.measure[portion_num].ls_measure[instance][6] = temp; break; default: break; } } int mtp_getmib(BYTE oidlen, DWORD *oid, BYTE *pdata,BYTE *vartype) { /* 1.3.6.1.4.1.1373.1.1.2.2.2.2 */ unsigned int instance; BYTE portion_num=0; ulong timestamp; ulong get_rc=0; int datalen=-1; if ( oidlen < 12 ) { printf("get fail,object id not correct\n"); return -1; } if ( oid[MTP3_OID_LEN] == 2 )/* configure */ { switch (oid[MTP3_OID_LEN+1]) { case 2: case 3: case 4: case 5: switch(oid[MTP3_OID_LEN+2]) { case 1: GET_INTEGER(mtp3_para->nw[oid[MTP3_OID_LEN+1]-2].opc14); return datalen; case 2: GET_INTEGER(mtp3_para->nw[oid[MTP3_OID_LEN+1]-2].pc_len); return datalen; case 3: GET_INTEGER(mtp3_para->nw[oid[MTP3_OID_LEN+1]-2].pc_type); return datalen; case 4: GET_OPAQUE(mtp3_para->nw[oid[MTP3_OID_LEN+1]-2].local_acn, MAX_ACN_NUM); return datalen; default: break; } break; default: break; } switch (oid[MTP3_OID_LEN+1]) { case 1:/* sp/stp */ return -1; case 2:/* 14/24bit (for four service networks) */ *vartype = 4; return mtp_encode_integer(pdata,mtp3_para->nw_pro,1); case 3:/* opc */ *vartype = 4; switch (oid[MTP3_OID_LEN+2]) { case 1: return mtp_encode_integer(pdata,mtp3_para->nw[0].opc14,4); case 2: return mtp_encode_integer(pdata,mtp3_para->nw[1].opc14,4); case 3: return mtp_encode_integer(pdata,mtp3_para->nw[2].opc14,4); case 4: return mtp_encode_integer(pdata,mtp3_para->nw[3].opc14,4); case 5: return mtp_encode_integer(pdata,mtp3_para->nw[0].opc24,4); case 6: return mtp_encode_integer(pdata,mtp3_para->nw[1].opc24,4); case 7: return mtp_encode_integer(pdata,mtp3_para->nw[2].opc24,4); case 8: return mtp_encode_integer(pdata,mtp3_para->nw[3].opc24,4); default: return -1; } return -1; case 4:/* linkset */ instance = oid[MTP3_OID_LEN+3]; *vartype = 4; switch (oid[MTP3_OID_LEN+2]) { case 1: mtp_encode_integer(pdata,mtp3_para->ls_pro[instance].ls_op_pc,4); pdata[3] = mtp3_para->ls_pro[instance].nw_id; memcpy(&pdata[4],&mtp3_para->ls_pro[instance].ls_reserved,16); return 20; /* linkset adjacent sp */ default: return -1; } return -1; case 5:/* link */ instance = oid[MTP3_OID_LEN+3]; *vartype = 4; switch (oid[MTP3_OID_LEN+2]) { case 1:/* e1 to linkset */ memcpy(pdata,&mtp3_para->lk[instance].e1_to_linkset,19); return 19; case 2: memcpy(pdata,&mtp3ObjState.lk_command[instance],1); return 1; case 3: pdata[0] = mtp3_para->mtp3lite_port; pdata[1] = mtp3_para->mtp3lite_port >> 8; return 2; default: return -1; } return -1; case 6:/* internation network routine table */ instance = oid[MTP3_OID_LEN+3]; *vartype = 4; switch (oid[MTP3_OID_LEN+2]) { case 1: mtp_encode_integer(pdata,mtp3_para->nw[0].routing[instance].dpc,4); memcpy(&pdata[3],&mtp3_para->nw[0].routing[instance].normal_ls,1); memcpy(&pdata[4],&mtp3_para->nw[0].routing[instance].alternative_ls,1); get_rc = htonl(mtp3_para->nw[0].routing[instance].rc); memcpy(&pdata[5], &get_rc, 4); get_rc = htonl(mtp3_para->nw[0].routing[instance].opc); memcpy(&pdata[9], &get_rc, 4); return 13; case 2: mtp_encode_integer(pdata,mtp3_para->nw[1].routing[instance].dpc,4); memcpy(&pdata[3],&mtp3_para->nw[1].routing[instance].normal_ls,1); memcpy(&pdata[4],&mtp3_para->nw[1].routing[instance].alternative_ls,1); get_rc = htonl(mtp3_para->nw[1].routing[instance].rc); memcpy(&pdata[5], &get_rc, 4); get_rc = htonl(mtp3_para->nw[1].routing[instance].opc); memcpy(&pdata[9], &get_rc, 4); return 13; case 3: mtp_encode_integer(pdata,mtp3_para->nw[2].routing[instance].dpc, 4); memcpy(&pdata[3],&mtp3_para->nw[2].routing[instance].normal_ls,1); memcpy(&pdata[4],&mtp3_para->nw[2].routing[instance].alternative_ls,1); get_rc = htonl(mtp3_para->nw[2].routing[instance].rc); memcpy(&pdata[5], &get_rc, 4); get_rc = htonl(mtp3_para->nw[2].routing[instance].opc); memcpy(&pdata[9], &get_rc, 4); return 13; case 4: mtp_encode_integer(pdata,mtp3_para->nw[3].routing[instance].dpc,4); memcpy(&pdata[3],&mtp3_para->nw[3].routing[instance].normal_ls,1); memcpy(&pdata[4],&mtp3_para->nw[3].routing[instance].alternative_ls,1); get_rc = htonl(mtp3_para->nw[3].routing[instance].rc); memcpy(&pdata[5], &get_rc, 4); get_rc = htonl(mtp3_para->nw[3].routing[instance].opc); memcpy(&pdata[9], &get_rc, 4); return 13; default: return -1; } return -1; case 7: instance = oid[MTP3_OID_LEN+3]; *vartype = 4; if (oid[MTP3_OID_LEN+2] == 1) { memcpy(pdata,mtp3_para->localAcn,MAX_ACN_NUM); } else if ((oid[MTP3_OID_LEN+2] > 1) && (oid[MTP3_OID_LEN+2] < 6)) { memcpy(pdata,mtp3_para->nw[oid[MTP3_OID_LEN+2]-2].routing[instance].acn,MAX_ACN_NUM); } else return -1; return MAX_ACN_NUM; case 8: instance = oid[MTP3_OID_LEN+3]; *vartype = 4; switch (oid[MTP3_OID_LEN+2]) { case 1:/* link timer */ memcpy(pdata,&mtp3_para->lt[instance].t1,10); return 10; default: return -1; } return -1; case 9:/* SG */ instance = oid[MTP3_OID_LEN+2]; *vartype = 4; memcpy(pdata,&mtp3_para->sg[instance],7); return 7; default: return -1; } return -1; } else if (oid[MTP3_OID_LEN] == 3)/* status */ { *vartype = 4; switch (oid[MTP3_OID_LEN+1]) { case 1:/* link status */ return mtp_encode_integer(pdata,mtp3ObjState.link_l3_state[oid[MTP3_OID_LEN+2]],1); case 2:/* linkset status */ instance= oid[MTP3_OID_LEN+2]; if (instance > 127) return -1; if (mtp3.ls[instance].links_available > 0) pdata[0] = 1; else pdata[0] = 0; return 1; case 3:/* international network routine */ return mtp_encode_integer(pdata,mtp3.nw[0].routine[oid[MTP3_OID_LEN+2]],1); case 4:/* international network spare routine */ return mtp_encode_integer(pdata,mtp3.nw[1].routine[oid[MTP3_OID_LEN+2]],1); case 5:/* national network routine */ return mtp_encode_integer(pdata,mtp3.nw[2].routine[oid[MTP3_OID_LEN+2]],1); case 6:/* national network spare routine */ return mtp_encode_integer(pdata,mtp3.nw[3].routine[oid[MTP3_OID_LEN+2]],1); case 7:/* version */ memcpy(pdata,mtp3_heartbeat.version,3); return 3; default: return -1; } } else if (oid[MTP3_OID_LEN] == 1)/* measurement */ { switch (oid[MTP3_OID_LEN+1]) { case 1:/* MTP signalling link faults and performance */ *vartype = 4; instance = oid[MTP3_OID_LEN+2]; if (instance > 8) return -1; portion_num = oid[MTP3_OID_LEN+3]; if ( (portion_num > 95) || (portion_num == mtp3_csta_p) ) return -1; timestamp = mtp3_measure.measure[portion_num].time_stamp; if (timestamp == 0) return 0; second_to_min(0,portion_num,instance); mtp3_data_reverse(pdata,(BYTE*)×tamp,4,4); mtp3_data_reverse(&pdata[4],(BYTE*)&mtp3_measure.measure[portion_num].lk_measure1[instance],36,4); return 40; case 2:/* Signalling link availability */ return -1; case 3:/* Signalling link set and route set availability */ *vartype = 4; instance = oid[MTP3_OID_LEN+2]; if (instance > 127) return -1; portion_num = oid[MTP3_OID_LEN+3]; /* if ( (portion_num > 95) || (portion_num == mtp3_csta_p) ) return -1;*/ timestamp = mtp3_measure.measure[portion_num].time_stamp; /* if (timestamp == 0) return 0;*/ second_to_min(1,portion_num,instance); mtp3_data_reverse(pdata,(BYTE*)×tamp,4,4); mtp3_data_reverse(&pdata[4],(BYTE*)&mtp3_measure.measure[portion_num].ls_measure[instance],32,4); return 36; case 5:/* Signalling traffic distribution */ switch (oid[MTP3_OID_LEN+2]) { case 1:/* total traffic */ *vartype = 4; instance = oid[MTP3_OID_LEN+3]; portion_num = oid[MTP3_OID_LEN+4]; if ( (portion_num > 95) || (portion_num == mtp3_csta_p) ) return -1; /* if (instance < 8) { timestamp = mtp3_measure.measure[portion_num].time_stamp; if (timestamp == 0) return 0; mtp3_data_reverse(pdata,(BYTE*)×tamp,4,4); mtp3_data_reverse(&pdata[4],(BYTE*)&mtp3_measure.measure[portion_num].tf_measure1[instance-1],80,4); return 84; }*/ else if (instance < 14) { timestamp = mtp3_measure.measure[portion_num].time_stamp; if (timestamp == 0) return 0; mtp3_data_reverse(pdata,(BYTE*)×tamp,4,4); mtp3_data_reverse(&pdata[4],(BYTE*)&mtp3_measure.measure[portion_num].tf_measure2[instance-8],80,4); return 84; } else return -1; default: return -1; } return -1; case 6:/* error */ *vartype = 4; portion_num = oid[MTP3_OID_LEN+2]; if ( (portion_num > 95) || (portion_num == mtp3_csta_p) ) return -1; timestamp = mtp3_measure.measure[portion_num].time_stamp; if (timestamp == 0) return 0; mtp3_data_reverse(pdata,(BYTE*)×tamp,4,4); mtp3_data_reverse(&pdata[4],(BYTE*)mtp3_measure.measure[portion_num].tf_measure5,12,4); return 16; default: return -1; } } else return -1; } void set_led(BYTE nled,BYTE ncolor); //void set_alarm(BYTE component_id,BYTE alarm_code); //void set_status(BYTE component_id,BYTE info_len,BYTE *info); void set_heartbeat(BYTE reason,WORD object) { BYTE place; BYTE temp; place = object/4; temp = (object % 4)*2; switch (reason) { case ALARM_LINK_UNAVAILABLE: mtp3_heartbeat.link_state[place] &= (~(3<lk[chl].e1_to_linkset; ls = &mtp3.ls[lsno];*/ mtp3ObjState.link_l2_state[chl] = MTP2_STATE_WORKING; mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_AVAILABLE; mtp3_send_alarm(MTP3_LINK_COMPONENT+chl,0); mtp3_send_mtp2_alarm(8+chl,0);//clear alarm tsrc_proc(chl); /* ls->links_available++;*/ hmrt_tcbc_update_routing_tables(chl); } void otherMTP3_managed_link_unavailable(WORD chl) { /* WORD lsno; ls_info *ls; lsno = mtp3_para->lk[chl].e1_to_linkset; ls = &mtp3.ls[lsno];*/ mtp3ObjInput.tsrc_input_from_tlac[chl] = TSRC_TLAC_LINK_UNAVAILABLE; tsrc_proc(chl); /* ls->links_available--;*/ hmrt_tcoc_update_routing_tables(chl); // mtp3ObjState.tlac_state[chl] = TLAC_UNAVAILABLE_STATE; /*init init_tlac_state*/ init_tlac_state[chl] = TRUE; tlac_proc(chl); init_lsac_state[chl] = TRUE; lsac_proc(chl); } int sys_mtp3_table(ulong ip) { int empty; int i; if (ip==0) return -1; empty = -1; for (i=0;i= 0) return empty; return -1; } void master_MTP3(WORD link,BYTE masterMTP3,ulong srcIP) { ulong NMTP3; ulong AMTP3; masterMTP3 = masterMTP3 & 1; NMTP3 = mtp3_para->lk[link].e1_to_mtp3; AMTP3 = mtp3_para->lk[link].e1_to_alterMTP3; if (srcIP==NMTP3) { if (masterMTP3) mtp3ObjState.lk_NMTP3_ok[link] |= 1; else mtp3ObjState.lk_NMTP3_ok[link] &= 0xf0; } else if (srcIP==AMTP3) { if (masterMTP3) mtp3ObjState.lk_AMTP3_ok[link] |= 1; else mtp3ObjState.lk_AMTP3_ok[link] &= 0xf0; } } void trap_platform (BYTE oid_len,DWORD *oid_ptr,BYTE *msg_ptr,WORD msg_len,snmp_addr *addr) { heartbeat_msg *phbmsg = (heartbeat_msg *)msg_ptr; BYTE *pstatus = phbmsg->info; heartbeat_compoent_of_mtp3 *phbmtp3 = NULL; WORD mtp3len=0; int i,j,pos = 2; //component_id=0:iptrans; BYTE newHeartbeat=0; int chl; BYTE chl_state; ulong remote_ip; int temp; struct in_addr in; in.s_addr = addr->remote_ip; mtp3_debug(MTP3DB_PFHB,"get platform heartbeat from %s",inet_ntoa(in)); if (msg_len > 128) mtp3_showbuf(MTP3DB_PFHB,msg_ptr,128); else mtp3_showbuf(MTP3DB_PFHB,msg_ptr,msg_len); remote_ip = addr->remote_ip; if ((temp=sys_mtp3_table(remote_ip)) >= 0) { MTP3IPMng.mtp3_flag_new[temp] = 1; MTP3IPMng.mtp3_flag_ip[temp] = remote_ip; } if ( remote_ip == mtp3_localip )/* heartbeat from itself */ return; if ((temp=MTP3_LinkIP_List(remote_ip,0))<0) return; if (sizeof(struct heartbeat_msg) >= (INFO_LEN + 18)) newHeartbeat = 1; peer_hb_timer = 1; //check peer heartbeat status if (!newHeartbeat) {//old version heartbeat, length and component_id are one octet pos = 1; pos += pstatus[pos]+1; //length of iptrans status pos++; //component_id=1:MTP3 mtp3len = pstatus[pos]; pos++; //length of mtp3 hb if (pstatus[pos-1] != 1)//not mtp3 component return; } else {//new version heartbeat, length and component_id are 2 octets pos ++; //length is 2 octets pos += pstatus[pos]+1; //length of iptrans status pos ++; //component_id=1:mtp3 pos ++; //component_id is 2 octets if (pstatus[pos-1] != 1)//not mtp3 component return; mtp3len = pstatus[pos]*256+pstatus[pos+1]; pos ++; //length of mtp3 hb pos ++; //length is 2 octets } phbmtp3 = (heartbeat_compoent_of_mtp3*)&pstatus[pos]; if (mtp3len > MTP3_HB_LEN || mtp3len < (MTP3_HB_LEN-34)) return; for (i=0; i<256; i++) { temp = phbmtp3->link_state[i]; for (j=0; j<4; j++) { chl = i*4+j; chl_state = (temp >> (j*2)) & 3; if ( (mtp3ObjState.lk_mtp3[chl] == remote_ip) && (mtp3ObjState.link_l3_state[chl] != chl_state) ) { if ( mtp3ObjState.lk_configured[chl] != PARA_CONFIGURED ) { continue; } switch (chl_state) { case UNAVAILABLE: if (mtp3ObjState.link_l3_state[chl] == INHIBITED) { mtp3_debug(MTP3DB_EVENT,"link %d L3 state changed from INHIBITED to UNAVAILABLE,invoke by %s",chl,inet_ntoa(in)); mtp3ObjState.link_l3_state[chl] = UNAVAILABLE; } else { mtp3_debug(MTP3DB_EVENT,"link %d L3 out of service,invoke by %s",chl,inet_ntoa(in)); otherMTP3_managed_link_unavailable(chl); } break; case AVAILABLE: mtp3_debug(MTP3DB_EVENT,"link %d L3 in service,invoke by %s",chl,inet_ntoa(in)); otherMTP3_managed_link_available(chl); break; case INHIBITED: mtp3_debug(MTP3DB_EVENT,"link %d L3 inhibited,invoke by %s",chl,inet_ntoa(in)); if (mtp3ObjState.link_l3_state[chl] == AVAILABLE) otherMTP3_managed_link_unavailable(chl); mtp3ObjState.link_l3_state[chl] = INHIBITED; break; default: break; } } } } if (mtp3len > 100) { for (i=0;i<32;i++) { for (j=0; j<8; j++) { chl = i*8+j; master_MTP3(chl,(phbmtp3->masterMTP3[i]>>j),remote_ip); master_MTP3(chl+256,0 , remote_ip); master_MTP3(chl+512,0 , remote_ip); master_MTP3(chl+768,0 , remote_ip); } } if (mtp3len > 132) { MTP3IPMng.LinkIPSubSta[temp][0] = phbmtp3->SubState[0]; MTP3IPMng.LinkIPSubSta[temp][1] = phbmtp3->SubState[1]; } else { MTP3IPMng.LinkIPSubSta[temp][0] = 0xff; MTP3IPMng.LinkIPSubSta[temp][1] = 0xff; } } else { MTP3IPMng.LinkIPSubSta[temp][0] = 0xff; MTP3IPMng.LinkIPSubSta[temp][1] = 0xff; } } void trap_mtp2 (BYTE oid_len,DWORD *oid_ptr,BYTE *msg_ptr,WORD msg_len,snmp_addr *addr)//8KE1 { int i; mtp2_heartbeat *mtp2; BYTE offset; BYTE new_l2_state; WORD chl; WORD ls; BYTE module_id; struct in_addr in; in.s_addr = addr->remote_ip; mtp3_debug(MTP3DB_PRIMITIVE_MSG,"get MTP2 heartbeat from %s",inet_ntoa(in)); mtp3_showbuf(MTP3DB_PRIMITIVE_MSG,msg_ptr,msg_len); mtp2 = (mtp2_heartbeat*)msg_ptr; module_id = (mtp2->systemid & 1)*16+mtp2->moduleid; if (module_id > 31) return; mtp2_flag_new[module_id] = 1; offset = module_id << 3; for ( i=0; i<8; i++ ) { chl = offset + i; mtp3ObjState.link_l1_state[chl] = (mtp2->l1_state >> i) & 1; new_l2_state = mtp2->l2_state[i];/* e1 l2 state from mtp2 */ if ( (mtp3ObjState.lk_configured[chl] == PARA_NOT_CONFIGURED) || (mtp3ObjState.lk_mtp3[chl] != mtp3_localip) ) continue; if ( new_l2_state != mtp3ObjState.link_l2_state[chl] ) { ls = mtp3_para->lk[chl].e1_to_linkset; if (new_l2_state == MTP2_STATE_WORKING)/* link from unavailable->available */ { current_measure->lk_measure1[chl][2]++;/* restoration */ mtp3_debug(MTP3DB_EVENT,"link %d L2 in service",chl); mtp3ObjInput.lsac_input_from_l2[chl] = LSAC_L2_IN_SERVICE; } else if (mtp3ObjState.link_l2_state[chl] == MTP2_STATE_WORKING)/* link from available->unavailable */ { local_change_over[chl]++; mtp3_debug(MTP3DB_EVENT,"link %d L2 out of service",chl); mtp3ObjInput.lsac_input_from_l2[chl] = LSAC_L2_OUT_OF_SERVICE; if ( mtp2->retrieved_bsnt[i] < 128 ) local_bsnt_retrievable[chl] = TRUE; else { // mtp3_debug(MTP3_DEBUG_LOG,"Link %d BSNT RETRIEVE FAILED",chl); local_bsnt_retrievable[chl] = FALSE; } mtp3ObjInput.sltc_input[chl] = SLTC_STOP; sltc_proc(chl); } } mtp3ObjState.link_l2_state[chl] = new_l2_state; if ( (mtp2->e1_dstip[i]+32 != ((mtp3ObjState.lk_mtp3[chl] >> 16) & 0xff)) && (mtp3ObjState.lk_configured[chl] == PARA_CONFIGURED) ) send_command_to_mtp2(chl,MTP2_ACTIVE_LINK);/* give this port a correct ip */ retrieved_bsnt[chl] = mtp2->retrieved_bsnt[i]; } if (mtp2->alarm_code == 3) { mtp2_buf_full[mtp2->alarm_component]++; } } int mtp3_clear_all_peer_link_status(); void mtp3_dealtrap(BYTE oid_len,DWORD *oid_ptr,BYTE *msg_ptr,WORD msg_len,snmp_addr *addr) { DWORD mtp2_oid[20] = MTP2_HB_OID; DWORD platform_oid[20] = PLATFORM_HB_OID; DWORD omc_oid[20] = MTP3_OMC_OID; if (memcmp(&oid_ptr[9],&mtp2_oid[9],16)==0) { trap_mtp2 (oid_len,oid_ptr,msg_ptr,msg_len,addr); } else if (memcmp(&oid_ptr[9],&platform_oid[9],8)==0) { trap_platform(oid_len,oid_ptr,msg_ptr,msg_len,addr); } else if (memcmp(oid_ptr,omc_oid,MTP3_OMC_OID_LEN*sizeof(DWORD))==0) {//omc heartbeat if ((mtp3_para->MTP3SerialNum==0) ||//support old version, do not have serial number (Bcd2Ull(&msg_ptr[39],MTP3_SERNUM_LEN)==mtp3_para->MTP3SerialNum) ) { if(peer_hb_timer>0) { if(++peer_hb_timer>4) { mtp3_clear_all_peer_link_status(); peer_hb_timer = 0; } } switch(msg_ptr[0]) { case 0: mtp3_primomcip = addr->remote_ip; break; case 1: mtp3_secdomcip = addr->remote_ip; break; default: break; } } } } int mtp3_clear_all_peer_link_status() { int link; for(link=0; linklk[link].admin_state& 1) && (mtp3ObjState.lk_mtp3[link] != mtp3_localip)) { if(mtp3ObjState.link_l3_state[link] == AVAILABLE) { mtp3ObjState.link_l3_state[link] = UNAVAILABLE; } } } return 1; } void mtp_snmp_init() { // DWORD mib_oid[20] = MTP3_OID; snmp_init(4957); heartbeat_init(0xff); /* inquire_setmsg(MTP3_OID_LEN,mib_oid, mtp_setmib); inquire_getmsg(MTP3_OID_LEN,mib_oid, mtp_getmib); */ mtp3_snmp_registration(); // inquire_trapmsg(trapcall trap_mtp2)/* mtp2 heartbeat */ inquire_trapmsg(mtp3_dealtrap); // rob_trapmsg(MTP2_HBOID_LEN,mtp2_oid,trap_mtp2); } int mtp3_getnext_link(u32 *instance) { int i=0; for(i=instance[0]; ilk[i].e1_to_mtp3==0xffffffff ||mtp3_para->lk[i].e1_to_mtp3==0) && mtp3_para->lk[i].admin_state==0) if((mtp3_para->lk[i].title[0]==0) && mtp3_para->lk[i].admin_state==0) continue; instance[0] = i; return 1; } instance[0] = 0; return 0; } int mtp3_get_link(u32 column, u32 *instance, u8 *pdata, u8 *vartype) { int datalen = -1; lk_pro *pLink; if (instance[0] >= MAX_LK) return -2; pLink = &mtp3_para->lk[instance[0]]; switch(column) { case 1: //index GET_INTEGER(instance[0]); break; case 2: //link title GET_STRING(pLink->title); break; case 3: //link admin_state GET_U8(pLink->admin_state); break; case 4://state GET_U8(mtp3ObjState.link_l3_state[*instance]); break; case 5: //server type GET_U8(pLink->e1_lk_type); break; case 6: //linkset number GET_INTEGER(pLink->e1_to_linkset); break; case 7: //link SLC GET_U8(pLink->e1_to_slc); break; case 8: //host ip GET_IP(&pLink->e1_to_mtp3); break; case 9: //alternavie host ip GET_IP(&pLink->e1_to_alterMTP3); break; case 10: //SG ID GET_INTEGER(pLink->e1_to_sg); break; case 11: //m2ua interface id GET_U8(pLink->e1_to_iid); break; case 12: //mtp3lite mode GET_U8(pLink->mtp3lite_apl_mode); break; case 13: //mtp3lite remote ip GET_IP(&pLink->remote_ip); break; case 14: // GET_U8(pLink->inactive); break; case 15: GET_U8(pLink->inactive_tm); break; case 16://state GET_U8(mtp3ObjState.link_l3_state[*instance]); break; default: break; } return datalen; } int mtp3_set_link(u32 column, u32 *instance, u8 *pdata, u16 datalen) { lk_pro *pLink; int new_id; u8 tmp=0; int linkId = 0; if(*instance >=MAX_LK) { strcpy((char*)pdata,"MAX Link is 1023."); return -2; } if(column == Create_Object_Cloumn) { SET_INTEGER(new_id); if(new_id >=MAX_LK) strcpy((char*)pdata,"MAX Link is 1023."); pLink = &mtp3_para->lk[new_id]; if(pLink->admin_state==1) { strcpy((char*)pdata,"Link is unlocked."); return -2; } pLink->title[0]='-'; pLink->e1_lk_type = 1; mtp3ObjState.link_type[new_id] = pLink->e1_lk_type; mtp3EnableSaveFlag(); return datalen; } linkId = *instance; pLink = &mtp3_para->lk[*instance]; if(pLink->admin_state==1 && column>3) { strcpy((char*)pdata,"Link is unlocked."); return -2; } if(datalen == 0) { if(column == 12 || column == 2) ; else return -2; } switch(column) { case 2: //link title if(datalen >= 16) return -2; SET_STRING(pLink->title); break; case 3: //link admin_state if(pLink->admin_state==1 && pdata[0]==0) { mtp3_setlink_to_IDLE(instance[0]); } else if(pLink->admin_state==0 && pdata[0]==1) { SET_U8(pLink->admin_state); if (update_ls_slc_table(instance[0]) == 1) { update_sls_to_link_table(pLink->e1_to_linkset); MTP3_LinkIP_List(pLink->e1_to_mtp3,1); MTP3_LinkIP_List(pLink->e1_to_alterMTP3,1); } } SET_U8(pLink->admin_state); #ifdef _INCLUDE_M2UA set_m2ua_link(instance[0]%MAX_LK, (u8 *)pLink); #endif break; case 5: //server type SET_U8(pLink->e1_lk_type); mtp3ObjState.link_type[instance[0]] = pLink->e1_lk_type; break; case 6: //linkset number SET_INTEGER(pLink->e1_to_linkset); break; case 7: //link SLC SET_U8(pLink->e1_to_slc); break; case 8: //host ip SET_IP(&pLink->e1_to_mtp3); mtp3ObjState.lk_mtp3[linkId] = mtp3_para->lk[linkId].e1_to_mtp3; break; case 9: //alternative host ip SET_IP(&pLink->e1_to_alterMTP3); break; case 10: //SG ID SET_INTEGER(pLink->e1_to_sg); break; case 11: //m2ua interface id SET_U8(pLink->e1_to_iid); break; case 12: //mtp3lite mode SET_U8(pLink->mtp3lite_apl_mode); break; case 13: //mtp3lite remote ip SET_IP(&pLink->remote_ip); break; case 14: // SET_U8(pLink->inactive); break; case 15: SET_U8(pLink->inactive_tm); break; case 16: SET_U8(tmp); if(tmp == 6) { memset(pLink, 0, sizeof(lk_pro)); #ifdef _INCLUDE_M2UA set_m2ua_link(instance[0]%MAX_LK, (u8 *)pLink); #endif } default: break; } mtp3EnableSaveFlag(); return datalen; } int mtp3_getnext_linkset(u32 *instance) { int i=0; for(i=instance[0]; ils_pro[i].title[0]==0&&mtp3_para->ls_pro[i].admin_state==0) continue; instance[0]= i; return 1; } return 0; } int mtp3_get_linkset(u32 column, u32 *instance, u8 *pdata, u8 *vartype) { int datalen = -1; ls_para *pLs; if (instance[0] >= MAX_LS) return -2; pLs = &mtp3_para->ls_pro[instance[0]]; switch(column) { case 1: //index GET_INTEGER(instance[0]); break; case 2: //ls title GET_STRING(pLs->title); break; case 3: //ls admin_state GET_U8(pLs->admin_state); break; case 4: //ls state GET_U8(pLs->ls_state); break; case 5: //nw indicator GET_U8(pLs->nw_id); break; case 6: //DPC GET_INTEGER(pLs->ls_op_pc); break; case 7: //ls loopback option GET_U8(pLs->loopback_opt); break; case 8: //ls opc if used multiple opc GET_INTEGER(pLs->ls_opc); break; case 9: GET_U8(1); break; default: break; } return datalen; } void reset_linkset(int ls_num ) { int i=0; u32 dpc=0, opc=0; u8 nw=0; nw = mtp3_para->ls_pro[ls_num].nw_id; dpc = mtp3_para->ls_pro[ls_num].ls_op_pc; opc = mtp3_para->ls_pro[ls_num].ls_opc; if(dpc == 0) { mtp3.ls[ls_num].adjacent_sp_place = 0xffff; return ; } for (i=0;inw[nw].routing[i].dpc == dpc && mtp3_para->nw[nw].routing[i].opc == opc)//??? { mtp3.ls[ls_num].adjacent_sp_place = i; return; } } mtp3.ls[ls_num].adjacent_sp_place = 0xffff; } int mtp3_set_linkset(u32 column, u32 *instance, u8 *pdata, u16 datalen) { ls_para *ptr; int new_id; u8 tmp=0; if(*instance >=MAX_LS) { strcpy((char*)pdata,"MAX Linkset is 511."); return -2; } if(column == Create_Object_Cloumn) { SET_INTEGER(new_id); if(new_id >=MAX_LS) strcpy((char*)pdata,"MAX Linkset is 511."); ptr = &mtp3_para->ls_pro[new_id]; if(ptr->admin_state==1) { strcpy((char*)pdata,"Linkset is unlocked."); return -2; } ptr->title[0]= '-'; mtp3EnableSaveFlag(); return datalen; } ptr = &mtp3_para->ls_pro[*instance]; if(ptr->admin_state==1&&column>3) { strcpy((char*)pdata,"Linkset is unlocked."); return -2; } if(datalen == 0) { if(column == 12 || column == 2) ; else return -2; } if(column == Create_Object_Cloumn) { new_id = *instance; if(ptr->admin_state==1) { strcpy((char*)pdata,"Linkset is unlocked."); return -2; } return datalen; } switch(column) { case 2: //linkset title if(datalen >= 16) return -2; SET_STRING(ptr->title); break; case 3: //ls admin_state if(ptr->admin_state !=pdata[0] && pdata[0]==1) reset_linkset(instance[0]); SET_U8(ptr->admin_state); break; case 4: //ls state //SET_U8(ptr->ls_state); break; case 5: //nw indicator if(ptr->nw_id != pdata[0]) change_the_whole_ls(instance[0],ptr->nw_id,pdata[0]); SET_U8(ptr->nw_id); break; case 6: //dpc SET_INTEGER(ptr->ls_op_pc); break; case 7: //ls loopback option SET_U8(ptr->loopback_opt); break; case 8: //ls opc if used multiple opc SET_INTEGER(ptr->ls_opc); break; case 9: SET_U8(tmp); if(tmp == 6) { memset(ptr, 0, sizeof(ls_para)); reset_linkset(instance[0]); } default: break; } mtp3EnableSaveFlag(); return datalen; } int mtp3_getnext_sg(u32 *instance) { int i=0; for(i=instance[0]; i<256; i++) { if(mtp3_para->sg[i].ip==0&&mtp3_para->sg[i].enable==0) continue; instance[0] = i; return 1; } return 0; } int mtp3_get_sg(u32 column, u32 *instance, u8 *pdata, u8 *vartype) { int datalen = -1; u8 type=0, data_ack=0; sg_para *ptr; if (instance[0] >= 256) return -2; ptr = &mtp3_para->sg[instance[0]]; switch(column) { case 1: //index GET_INTEGER(instance[0]); break; case 2: //sg admin_state GET_U8(ptr->enable); break; case 3: //server or client GET_U8(ptr->server); break; case 4: //data_ack data_ack = ptr->data_ack&1; GET_U8(data_ack); break; case 5: // type type = ptr->data_ack>>1; GET_U8(type); break; case 6: //remote ip GET_IP(&ptr->ip); break; case 7: //client source ip GET_IP(&ptr->source_ip); break; case 8: //client source port GET_INTEGER(ptr->source_port); break; case 9: //dst port GET_INTEGER(ptr->dst_port); break; case 10: GET_U8(ptr->enable); break; default: break; } return datalen; } int check_sg_link_enable(int sg_id) { int link; for(link=0; linklk[link].e1_to_sg == sg_id && mtp3_para->lk[link].admin_state==1&&mtp3_para->lk[link].e1_lk_type>0&&mtp3_para->lk[link].e1_lk_type!=LKTYPE_MTP3_LITE) return 1; } return 0; } int mtp3_set_sg(u32 column, u32 *instance, u8 *pdata, u16 datalen) { sg_para *ptr; int new_id; u8 tmp=0; if(*instance >=256) { strcpy((char*)pdata,"MAX SG is 255."); return -2; } if(column == Create_Object_Cloumn) { SET_INTEGER(new_id); if(mtp3_para->sg[new_id].enable==1) { strcpy((char*)pdata,"SG is unlocked."); return -2; } mtp3_para->sg[new_id].ip=0x016212ac; mtp3EnableSaveFlag(); return datalen; } ptr = &mtp3_para->sg[*instance]; if(check_sg_link_enable(*instance)) { strcpy((char*)pdata,"Links of SG are unlocked."); return -2; } if(ptr->enable==1&&(column>2)) { strcpy((char*)pdata,"SG is unlocked."); return -2; } if(datalen == 0) { if(column == 3) ; else return -2; } switch(column) { case 2: //sg admin_state SET_U8(ptr->enable); #ifdef _INCLUDE_M2UA set_m2ua_sg(instance[0] & 0xff, (u8 *)ptr); #endif break; case 3: //server or client SET_U8(ptr->server); break; case 4: //data_ack ptr->data_ack = (ptr->data_ack&0xfe)|pdata[0]; break; case 5: //type ptr->data_ack = (ptr->data_ack&0x1)|(pdata[0]<<1); break; case 6: //remote ip SET_IP(&ptr->ip); break; case 7: //client source ip SET_IP(&ptr->source_ip); break; case 8: //client source port SET_INTEGER(ptr->source_port); break; case 9: //dst port SET_INTEGER(ptr->dst_port); break; case 10: //delete sg SET_U8(tmp); if(tmp == 6) { memset(ptr, 0, sizeof(sg_para)); #ifdef _INCLUDE_M2UA set_m2ua_sg(instance[0] & 0xff, (u8 *)ptr); #endif } break; default: break; } mtp3EnableSaveFlag(); return datalen; } int mtp3_getnext_introute(u32 *instance) { int i=0; for(i=instance[0]; inw[0].routing[i].title[0]==0) continue; instance[0] = i; return 1; } return 0; } int mtp3_get_introute(u32 column, u32 *instance, u8 *pdata, u8 *vartype) { int datalen = -1; nw_route *ptr; if (instance[0] >= MAX_ROUTE) return -2; ptr = &mtp3_para->nw[0].routing[instance[0]]; switch(column) { case 1: //index GET_INTEGER(instance[0]); break; case 2: //title GET_STRING(ptr->title); break; case 3: //DPC GET_INTEGER(ptr->dpc); break; case 4: //OPC multiple GET_INTEGER(ptr->opc); break; case 5: // normal linkset GET_INTEGER(ptr->normal_ls); break; case 6: //alternative linkset GET_INTEGER(ptr->alternative_ls); break; case 7:// m3ua rc GET_INTEGER(ptr->rc); break; case 8://ACN GET_OPAQUE(ptr->acn, MAX_ACN_NUM); break; case 9:// GET_U8(1); break; default: break; } return datalen; } int mtp3_set_introute(u32 column, u32 *instance, u8 *pdata, u16 datalen) { nw_route *ptr; int new_id; u8 tmp=0; u32 temp=0; if(*instance >=MAX_ROUTE) { strcpy((char*)pdata,"MAX ROUTE is 1023."); return -2; } if(column == Create_Object_Cloumn) { SET_INTEGER(new_id); if(mtp3_para->nw[0].routing[new_id].title[0]!=0) { strcpy((char*)pdata,"Route is already used."); return -2; } mtp3_para->nw[0].routing[new_id].title[0]='-'; memcpy(mtp3_para->nw[0].routing[new_id].acn, mtp3_para->nw[0].local_acn, MAX_ACN_NUM); mtp3EnableSaveFlag(); return datalen; } ptr = &mtp3_para->nw[0].routing[*instance]; switch(column) { case 2: //title SET_STRING(ptr->title); break; case 3: //DPC SET_INTEGER(temp); update_ls_influence_dst_table(0,temp,instance[0],ptr->normal_ls, ptr->alternative_ls, ptr->rc, ptr->opc); SET_INTEGER(ptr->dpc); break; case 4: //OPC multiple SET_INTEGER(temp); update_ls_influence_dst_table(0,ptr->dpc,instance[0],ptr->normal_ls, ptr->alternative_ls, ptr->rc, temp); SET_INTEGER(ptr->opc); break; case 5: // normal linkset SET_INTEGER(temp); update_ls_influence_dst_table(0,ptr->dpc,instance[0],temp, ptr->alternative_ls, ptr->rc, ptr->opc); SET_INTEGER(ptr->normal_ls); break; case 6: //alternative linkset SET_INTEGER(temp); update_ls_influence_dst_table(0,ptr->dpc,instance[0],ptr->normal_ls, temp, ptr->rc, ptr->opc); SET_INTEGER(ptr->alternative_ls); break; case 7:// m3ua rc SET_INTEGER(temp); update_ls_influence_dst_table(0,ptr->dpc,instance[0],ptr->normal_ls, ptr->alternative_ls, temp, ptr->opc); SET_INTEGER(ptr->rc); break; case 8://ACN SET_OPAQUE(ptr->acn, MAX_ACN_NUM); break; case 9:// SET_U8(tmp); if(tmp == 6) { update_ls_influence_dst_table(0,0,instance[0],0, 0, 0, 0); memset(ptr, 0, sizeof(nw_route)); } break; default: break; } mtp3EnableSaveFlag(); return datalen; } int mtp3_getnext_intsroute(u32 *instance) { int i=0; for(i=instance[0]; inw[1].routing[i].title[0]==0) continue; instance[0] = i; return 1; } return 0; } int mtp3_get_intsroute(u32 column, u32 *instance, u8 *pdata, u8 *vartype) { int datalen = -1; nw_route *ptr; if (instance[0] >= MAX_ROUTE) return -2; ptr = &mtp3_para->nw[1].routing[instance[0]]; switch(column) { case 1: //index GET_INTEGER(instance[0]); break; case 2: //title GET_STRING(ptr->title); break; case 3: //DPC GET_INTEGER(ptr->dpc); break; case 4: //OPC multiple GET_INTEGER(ptr->opc); break; case 5: // normal linkset GET_INTEGER(ptr->normal_ls); break; case 6: //alternative linkset GET_INTEGER(ptr->alternative_ls); break; case 7:// m3ua rc GET_INTEGER(ptr->rc); break; case 8://ACN GET_OPAQUE(ptr->acn, MAX_ACN_NUM); break; case 9:// GET_U8(1); break; default: break; } return datalen; } int mtp3_set_intsroute(u32 column, u32 *instance, u8 *pdata, u16 datalen) { nw_route *ptr; int new_id; u8 tmp=0; u32 temp=0; if(*instance >=MAX_ROUTE) { strcpy((char*)pdata,"MAX ROUTE is 1023."); return -2; } if(column == Create_Object_Cloumn) { SET_INTEGER(new_id); if(mtp3_para->nw[1].routing[new_id].title[0]!=0) { strcpy((char*)pdata,"Route is already used."); return -2; } mtp3_para->nw[1].routing[new_id].title[0]='-'; memcpy(mtp3_para->nw[1].routing[new_id].acn, mtp3_para->nw[1].local_acn, MAX_ACN_NUM); mtp3EnableSaveFlag(); return datalen; } ptr = &mtp3_para->nw[1].routing[*instance]; switch(column) { case 2: //title SET_STRING(ptr->title); break; case 3: //DPC SET_INTEGER(temp); update_ls_influence_dst_table(1,temp,instance[0],ptr->normal_ls, ptr->alternative_ls, ptr->rc, ptr->opc); SET_INTEGER(ptr->dpc); break; case 4: //OPC multiple SET_INTEGER(temp); update_ls_influence_dst_table(1,ptr->dpc,instance[0],ptr->normal_ls, ptr->alternative_ls, ptr->rc, temp); SET_INTEGER(ptr->opc); break; case 5: // normal linkset SET_INTEGER(temp); update_ls_influence_dst_table(1,ptr->dpc,instance[0],temp, ptr->alternative_ls, ptr->rc, ptr->opc); SET_INTEGER(ptr->normal_ls); break; case 6: //alternative linkset SET_INTEGER(temp); update_ls_influence_dst_table(1,ptr->dpc,instance[0],ptr->normal_ls, temp, ptr->rc, ptr->opc); SET_INTEGER(ptr->alternative_ls); break; case 7:// m3ua rc SET_INTEGER(temp); update_ls_influence_dst_table(1,ptr->dpc,instance[0],ptr->normal_ls, ptr->alternative_ls, temp, ptr->opc); SET_INTEGER(ptr->rc); break; case 8://ACN SET_OPAQUE(ptr->acn, MAX_ACN_NUM); break; case 9:// SET_U8(tmp); if(tmp == 6) { update_ls_influence_dst_table(1,0,instance[0],0, 0, 0, 0); memset(ptr, 0, sizeof(nw_route)); } break; default: break; } mtp3EnableSaveFlag(); return datalen; } int mtp3_getnext_natroute(u32 *instance) { int i=0; for(i=instance[0]; inw[2].routing[i].title[0]==0) continue; instance[0] = i; return 1; } return 0; } int mtp3_get_natroute(u32 column, u32 *instance, u8 *pdata, u8 *vartype) { int datalen = -1; nw_route *ptr; if (instance[0] >= MAX_ROUTE) return -2; ptr = &mtp3_para->nw[2].routing[instance[0]]; switch(column) { case 1: //index GET_INTEGER(instance[0]); break; case 2: //title GET_STRING(ptr->title); break; case 3: //DPC GET_INTEGER(ptr->dpc); break; case 4: //OPC multiple GET_INTEGER(ptr->opc); break; case 5: // normal linkset GET_INTEGER(ptr->normal_ls); break; case 6: //alternative linkset GET_INTEGER(ptr->alternative_ls); break; case 7:// m3ua rc GET_INTEGER(ptr->rc); break; case 8://ACN GET_OPAQUE(ptr->acn, MAX_ACN_NUM); break; case 9:// GET_U8(1); break; default: break; } return datalen; } int mtp3_set_natroute(u32 column, u32 *instance, u8 *pdata, u16 datalen) { nw_route *ptr; int new_id; u8 tmp=0; u32 temp=0; if(*instance >=MAX_ROUTE) { strcpy((char*)pdata,"MAX ROUTE is 1023."); return -2; } if(column == Create_Object_Cloumn) { SET_INTEGER(new_id); if(mtp3_para->nw[2].routing[new_id].title[0]!=0) { strcpy((char*)pdata,"Route is already used."); return -2; } mtp3_para->nw[2].routing[new_id].title[0]='-'; memcpy(mtp3_para->nw[2].routing[new_id].acn, mtp3_para->nw[2].local_acn, MAX_ACN_NUM); mtp3EnableSaveFlag(); return datalen; } ptr = &mtp3_para->nw[2].routing[*instance]; switch(column) { case 2: //title SET_STRING(ptr->title); break; case 3: //DPC SET_INTEGER(temp); update_ls_influence_dst_table(2,temp,instance[0],ptr->normal_ls, ptr->alternative_ls, ptr->rc, ptr->opc); SET_INTEGER(ptr->dpc); break; case 4: //OPC multiple SET_INTEGER(temp); update_ls_influence_dst_table(2,ptr->dpc,instance[0],ptr->normal_ls, ptr->alternative_ls, ptr->rc, temp); SET_INTEGER(ptr->opc); break; case 5: // normal linkset SET_INTEGER(temp); update_ls_influence_dst_table(2,ptr->dpc,instance[0],temp, ptr->alternative_ls, ptr->rc, ptr->opc); SET_INTEGER(ptr->normal_ls); break; case 6: //alternative linkset SET_INTEGER(temp); update_ls_influence_dst_table(2,ptr->dpc,instance[0],ptr->normal_ls, temp, ptr->rc, ptr->opc); SET_INTEGER(ptr->alternative_ls); break; case 7:// m3ua rc SET_INTEGER(temp); update_ls_influence_dst_table(2,ptr->dpc,instance[0],ptr->normal_ls, ptr->alternative_ls, temp, ptr->opc); SET_INTEGER(ptr->rc); break; case 8://ACN SET_OPAQUE(ptr->acn, MAX_ACN_NUM); break; case 9:// SET_U8(tmp); if(tmp == 6) { update_ls_influence_dst_table(2,0,instance[0],0, 0, 0, 0); memset(ptr, 0, sizeof(nw_route)); } break; default: break; } mtp3EnableSaveFlag(); return datalen; } int mtp3_getnext_natsroute(u32 *instance) { int i=0; for(i=instance[0]; inw[3].routing[i].title[0]==0) continue; instance[0] = i; return 1; } return 0; } int mtp3_get_natsroute(u32 column, u32 *instance, u8 *pdata, u8 *vartype) { int datalen = -1; nw_route *ptr; if (instance[0] >= MAX_ROUTE) return -2; ptr = &mtp3_para->nw[3].routing[instance[0]]; switch(column) { case 1: //index GET_INTEGER(instance[0]); break; case 2: //title GET_STRING(ptr->title); break; case 3: //DPC GET_INTEGER(ptr->dpc); break; case 4: //OPC multiple GET_INTEGER(ptr->opc); break; case 5: // normal linkset GET_INTEGER(ptr->normal_ls); break; case 6: //alternative linkset GET_INTEGER(ptr->alternative_ls); break; case 7:// m3ua rc GET_INTEGER(ptr->rc); break; case 8://ACN GET_OPAQUE(ptr->acn, MAX_ACN_NUM); break; case 9:// GET_U8(1); break; default: break; } return datalen; } int mtp3_set_natsroute(u32 column, u32 *instance, u8 *pdata, u16 datalen) { nw_route *ptr; int new_id; u8 tmp=0; u32 temp=0; if(*instance >=MAX_ROUTE) { strcpy((char*)pdata,"MAX ROUTE is 1023."); return -2; } if(column == Create_Object_Cloumn) { SET_INTEGER(new_id); if(mtp3_para->nw[3].routing[new_id].title[0]!=0) { strcpy((char*)pdata,"Route is already used."); return -2; } mtp3_para->nw[3].routing[new_id].title[0]='-'; memcpy(mtp3_para->nw[3].routing[new_id].acn, mtp3_para->nw[3].local_acn, MAX_ACN_NUM); mtp3EnableSaveFlag(); return datalen; } ptr = &mtp3_para->nw[3].routing[*instance]; switch(column) { case 2: //title SET_STRING(ptr->title); break; case 3: //DPC SET_INTEGER(temp); update_ls_influence_dst_table(3,temp,instance[0],ptr->normal_ls, ptr->alternative_ls, ptr->rc, ptr->opc); SET_INTEGER(ptr->dpc); break; case 4: //OPC multiple SET_INTEGER(temp); update_ls_influence_dst_table(3,ptr->dpc,instance[0],ptr->normal_ls, ptr->alternative_ls, ptr->rc, temp); SET_INTEGER(ptr->opc); break; case 5: // normal linkset SET_INTEGER(temp); update_ls_influence_dst_table(3,ptr->dpc,instance[0],temp, ptr->alternative_ls, ptr->rc, ptr->opc); SET_INTEGER(ptr->normal_ls); break; case 6: //alternative linkset SET_INTEGER(temp); update_ls_influence_dst_table(3,ptr->dpc,instance[0],ptr->normal_ls, temp, ptr->rc, ptr->opc); SET_INTEGER(ptr->alternative_ls); break; case 7:// m3ua rc SET_INTEGER(temp); update_ls_influence_dst_table(3,ptr->dpc,instance[0],ptr->normal_ls, ptr->alternative_ls, temp, ptr->opc); SET_INTEGER(ptr->rc); break; case 8://ACN SET_OPAQUE(ptr->acn, MAX_ACN_NUM); break; case 9:// SET_U8(tmp); if(tmp == 6) { update_ls_influence_dst_table(3,0,instance[0],0, 0, 0, 0); memset(ptr, 0, sizeof(nw_route)); } break; default: break; } mtp3EnableSaveFlag(); return datalen; } int mtp3_get_sysparam(u32 column, u32 *instance, u8 *pdata, u8 *vartype) { int datalen=-1; WORD tmp=0; switch(column) { case 1: //mtp3lite port tmp = htons(mtp3_para->mtp3lite_port); GET_INTEGER(tmp); break; case 2: //command GET_U8(0); break; default: break; } return datalen; } int mtp3_set_sysparam(u32 column, u32 *instance, u8 *pdata, u16 datalen) { u8 command=0; WORD tmp=0; switch(column) { case 1: //mtp3lite port SET_INTEGER(tmp); mtp3_para->mtp3lite_port = htons(tmp); break; case 2: //command SET_U8(command); if(command==1) { mtp3_write_para(); reset_mtp3(); } else if(command ==2) { printf("save parameter\n"); mtp3_write_para(); } break; default: break; } mtp3EnableSaveFlag(); return datalen; } //MTP3 OID Prefix: {1,3,6,1,4,1,1373,2,3,2,2} static struct snmp_table_profile mtp3_tables[] = { /****** Parameter table ******/ { .name = "system", .index.len = 13, .index.oid = {1,3,6,1,4,1,1373,2,3,2,2,2,1}, .column = {0,1,2,3}, .level = 0, .get_instance = NULL, .get_resp = mtp3_get_sysparam, .set_resp = mtp3_set_sysparam }, { .name = "international network routing", .index.len = 14, .index.oid = {1,3,6,1,4,1,1373,2,3,2,2,2,2,5}, .column = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0}, .level = 1, .get_instance = mtp3_getnext_introute, .get_resp = mtp3_get_introute, .set_resp = mtp3_set_introute }, { .name = "international spare nw routing", .index.len = 14, .index.oid = {1,3,6,1,4,1,1373,2,3,2,2,2,3,5}, .column = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0}, .level = 1, .get_instance = mtp3_getnext_intsroute, .get_resp = mtp3_get_intsroute, .set_resp = mtp3_set_intsroute }, { .name = "national network routing", .index.len = 14, .index.oid = {1,3,6,1,4,1,1373,2,3,2,2,2,4,5}, .column = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0}, .level = 1, .get_instance = mtp3_getnext_natroute, .get_resp = mtp3_get_natroute, .set_resp = mtp3_set_natroute }, { .name = "national spare network routing", .index.len = 14, .index.oid = {1,3,6,1,4,1,1373,2,3,2,2,2,5,5}, .column = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0}, .level = 1, .get_instance = mtp3_getnext_natsroute, .get_resp = mtp3_get_natsroute, .set_resp = mtp3_set_natsroute }, { .name = "linkset", .index.len = 14, .index.oid = {1,3,6,1,4,1,1373,2,3,2,2,2,6,1}, .column = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0}, .level = 1, .get_instance = mtp3_getnext_linkset, .get_resp = mtp3_get_linkset, .set_resp = mtp3_set_linkset }, { .name = "link", .index.len = 14, .index.oid = {1,3,6,1,4,1,1373,2,3,2,2,2,7,1}, .column = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,15,16,0}, .level = 1, .get_instance = mtp3_getnext_link, .get_resp = mtp3_get_link, .set_resp = mtp3_set_link }, { .name = "sg", .index.len = 14, .index.oid = {1,3,6,1,4,1,1373,2,3,2,2,2,8,1}, .column = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0}, .level = 1, .get_instance = mtp3_getnext_sg, .get_resp = mtp3_get_sg, .set_resp = mtp3_set_sg } }; static struct snmp_register mtp3_register = { .name = "MTP3", .prefix_len = 11, .prefix_oid = {1, 3, 6, 1, 4, 1, 1373, 2, 3, 2, 2}, .num_of_table = sizeof(mtp3_tables)/sizeof(struct snmp_table_profile), .table = mtp3_tables, .default_get_resp = mtp_getmib, .default_set_resp = mtp_setmib }; void mtp3_snmp_registration(void) { register_snmp_table(&mtp3_register); } /*@end@*/