feat: create cook branch

This commit is contained in:
zhangsz
2025-03-08 16:40:56 +08:00
parent 9a139c52c6
commit 025a455e17
70 changed files with 3603 additions and 11829 deletions

View File

@@ -6,7 +6,7 @@
#define _MTP3_HEAD_FILE
#define _up_message up_message
#define MAX_SS7_MSG_LEN 400 //272
#define MAX_SS7_MSG_LEN 300 //272
typedef struct up_message{
long dest_ip;

View File

@@ -22,7 +22,7 @@
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/ioctl.h>
//#include <sys/io.h>
#include <sys/io.h>
#include <sys/poll.h>
#include <sys/stat.h>
#include <sys/wait.h>

View File

@@ -244,8 +244,6 @@ typedef struct _mtp3_state
BYTE tprc_state;
BYTE MTP3WatchDog[MAX_LK];
BYTE link_enable_sent_flag[MAX_LK];
}_mtp3_state;
extern _mtp3_state mtp3ObjState;

View File

@@ -165,7 +165,6 @@ int mtp3lite_InitClientSocket(WORD lk)
bzero(&sin_addr,sizeof(struct sockaddr));
sin_addr.sin_family = AF_INET;
//sin_addr.sin_port = htons(mtp3lite_port);
sin_addr.sin_addr.s_addr = GetLocalIP();
mtp3lite_link[lk].cliSockfd = -1;
if (isMtp3LiteClientLink(lk) && !checkIfOveridesocket(lk))
@@ -173,7 +172,7 @@ int mtp3lite_InitClientSocket(WORD lk)
//sin_addr.sin_port = mtp3_para->mtp3lite_port; //server port,tmp
//sin_addr.sin_addr.s_addr = mtp3_para->lk[lk].remote_ip;
//bzero(&(sin_addr.sin_zero),8);
if ((socketfd = mtp3lite_Init_TCPSocket(sin_addr,1)) < 0)
if ((socketfd = mtp3lite_Init_TCPSocket(sin_addr,0)) < 0)
{
printf("MTP3LITE TCP Client Socket(%d) Init Failed!\n",mtp3_para->mtp3lite_port);
//exit(1);
@@ -268,7 +267,7 @@ int mtp3lite_TcpConnectCheck()
bzero(&cliaddr,(clilen = sizeof(struct sockaddr)));
connfdtmp = accept(mtp3lite_listen_fd,(struct sockaddr *)&cliaddr,&clilen);
if (connfdtmp <= 0)//no connect request , check client socket
if (connfdtmp <= 0)//no connect request , check client socke
{
link = cliLk++;
if (!isMtp3LiteClientLink(link))
@@ -297,11 +296,6 @@ int mtp3lite_TcpConnectCheck()
mtp3lite_CloseTcpConn(link);
return 0;
}
else
{
mtp3lite_link[link].connfd = connfdtmp;
mtp3lite_updateStatus(link, MTP2_STATE_WORKING, 0);
}
return 0;
}
else if ((link = mtp3lite_get_lk_by_ip(&cliaddr)) < 0)
@@ -315,7 +309,7 @@ int mtp3lite_TcpConnectCheck()
mtp3lite_link[link].connfd = connfdtmp;
mtp3lite_link[link].cliSockfd = connfdtmp;
mtp3lite_link[link].remote_port = cliaddr.sin_port;
mtp3_debug(MTP3DB_EVENT,"link[%d] connfd: %d, rem_port: %d\n", link, connfdtmp, ntohs(mtp3lite_link[link].remote_port));
printf("link[%d] connfd: %d, rem_port: %d\n", link, connfdtmp, ntohs(mtp3lite_link[link].remote_port));
fcntl(mtp3lite_link[link].connfd,F_SETFL,O_NONBLOCK);
if (setsockopt(mtp3lite_link[link].connfd,SOL_SOCKET,SO_KEEPALIVE, &keepAlive,sizeof(keepAlive)) != 0)
@@ -332,24 +326,6 @@ int mtp3lite_TcpConnectCheck()
return 1;
}
int send_mtp3lite_id_ack(WORD link)
{
BYTE id_ack_msg[4]={0,0x1,0xfe, 0x6};
mtp3lite_DirectSendMsg(link, 4, id_ack_msg);
mtp3_debug(MTP3DB_EVENT,"mtp3-lite link %d send Inditify ACK",link);
return 1;
}
int send_mtp3lite_ping(WORD link)
{
BYTE id_ack_msg[4]={0x00,0x01,0xfe, 0x00};
mtp3lite_DirectSendMsg(link, 4, id_ack_msg);
mtp3_debug(MTP3DB_EVENT,"mtp3-lite link %d send PING",link);
return 1;
}
int mtp3lite_DirectRecvMsg(WORD link)
{
struct sockaddr_in sin;
@@ -360,19 +336,12 @@ int mtp3lite_DirectRecvMsg(WORD link)
// if ((len1 = mtp3lite_rem_len[link])>0)
// printf("len1: %d\n", len1);
len1 = mtp3lite_rem_len[link];
if(len >= MTP3LITE_MSG_BUF_SIZE_PER_LINK)
{
mtp3_debug(MTP3DB_EVENT, "mtp3lite link[%d] buffer is full!\n", link);
return 0;
}
nbytes = recvfrom(mtp3lite_link[link].connfd, mtp3lite_msg_buf[link] + len1,
MTP3LITE_MSG_BUF_SIZE_PER_LINK - len1, 0, (struct sockaddr *) &sin, &len);
if (nbytes == 0 && errno != 11)
if (nbytes == 0)
{
mtp3_debug(MTP3DB_EVENT, "mtp3lite tcp link[%d] error : %d\n", link, errno);
printf("tcp link[%d] error : %d\n", link, errno);
mtp3lite_CloseTcpConn(link);
mtp3lite_updateStatus(link, MTP2_STATE_STOP, MTP3LITE_TCP_FAILURE);
mtp3lite_rem_len[link] = 0;
@@ -499,9 +468,8 @@ int mtp3lite_decode_tcp_msg(WORD total_len, WORD link)
else if (sub_len == 1)
{
if(buf_ptr[1+2] == 0x6)
// if(buf_ptr[1+2] == 0x6 || buf_ptr[2] == 0x06)
{ // Receive Keep Alive Message
mtp3lite_link[link].remote_inactive = mtp3_para->lk[link].inactive * 200;
mtp3lite_link[link].remote_inactive = mtp3_para->lk[link].inactive * 100;
mtp3lite_link[link].remote_inactive_timeouts = 0;
//mtp3lite_print_msg(buf_ptr, 3);
total_hdl_len += (sub_len + 3);
@@ -510,17 +478,13 @@ int mtp3lite_decode_tcp_msg(WORD total_len, WORD link)
continue;
}
else
{
//mtp3_debug(MTP3DB_EVENT,"mtp3-lite link %d RECV IPA Ping!",link);
//send_mtp3lite_ping(link);
return -1;
}
}
// if ((buf_ptr[1+2] > 9) || (buf_ptr[1+2] == 0))
// return -1;
mtp3lite_link[link].remote_inactive = mtp3_para->lk[link].inactive * 200;
mtp3lite_link[link].remote_inactive = mtp3_para->lk[link].inactive * 100;
mtp3lite_link[link].remote_inactive_timeouts = 0;
//mtp3lite_print_msg(buf_ptr, sub_len + 1);
@@ -533,7 +497,7 @@ int mtp3lite_decode_tcp_msg(WORD total_len, WORD link)
//nw = mtp3_para->ls_pro[lk_set] & 3;
nw = mtp3_para->ls_pro[lk_set].nw_id ;
up_msg_ptr->sio = 0x03 | (nw << 6);//sccp lite always itu message
up_msg_ptr->sio |= (mtp3_para->nw[nw].pc_type & 1)<<4;//detect ansi or itu sccp, ansi=1,itu=0
up_msg_ptr->sio |= (mtp3_para->nw[nw].pc_len & 1)<<4;//detect ansi or itu sccp, ansi=1,itu=0
up_msg_ptr->opc = mtp3_para->ls_pro[lk_set].ls_op_pc;
if (pc_length(up_msg_ptr->sio >> 6) == MTP3_24BIT_PC)
up_msg_ptr->dpc = mtp3_para->nw[nw].opc24;
@@ -553,6 +517,14 @@ int mtp3lite_decode_tcp_msg(WORD total_len, WORD link)
return 1;
}
int send_mtp3lite_id_ack(WORD link)
{
BYTE id_ack_msg[4]={0,0x1,0xfe, 0x6};
mtp3lite_DirectSendMsg(link, 4, id_ack_msg);
mtp3_debug(MTP3DB_EVENT,"mtp3-lite link %d send Inditify ACK",link);
return 1;
}
int get_mtp3lite_msg(WORD link)
{
@@ -704,7 +676,7 @@ int mtp3lite_chk_lk(WORD link)
}
else
{
mtp3lite_link[link].remote_inactive = mtp3_para->lk[link].inactive * 200;
mtp3lite_link[link].remote_inactive = mtp3_para->lk[link].inactive * 100;
}
}
}
@@ -715,14 +687,12 @@ int mtp3lite_chk_lk(WORD link)
{
mtp3lite_id_fg[link] = 1;
send_mtp3lite_id_ack(link);
//send_mtp3lite_ping(link);
}
if (--mtp3lite_link[link].local_inactive == 0)
{
// mtp3lite_DirectSendMsg(link, 3, mtp3lite_ka_msg);
// put_mtp3lite_msg(&str);
mtp3lite_link[link].local_inactive = 2000;
send_mtp3lite_id_ack(link);
}
}

View File

@@ -865,7 +865,6 @@ static void i_sys()
mtp3ObjState.link_l3_state[i] = UNAVAILABLE;
mtp3ObjState.link_l2_state[i] = UNAVAILABLE;
mtp3ObjState.link_l1_state[i] = UNAVAILABLE;
mtp3ObjState.link_enable_sent_flag[i] = 0;
mtp3_set_link_manager(i);
@@ -993,8 +992,6 @@ int update_ls_slc_table(int link)
{
mtp3ObjState.lk_configured[link] = PARA_CONFIGURED;
mtp3ObjState.link_l3_state[link] = UNAVAILABLE;
mtp3ObjState.link_enable_sent_flag[link] = 0;
mtp3.ls[ls].linksNum_configured++;
ls_slc[lsx16+slc] = link;
// linknum_in_ls[ls]++;
@@ -1005,8 +1002,6 @@ int update_ls_slc_table(int link)
{
mtp3ObjState.lk_configured[link] = PARA_NOT_CONFIGURED;
mtp3ObjState.link_l3_state[link] = UNAVAILABLE;
mtp3ObjState.link_enable_sent_flag[link] = 0;
mtp3_heartbeat.link_state[idiv4] = mtp3_heartbeat.link_state[idiv4] | temp;
}
}
@@ -1173,11 +1168,11 @@ void init_mtp3table()
{
update_timer(i);
}
mtp3_para->mtp3_t10 = 126; //63;/* 40 SECOND, unit=640ms,for dpc */
mtp3_para->mtp3_t18 = 40;//20;
mtp3_para->mtp3_t19 = 8;//4;
mtp3_para->mtp3_t20 = 8;//4;
mtp3_para->mtp3_t21 = 750; //375;/* 30 SECOND,unit=80ms, for linkset */
mtp3_para->mtp3_t10 = 63;/* 40 SECOND, unit=640ms,for dpc */
mtp3_para->mtp3_t18 = 20;
mtp3_para->mtp3_t19 = 4;
mtp3_para->mtp3_t20 = 4;
mtp3_para->mtp3_t21 = 375;/* 30 SECOND,unit=80ms, for linkset */
mtp3ObjInput.tprc_input = TPRC_SP_RESTART_INDICATION;
own_sp_restarting = 1;
tprc_mgmt_signalling_point_restart_indication();
@@ -1229,8 +1224,6 @@ void mtp_shm_init(WORD moduleid_systemid, DWORD local_ip, DWORD peer_ip)
mtp_local_ip = local_ip;
mtp_peer_ip = peer_ip;
//mtp3_alterip = peer_ip;
printf("mtp3 complete init\n");
}

View File

@@ -8,7 +8,7 @@ int mtp3_send_netcap=0;
void reset_mtp3();
long atol(const char *nptr);
//int gettimeofday(struct timeval *tv,struct timezone *tz);
int gettimeofday(struct timeval *tv,struct timezone *tz);
struct tm *localtime(const time_t *timep);
void mtp3_list_link(WORD i);
@@ -19,8 +19,8 @@ extern BOOL mtp3DebugFull;
BYTE disp_flag;
BYTE disp_page[16];
static BYTE * disp_ptr;
static BYTE disp_length;
BYTE * disp_ptr;
BYTE disp_length;
static DWORD debug_mask=0;
void mtp3_show_routine_status(BYTE nw);

View File

@@ -2112,7 +2112,6 @@ void mtp3_setlink_to_IDLE(WORD link)
otherMTP3_managed_link_unavailable(link);
mtp3ObjState.link_l2_state[link] = UNAVAILABLE;
mtp3ObjState.link_l3_state[link] = UNAVAILABLE;
mtp3ObjState.link_enable_sent_flag[link] = 0;
}
}
@@ -3199,6 +3198,7 @@ void trap_mtp2 (BYTE oid_len,DWORD *oid_ptr,BYTE *msg_ptr,WORD msg_len,snmp_addr
}
}
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;
@@ -3218,7 +3218,6 @@ void mtp3_dealtrap(BYTE oid_len,DWORD *oid_ptr,BYTE *msg_ptr,WORD msg_len,snmp_a
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)
@@ -3255,7 +3254,6 @@ int mtp3_clear_all_peer_link_status()
if(mtp3ObjState.link_l3_state[link] == AVAILABLE)
{
mtp3ObjState.link_l3_state[link] = UNAVAILABLE;
mtp3ObjState.link_enable_sent_flag[link] = 0;
}
}
}
@@ -4530,8 +4528,5 @@ void mtp3_snmp_registration(void)
register_snmp_table(&mtp3_register);
}
int mtp3_get_net_pclen(int netid)
{
return mtp3_para->nw[netid%4].pc_len;
}
/*@end@*/

View File

@@ -30,7 +30,7 @@ extern mtp3_routing_result routingResult;
extern void mtp3_debug(int n,const char *fmt,...);
extern BYTE mtp3_check_dpc_equal_to_opc(BYTE nw, ulong dpc);
static int detail_debug_flag=0;
static int detail_debug_flag=1;
static int rc_timer=190;
extern DWORD mtp_local_ip, mtp_peer_ip;
@@ -472,46 +472,15 @@ int priority_own_link(WORD lsno,WORD sls)
return -1;
ls = &mtp3.ls[lsno];
if(detail_debug_flag)
{
if(1)
{
char buf[256];
char strbuf[1024];
mtp3_debug(MTP3DB_EVENT, "%s, linkset=%d, sls=%d, linkconfigred=%d ",
__FUNCTION__,
lsno,
sls,
mtp3.ls[lsno].linksNum_configured);
memset(strbuf, 0x00, 16);
for(i=0;i<2; i++)
{
link = ls_sls[(lsno<<4)+i];
sprintf(buf, "ls_sls[%02d]=%d, ip=%08x, state=%d",
i,
ls_sls[(lsno<<4)+i],
mtp3_para->lk[link].e1_to_mtp3,
mtp3ObjState.link_l3_state[link]);
strcat(strbuf, buf);
}
mtp3_debug(MTP3DB_EVENT, "%s, %s ",
__FUNCTION__,
strbuf);
}
}
for (i=0;i<16;i++)
// for (i=0;i<mtp3.ls[lsno].linksNum_configured;i++)
for (i=0;i<mtp3.ls[lsno].linksNum_configured;i++)
{
link = ls_sls[(lsno<<4)+i];
if (mtp3_para->lk[link].e1_to_mtp3 == mtp3_localip && mtp3ObjState.link_l3_state[link] == AVAILABLE)
return link;
}
for (i=0;i<16;i++)
// for (i=0;i<mtp3.ls[lsno].linksNum_configured;i++)
for (i=0;i<mtp3.ls[lsno].linksNum_configured;i++)
{
link = ls_sls[(lsno<<4)+i];
@@ -607,11 +576,14 @@ int check_outbound_route(BYTE nw, long dpc, WORD sls, long opc)
ls_info = &mtp3.ls[ls];
/* added for override link status -- start */
/*
if(m2ua_get_traffic_mode_type()==0)
{
if(ls_info->send_asp_ac_link_id>0 && ls_info->send_asp_ac_link_id != 0xffff)
{
if(detail_debug_flag)
mtp3_debug(MTP3DB_EVENT,
"[SCCP] M3UA ==> M2UA < %s > DPC=%d, Link=%d (asc link=%d)",__FUNCTION__, dpc, outlink,
ls_info->send_asp_ac_link_id);
return ls_info->send_asp_ac_link_id;
}
@@ -619,11 +591,14 @@ int check_outbound_route(BYTE nw, long dpc, WORD sls, long opc)
{
int link_no = get_asp_ac_link(ls,sls);
if(detail_debug_flag)
mtp3_debug(MTP3DB_EVENT,
"[SCCP] M3UA ==> M2UA < %s > DPC=%d, Link=%d (asc link=%d)",__FUNCTION__, dpc, link_no,
ls_info->send_asp_ac_link_id);
return link_no;
}
}
*/
/* added for override link status -- end*/
if (mtp3_para->lk[outlink].e1_to_mtp3 == mtp3_localip && mtp3ObjState.link_l3_state[outlink] == AVAILABLE)
@@ -639,11 +614,14 @@ int check_outbound_route(BYTE nw, long dpc, WORD sls, long opc)
ls_info = &mtp3.ls[ls];
/* added for override link status -- start */
/*
if(m2ua_get_traffic_mode_type()==0)
{
if(ls_info->send_asp_ac_link_id>0 && ls_info->send_asp_ac_link_id != 0xffff)
{
if(detail_debug_flag)
mtp3_debug(MTP3DB_EVENT,
"[SCCP] M3UA ==> M2UA < %s > DPC=%d(ALS), Link=%d (asc link=%d)",__FUNCTION__, dpc, outlink,
ls_info->send_asp_ac_link_id);
return ls_info->send_asp_ac_link_id;
}
@@ -651,11 +629,14 @@ int check_outbound_route(BYTE nw, long dpc, WORD sls, long opc)
{
int link_no = get_asp_ac_link(ls,sls);
if(detail_debug_flag)
mtp3_debug(MTP3DB_EVENT,
"[SCCP] M3UA ==> M2UA < %s > DPC=%d(ALS), Link=%d (asc link=%d)",__FUNCTION__, dpc, link_no,
ls_info->send_asp_ac_link_id);
return link_no;
}
}
*/
/* added for override link status -- end*/
if (mtp3_para->lk[outlink].e1_to_mtp3 == mtp3_localip && mtp3ObjState.link_l3_state[outlink] == AVAILABLE)
@@ -3035,7 +3016,7 @@ void m3ua_upd_route_status(WORD chl, DWORD rc, BYTE rc_status, BYTE ls_disable)
if( ls_disable == 0)
continue;
// sp->m3ua_rc_status[spplace] = rc_status;
sp->m3ua_rc_status[spplace] = rc_status;
if(detail_debug_flag)
mtp3_debug(MTP3DB_EVENT," <%s.%d> M3UA update route info, link=%d, sppace=%d, sp->routine=%d",
__FUNCTION__,
@@ -3043,19 +3024,15 @@ void m3ua_upd_route_status(WORD chl, DWORD rc, BYTE rc_status, BYTE ls_disable)
chl,
spplace, sp->routine[spplace]);
mark_normal_linkset_unavailable(&sp->routine[spplace]);
if ( ((sp->routine[spplace] >> 2) & 3) == 0 )/*alternative route available */
sp->routine[spplace] = (sp->routine[spplace] & 0x3f) + 0x40;/* current route change from normal linkset to alternative linkset */
else/* sp not accessible */
{
sp_unaccessable((BYTE *)&sp->routine[spplace]);
primitive_to_userpart(nw,mtp3_para->nw[nw].routing[spplace].dpc,UNAVAILABLE);
sp->m3ua_rc_status[spplace] = rc_status;
}
if(mtp3ObjState.lk_mtp3[chl] == mtp3_localip)
{
if(1)
if(mtp_peer_ip != 0)
{
send_route_to_other_plat(mtp3_para->nw[nw].routing[spplace].dpc,
@@ -3089,27 +3066,21 @@ void m3ua_upd_route_status(WORD chl, DWORD rc, BYTE rc_status, BYTE ls_disable)
continue;
//sp->m3ua_rc_status[spplace] = rc_status;
sp->m3ua_rc_status[spplace] = rc_status;
if(detail_debug_flag)
mtp3_debug(MTP3DB_EVENT," <%s.%d> M3UA ALS update route info, link=%d, sppace=%d, sp->routine=%d, rc_status=%d",
mtp3_debug(MTP3DB_EVENT," <%s.%d> M3UA ALS update route info, link=%d, sppace=%d, sp->routine=%d",
__FUNCTION__,
__LINE__,
chl,
spplace, sp->routine[spplace],
sp->m3ua_rc_status[spplace]);
mark_alternative_linkset_unavailable(&sp->routine[spplace]);
spplace, sp->routine[spplace]);
if ( (sp->routine[spplace] & 3) != 0 )/* normal route unavailable */
{
sp_unaccessable((BYTE *)&sp->routine[spplace]);
primitive_to_userpart(nw,mtp3_para->nw[nw].routing[spplace].dpc,UNAVAILABLE);
sp->m3ua_rc_status[spplace] = rc_status;
}
if(mtp3ObjState.lk_mtp3[chl] == mtp3_localip)
{
if(1)
if(mtp_peer_ip != 0)
{
send_route_to_other_plat(mtp3_para->nw[nw].routing[spplace].dpc,
@@ -3202,7 +3173,6 @@ void m3ua_upd_route_status(WORD chl, DWORD rc, BYTE rc_status, BYTE ls_disable)
primitive_to_userpart(nw,mtp3_para->nw[nw].routing[spplace].dpc,AVAILABLE);
}
if(1)
if(mtp3ObjState.lk_mtp3[chl] == mtp3_localip && mtp_peer_ip != 0)
{
send_route_to_other_plat(dpc,
@@ -3222,8 +3192,6 @@ void m3ua_upd_route_status(WORD chl, DWORD rc, BYTE rc_status, BYTE ls_disable)
__LINE__,
chl,
spplace, sp->routine[spplace]);
rc_timer = 100; //make sure 1 second later to send ASP_AC
}
sp = &mtp3.nw[nw];
@@ -3234,37 +3202,29 @@ void m3ua_upd_route_status(WORD chl, DWORD rc, BYTE rc_status, BYTE ls_disable)
// continue;
sp->m3ua_rc_status[spplace] = rc_status;
routine = (BYTE*)&sp->routine[spplace];
if(detail_debug_flag)
if(0)
mtp3_debug(MTP3DB_EVENT," <%s:%d> S5 ALS,M3UA update route info, link=%d, sppace=%d, sp->routine=%d",
__FUNCTION__, __LINE__,
chl,
spplace, *routine);
spplace, sp->routine[spplace]);
mark_alternative_linkset_available(&mtp3.nw[nw].routine[spplace]); //17-11-07
routine = (BYTE *)&mtp3.nw[nw].routine[spplace];
if ( (*routine) >> 6 == 2 )// no route
if ( (*routine) >> 6 == 2 )/* no route */
{
(*routine) = ((*routine) & 0x3f) + 0x40;// current route is alternative linkset
(*routine) = ((*routine) & 0x3f) + 0x40;/* current route is alternative linkset */
primitive_to_userpart(nw,mtp3_para->nw[nw].routing[spplace].dpc,AVAILABLE);
}
{
mark_alternative_linkset_available(&mtp3.nw[nw].routine[spplace]);
routine = (BYTE *)&mtp3.nw[nw].routine[spplace];
/*
if (Nlinkset_status(*routine) == LS_AVAILABLE)
(*routine) = ((*routine) & 0x3f); // current route is normal linkset
else if (Alinkset_status(*routine) == LS_AVAILABLE)
(*routine) = ((*routine) & 0x3f) + 0x40;
else
(*routine) = ((*routine) & 0x3f) + 0x80;
}
*/
if(0)
{
mark_alternative_linkset_available(&mtp3.nw[nw].routine[spplace]);
routine = (BYTE *)&mtp3.nw[nw].routine[spplace];
}
if(1)
if(mtp3ObjState.lk_mtp3[chl] == mtp3_localip && mtp_peer_ip != 0)
{
send_route_to_other_plat(mtp3_para->nw[nw].routing[spplace].dpc,
@@ -3274,15 +3234,17 @@ void m3ua_upd_route_status(WORD chl, DWORD rc, BYTE rc_status, BYTE ls_disable)
chl,
opc);
}
if(mtp3ObjState.lk_mtp3[chl] == mtp3_localip && mtp3_para->lk[chl].e1_to_alterMTP3 !=0)
send_route_to_other_plat(mtp3_para->nw[nw].routing[spplace].dpc, nw, sp->routine[spplace], mtp3_para->lk[chl].e1_to_alterMTP3, chl, opc);
}
if(detail_debug_flag)
mtp3_debug(MTP3DB_EVENT," <%s:%d> S5 ALS,M3UA update route info, link=%d, sppace=%d, sp->routine=%d",
__FUNCTION__, __LINE__,
chl,
spplace, sp->routine[spplace]);
if(mtp3ObjState.lk_mtp3[chl] == mtp3_localip && mtp3_para->lk[chl].e1_to_alterMTP3 !=0)
send_route_to_other_plat(mtp3_para->nw[nw].routing[spplace].dpc, nw, sp->routine[spplace], mtp3_para->lk[chl].e1_to_alterMTP3, chl, opc);
}
}
// if ((mtp3.nw[nw].routine[dpc_index] & 0x0f) == 0x0a)// all road unavailable
// mark_dstSP_inaccessible(&mtp3.nw[nw].routine[dpc_index]);
@@ -3400,7 +3362,6 @@ int m3ua_ssnm_update_route(xua_ssnm_cmd *p_ssnm)
else
primitive_to_userpart(nw,mtp3_para->nw[nw].routing[spplace].dpc,AVAILABLE);
if(1)
if(mtp3ObjState.lk_mtp3[link] == mtp3_localip && mtp_peer_ip != 0)
{
send_route_to_other_plat(mtp3_para->nw[nw].routing[spplace].dpc,
@@ -3425,12 +3386,10 @@ int m3ua_updateStatus(WORD chl, BYTE new_l2_state,BYTE command, DWORD rc, BYTE r
ls_info *ls;
int set_unaccessable = 0 ;
/*
if ((mtp3ObjState.lk_configured[chl] == PARA_NOT_CONFIGURED) ||
(mtp3ObjState.lk_mtp3[chl] != mtp3_localip))
return 0;
*/
rc_timer = 195+(mtp2_systemid%2)*5;
if (mtp3ObjState.lk_configured[chl] == PARA_NOT_CONFIGURED)
@@ -3459,7 +3418,7 @@ int m3ua_updateStatus(WORD chl, BYTE new_l2_state,BYTE command, DWORD rc, BYTE r
if (new_l2_state != mtp3ObjState.link_l2_state[chl])
{
if(detail_debug_flag)
// if(detail_debug_flag)
{
mtp3_debug(MTP3DB_ERROR,"m3ua_updateStatus, link=%d, l2_state=%d, command=%d, rc=%d, rc_status=%d",
chl, new_l2_state, command, rc, rc_status);
@@ -3517,36 +3476,11 @@ int m3ua_updateStatus(WORD chl, BYTE new_l2_state,BYTE command, DWORD rc, BYTE r
m3ua_upd_route_status(chl, rc, 5, 1);
mtp3.ls[ls_t].links_available ++;
ls->links_available_t = scan_ls_link_available(ls_t);
if(ls->links_available_t == 1)
{
if (mtp3ObjState.lk_mtp3[chl] != mtp3_localip)
ls->send_asp_ac_link_id = chl;
}
if(0)
{
if(ls->links_available_t== 1)
{
if(ls->send_asp_ac_link_id == 0x00 || ls->send_asp_ac_link_id == 0xffff )
{//for override mode
ls->send_asp_ac_link_id = chl;
m3ua_set_link_rc_to_m2ua(chl);
send_command_to_m3ua(chl, 1,M3UA_RC_CMD , rc, 0);
if(detail_debug_flag)
mtp3_debug(MTP3DB_EVENT,"<%s:%d> M3UA send RC_CMD, link=%d",
__FUNCTION__, __LINE__,
chl);
}
}
}
//mtp3ObjState.lk_mtp3[chl] = mtp3_localip;
mtp3ObjState.lk_mtp3[chl] = mtp3_localip;
}
else if (mtp3ObjState.link_l2_state[chl] == MTP2_STATE_WORKING)
{
@@ -3579,7 +3513,6 @@ int m3ua_updateStatus(WORD chl, BYTE new_l2_state,BYTE command, DWORD rc, BYTE r
if(ls->send_asp_ac_link_id == chl)
ls->send_asp_ac_link_id = 0xFFFF;
ls->links_nls_asp_ac_send_flag[chl] = 0;
ls->links_available_t = scan_ls_link_available(ls_t);
@@ -3668,9 +3601,8 @@ int GetM3uaMsg(ulong port)
chl = lm_lk_ptr->link;//???
new_l2_state = lm_lk_ptr->opercode;
if(new_l2_state)
m3ua_updateStatus(chl, new_l2_state, 0, 0 ,0);
mtp3_debug(MTP3DB_PRIMITIVE_MSG,"get M3UA link[%d], state=%d, heartbeat from %lx", chl, new_l2_state, msgSourceIP);
mtp3_debug(MTP3DB_PRIMITIVE_MSG,"get M3UA link heartbeat from %lx",msgSourceIP);
mtp3_showbuf(MTP3DB_PRIMITIVE_MSG,(BYTE *)mtp3_m3ua_msg,ntohs(lm_lk_ptr->len)+4);
return 0;
@@ -3787,22 +3719,9 @@ int GetM3uaMsg(ulong port)
int send_command_to_m3ua(WORD link, BYTE command, BYTE xua_msg_class, DWORD rc, DWORD aff_pc)
{
char charCmd[32];
static int rc_cmd_counter=0, total_cmd_counter=0;
if(0)
{
if(rc_cmd_counter < 5 && total_cmd_counter++ < 100)
{
char buf[128];
sprintf(buf, "link=%d, cmd=%d, xmc=%d", link, command, xua_msg_class);
pub_print_traceback(buf);
}
}
if(xua_msg_class == M3UA_RC_CMD)
{
rc_cmd_counter ++;
mtp3_iprt.io_msg.msgLength = 5+1+4+1;
mtp3_iprt.io_msg.msgContent[0] = xua_msg_class;
mtp3_iprt.io_msg.msgContent[2] = link>>8;
@@ -3811,9 +3730,6 @@ int send_command_to_m3ua(WORD link, BYTE command, BYTE xua_msg_class, DWORD rc,
mtp3_iprt.io_msg.msgContent[4] = 7;
mtp3_iprt.io_msg.msgContent[9] = command;
memcpy(&mtp3_iprt.io_msg.msgContent[5], &rc, 4);
sprintf(charCmd,"M3UA_ASP_Active");
}else if(xua_msg_class == M3UA_MGMT_CMD)
{
mtp3_iprt.io_msg.msgLength = 5+1+1;
@@ -3871,33 +3787,8 @@ void deactive_m3ua_lk(WORD link)
}
}
void m3ua_set_link_rc_to_m2ua(int linkno)
{
int i;
WORD lsno, spplace;
BYTE nw;
DWORD rc;
network *sp;
ls_info *ls;
lsno = mtp3_para->lk[linkno].e1_to_linkset;
if (lsno >= MAX_LS)
return;
ls = &mtp3.ls[lsno];
nw = mtp3_para->ls_pro[lsno].nw_id;
sp = &mtp3.nw[nw];
for ( i=0; i<(ls->influ_dstnum_asNLS % MAX_LS_DPC_ADD1); i++ )
{
spplace = ls->influ_dstplace_intable_asNLS[i];
rc = mtp3_para->nw[nw].routing[spplace].rc;
m2ua_set_sg_rc(linkno, rc);
}
}
void check_m3ua_link_status(int force_flag)
extern int m2ua_set_sg_rc(int linkno, int rc);
void check_m3ua_link_status()
{
int link,i;
WORD lsno, spplace;
@@ -3906,16 +3797,15 @@ void check_m3ua_link_status(int force_flag)
network *sp;
ls_info *ls;
static int link_timer=0;
int check_timer = ( mtp2_systemid * 30 + 400);
int check_timer = ( mtp2_systemid * 30 + 200);
int send_asp_ac_flag = 0;
if(rc_timer >= check_timer || force_flag)//2s
if(rc_timer >= check_timer)//2s
{
rc_timer = 0;
for(link=0;link<MAX_LK; link++)
{
// if(MTP3_LINK_TYPE(link) == LKTYPE_M3UA && (mtp3_para->lk[link].admin_state& 1)&&(check_if_local_ip(mtp3ObjState.lk_mtp3[link] )) ) //mtp3_localip))
if(MTP3_LINK_TYPE(link) == LKTYPE_M3UA && (mtp3_para->lk[link].admin_state& 1)&&(mtp3ObjState.lk_mtp3[link] == mtp3_localip))
{
if(mtp3ObjState.link_l3_state[link] == AVAILABLE)
@@ -3972,38 +3862,11 @@ void check_m3ua_link_status(int force_flag)
}
if(send_asp_ac_flag == 0)
{
//ls->send_asp_ac_link_id = link; //
if(0)
{
if(detail_debug_flag)
mtp3_debug(MTP3DB_EVENT,"<%s:%d> M3UA send RC_CMD, link=%d, total links=%d, sppace=%d, sp->routine=%d, act link=%d",
__FUNCTION__, __LINE__,
link,
ls->links_available_t,
spplace,
sp->routine[spplace],
ls->send_asp_ac_link_id);
}
}
else
{
if(ls->links_nls_asp_ac_send_flag[link] == 1)
send_asp_ac_flag = 0;
ls->send_asp_ac_link_id = link; //
}
}
else
{
if(0)
mtp3_debug(MTP3DB_EVENT,"<%s:%d> link=%d, sppace=%d, sp->routine=%d, rc_status=%d, lk_asp_ac=%d",
__FUNCTION__, __LINE__,
link,
spplace,
sp->routine[spplace],
sp->m3ua_rc_status[spplace],
ls->links_nls_asp_ac_send_flag[link]);
if(sp->m3ua_rc_status[spplace]!=5 || ls->links_nls_asp_ac_send_flag[link] == 0 )
{
@@ -4118,13 +3981,8 @@ void check_m3ua_link_status(int force_flag)
{
if(MTP3_LINK_TYPE(link) == LKTYPE_M3UA && (mtp3_para->lk[link].admin_state& 1) &&(mtp3ObjState.lk_mtp3[link] == mtp3_localip))
{
if(mtp3ObjState.link_l3_state[link] == UNAVAILABLE || mtp3ObjState.link_enable_sent_flag[link] == 0)
{
mtp3ObjState.link_enable_sent_flag[link] = 1;
if(mtp3ObjState.link_l3_state[link] == UNAVAILABLE)
send_command_to_m3ua(link, MTP3_M3UA_ENABLE,M3UA_MGMT_CMD,0, 0);
rc_timer = 100;
}
}
/* if(MTP3_LINK_TYPE(link) == LKTYPE_M3UA && mtp3ObjInput.lsac_input_from_mgmt[link] == LSAC_MGMT_DEACTIVATE_LINK)
{
@@ -4144,7 +4002,7 @@ void check_m3ua_link_status(int force_flag)
void m3ua_timer()
{
check_m3ua_link_status(0);
check_m3ua_link_status();
}
void send_mtp_msg(int outlink, BYTE *msgptr)
@@ -4264,9 +4122,7 @@ void send_mtp_msg(int outlink, BYTE *msgptr)
/* debug show message */
if(pclen == MTP3_24BIT_PC)
{
// memmove(m3ua_ptr->msg.m3ua.content, msgptr+11+1, len-8-1);
memmove(m3ua_ptr->msg.m3ua.content, msgptr+11+1, len-6-1);
memmove(m3ua_ptr->msg.m3ua.content, msgptr+11+1, len-8-1);
dpc = 0;
opc = 0;
sls = msgptr[11];
@@ -4277,9 +4133,7 @@ void send_mtp_msg(int outlink, BYTE *msgptr)
m3ua_ptr->msg_class = M3UA_MAUP_MSG;
m3ua_ptr->msg.m3ua.ni = nw;
m3ua_ptr->msg.m3ua.si = msgptr[4] & 0x0f;
// m3ua_ptr->msg.m3ua.len = ntohs(len - 8 - 1 - 4); //m3ua_ptr->msg.m3ua.len = ntohs(len - 8-1); //modify by Jink on 2012-11-01
m3ua_ptr->msg.m3ua.len = ntohs(len - 6 - 1 - 4); //m3ua_ptr->msg.m3ua.len = ntohs(len - 8-1); //modify by Jink on 2012-11-01
m3ua_ptr->msg.m3ua.len = ntohs(len - 8 - 1 - 4); //m3ua_ptr->msg.m3ua.len = ntohs(len - 8-1); //modify by Jink on 2012-11-01
m3ua_ptr->msg.m3ua.mp = 0;
m3ua_ptr->msg.m3ua.sls = sls;
m3ua_ptr->msg.m3ua.rc = get_m3ua_rc_by_dpc(nw, m3ua_ptr->msg.m3ua.dpc, m3ua_ptr->msg.m3ua.opc);
@@ -4419,7 +4273,6 @@ int update_route_by_other_plat(u32 dpc,BYTE nw, BYTE routine, WORD chl, u32 opc)
lsno = mtp3_para->lk[chl].e1_to_linkset;
ull opc_dpc=0;
return 0;
if (lsno >= MAX_LS)
return 0;
@@ -4438,24 +4291,14 @@ int update_route_by_other_plat(u32 dpc,BYTE nw, BYTE routine, WORD chl, u32 opc)
i = sort_rec->index[index];
else
return 0;
sp->routine[i] = routine;
if(detail_debug_flag)
mtp3_debug(MTP3DB_EVENT," <%s:%d> link=%d, linkset=%d, dpc=%d, sp->routine .local=%d,peer=%d",
mtp3_debug(MTP3DB_EVENT," <%s:%d> link=%d, linkset=%d, dpc=%d, sp->routine=%d",
__FUNCTION__, __LINE__,
chl,
lsno,
dpc,
sp->routine[i],
routine);
if(0)
if(sp->routine[i] != routine)
{
outroute = (sp->routine[i] >> 6) & 3;
if(outroute != 2)
return 0;
}
sp->routine[i] = routine;
outroute = (routine >> 6) & 3;
if ( outroute == 2 )/* no outbound route */
@@ -5010,15 +4853,12 @@ void hmrt_tcbc_update_routing_tables(WORD chl)
spplace = ls->influ_dstplace_intable_asNLS[i];
routine = (BYTE*)&sp->routine[spplace];
if(detail_debug_flag)
mtp3_debug(MTP3DB_EVENT,"\33[32m%s:%d : Link %d Linkset %d , routine: =%02x\33[0m",__FUNCTION__, __LINE__, chl, lsno,
mtp3_debug(MTP3DB_EVENT,"\33[32m%s: Link %d Linkset %d , routine: =%02x\33[0m",__FUNCTION__, chl, lsno,
*routine);
mark_normal_linkset_available(routine); //117-11-07
if (Nlinkset_status(*routine) == LS_AVAILABLE)
{
*routine = ((*routine) & 0x3f);/* current route is normal linkset */
if(1)
if(ls->links_nls_asp_ac_send_flag[spplace] == 0)
{
ls->links_nls_asp_ac_send_flag[spplace] = 1;
@@ -5028,7 +4868,6 @@ void hmrt_tcbc_update_routing_tables(WORD chl)
else if (Alinkset_status(*routine) == LS_AVAILABLE)
{
(*routine) = ((*routine) & 0x3f) + 0x40;
if(1)
if(ls->links_als_asp_ac_send_flag[spplace] == 0)
{
ls->links_als_asp_ac_send_flag[spplace] = 1;
@@ -5037,29 +4876,18 @@ void hmrt_tcbc_update_routing_tables(WORD chl)
}
else
{
//mark_normal_linkset_available(routine);
mark_normal_linkset_available(routine);
(*routine) = ((*routine) & 0x3f) + 0x80;
primitive_to_userpart(nw,mtp3_para->nw[nw].routing[spplace].dpc,AVAILABLE);
}
if(detail_debug_flag)
mtp3_debug(MTP3DB_EVENT,"\33[32m%s:%d : Link %d Linkset %d , routine: =%02x\33[0m",__FUNCTION__, __LINE__, chl, lsno,
*routine);
}
for ( i=0; i<(ls->influ_dstnum_asALS % MAX_LS_DPC_ADD1); i++ )
{
spplace = ls->influ_dstplace_intable_asALS[i];
routine = (BYTE*)&sp->routine[spplace];
if(detail_debug_flag)
mtp3_debug(MTP3DB_EVENT,"\33[32m%s:%d : Link %d Linkset %d , ssplace=%d, routine: =%02x\33[0m",__FUNCTION__, __LINE__, chl, lsno,
spplace, *routine);
mark_alternative_linkset_available(routine); //17-11-07
if ( (*routine) >> 6 == 2 )/* no route */
{
(*routine) = ((*routine) & 0x3f) + 0x40;/* current route is alternative linkset */
@@ -5073,36 +4901,23 @@ void hmrt_tcbc_update_routing_tables(WORD chl)
else
(*routine) = ((*routine) & 0x3f) + 0x80;
if(1)
if(ls->links_als_asp_ac_send_flag[spplace] == 0)
{
ls->links_als_asp_ac_send_flag[spplace] = 1;
ls->send_asp_ac_link_id = chl;
}
if(detail_debug_flag)
mtp3_debug(MTP3DB_EVENT,"\33[32m%s:%d : Link %d Linkset %d , routine: =%02x\33[0m",__FUNCTION__, __LINE__, chl, lsno,
*routine);
}
//if (mtp3ObjState.lk_mtp3[chl] == mtp3_localip) for dual alarm issue
mtp3_send_alarm(lsno+MTP3_LINKSET_COMPONENT,0);
set_heartbeat(ALARM_LS_AVAILABLE,lsno);
mtp3_para->ls_pro[lsno].ls_state = 1;//ALARM_LS_AVAILABLE;
}
if (mtp3ObjState.lk_mtp3[chl] == mtp3_localip)
mtp3_send_alarm(MTP3_LINK_COMPONENT+chl,0);
ls->links_available_t = scan_ls_link_available(lsno);
if (mtp3ObjState.lk_mtp3[chl] == mtp3_localip)
mtp3_send_alarm(MTP3_LINK_COMPONENT+chl,0);
else
{
if(ls->links_available_t >= 1)
{
if(ls->send_asp_ac_link_id == 0 || ls->send_asp_ac_link_id == 0xffff)
ls->send_asp_ac_link_id = chl;
}
}
if ( ls->links_available_t > 0 )
{
@@ -5115,15 +4930,12 @@ void hmrt_tcbc_update_routing_tables(WORD chl)
mtp3_debug(MTP3DB_EVENT,"\33[32m%s: Link %d L3 in service,Linkset %d in service\33[0m",__FUNCTION__, chl,lsno);
}
/*
if(link_already_available != AVAILABLE)
ls->links_available_t++;
else
mtp3_debug(MTP3DB_ERROR,"update routing table fail, links=%d have already available", chl);
*/
current_measure->lk_measure1[chl][1]++;/* local changeback */
// printf("\r\n tcbc %d update routine cmp link_available = %d \n\r",chl, ls->links_available_t);
}
@@ -5156,11 +4968,7 @@ void hmrt_tcoc_update_routing_tables(WORD chl)
if (link_inhibited[chl] == TRUE)
mtp3ObjState.link_l3_state[chl] = INHIBITED;
else
{
mtp3ObjState.link_l3_state[chl] = UNAVAILABLE;
mtp3ObjState.link_enable_sent_flag[chl] = 0;
}
set_heartbeat(ALARM_LINK_UNAVAILABLE,chl);
@@ -5213,9 +5021,8 @@ void hmrt_tcoc_update_routing_tables(WORD chl)
primitive_to_userpart(nw,mtp3_para->nw[nw].routing[spplace].dpc,UNAVAILABLE);
sp->m3ua_rc_status[spplace] = 0;
}
if(detail_debug_flag)
mtp3_debug(MTP3DB_ERROR,"%s:%d, Link=%d, changeover DPC=%d, rc_status=%d", __FUNCTION__, __LINE__,
chl, mtp3_para->nw[nw].routing[spplace].dpc, sp->m3ua_rc_status[spplace]);
mtp3_debug(MTP3DB_ERROR,"%s, Link=%d, changeover DPC=%d", __FUNCTION__, chl,
mtp3_para->nw[nw].routing[spplace].dpc);
}
@@ -5228,10 +5035,6 @@ void hmrt_tcoc_update_routing_tables(WORD chl)
primitive_to_userpart(nw,mtp3_para->nw[nw].routing[spplace].dpc,UNAVAILABLE);
sp->m3ua_rc_status[spplace] = 0;
}
if(detail_debug_flag)
mtp3_debug(MTP3DB_ERROR,"%s:%d, Link=%d, changeover DPC=%d, rc_status=%d", __FUNCTION__, __LINE__,
chl, mtp3_para->nw[nw].routing[spplace].dpc, sp->m3ua_rc_status[spplace]);
}
//memset(&ls_sls[lsx16],MAX_LK,16);