X-Git-Url: https://git.jankratochvil.net/?p=gnokii.git;a=blobdiff_plain;f=common%2Fdata%2Frlp-common.c;h=9c46e0d229330cf8b60ead3a41f35eab09eb0c75;hp=509faa725d14bef7d3e411d074ff1c856e6d6869;hb=0484268a27be1ab830d087847d830bc0ec734016;hpb=975a83d253eea8aa37bf3dfd7e026df3027db4ff diff --git a/common/data/rlp-common.c b/common/data/rlp-common.c index 509faa7..9c46e0d 100644 --- a/common/data/rlp-common.c +++ b/common/data/rlp-common.c @@ -16,8 +16,6 @@ */ -#include "config.h" - #include #include #include @@ -36,64 +34,59 @@ /* Our state machine which handles all of nine possible states of RLP machine. */ -static void MAIN_STATE_MACHINE(RLP_F96Frame *frame, RLP_F96Header *header); +void MAIN_STATE_MACHINE(RLP_F96Frame *frame, RLP_F96Header *header); /* This is the type we are just handling. */ -static RLP_FrameTypes CurrentFrameType; +RLP_FrameTypes CurrentFrameType; /* Current state of RLP state machine. */ -static RLP_State CurrentState=RLP_S0; /* We start at ADM and Detached */ +RLP_State CurrentState=RLP_S0; /* We start at ADM and Detached */ /* Next state of RLP state machine. */ -static RLP_State NextState; +RLP_State NextState; /* Pointer to Send function that sends frame to phone. */ -static bool (*RLPSendFunction)(RLP_F96Frame *frame, bool out_dtx); +bool (*RLPSendFunction)(RLP_F96Frame *frame, bool out_dtx); /* Pointer to Passup function which returns data/inds */ -static int (*RLP_Passup)(RLP_UserInds ind, u8 *buffer, int length); +int (*RLP_Passup)(RLP_UserInds ind, u8 *buffer, int length); /* State variables - see GSM 04.22, Annex A, section A.1.2 */ -static RLP_StateVariable UA_State; -/* -static RLP_StateVariable UI_State; -*/ -static RLP_StateVariable Ackn_State; -static RLP_StateVariable Poll_State; -static RLP_StateVariable Poll_xchg; -static RLP_StateVariable SABM_State; -static RLP_StateVariable DISC_State; -static RLP_StateVariable DM_State; /* FIXME - not handled */ -/* -static RLP_StateVariable XID_C_State; -*/ -static RLP_StateVariable XID_R_State; -/* -static RLP_StateVariable TEST_R_State; -*/ - -static u8 VR=0; -static u8 VA=0; -static u8 VS=0; -static u8 VD=0; -static u8 DISC_Count; - -static u8 DTX_VR; -static RLP_FrameTypes DTX_SF; +RLP_StateVariable UA_State; +RLP_StateVariable UI_State; +RLP_StateVariable Ackn_State; +RLP_StateVariable Poll_State; +RLP_StateVariable Poll_xchg; +RLP_StateVariable SABM_State; +RLP_StateVariable DISC_State; +RLP_StateVariable DM_State; /* FIXME - not handled */ +RLP_StateVariable XI_R_State; +RLP_StateVariable XID_C_State; +RLP_StateVariable XID_R_State; +RLP_StateVariable TEST_R_State; + +u8 VR=0; +u8 VA=0; +u8 VS=0; +u8 VD=0; +u8 DISC_Count; + +u8 DTX_VR; +RLP_FrameTypes DTX_SF; #define RLP_M 62 -static RLP_Data R[RLP_M]; -static RLP_Data S[RLP_M]; +RLP_Data R[RLP_M]; +RLP_Data S[RLP_M]; -static RLP_StateVariable SABM_State; -static int SABM_Count; +RLP_StateVariable SABM_State; +int SABM_Count; -static RLP_UserRequestStore UserRequests; +RLP_UserRequestStore UserRequests; -static u8 Poll_Count=0; +u8 Poll_Count=0; /* For now timing is done based on a frame reception rate of 20ms */ /* Serge has measured it as 18.4ms */ @@ -103,28 +96,28 @@ static u8 Poll_Count=0; /* To set, timer is loaded with RLP_Timeout1_Limit/RLP_T_Scaling. */ /* Each received frame (including NULLS / errors) any >0 timer is decrease */ -static int T; -static int T_RCVS[RLP_M]; +int T; +int T_RCVS[RLP_M]; -static bool UA_FBit=true; -static bool Ackn_FBit=false; -static bool DM_FBit=false; /* FIXME - not handled */ -static bool RRReady=false; -static bool LRReady=true; /* FIXME - not handled (as if we couldn't keep up with 9600bps :-) */ -static bool DISC_PBit=false; +bool UA_FBit=true; +bool Ackn_FBit=false; +bool DM_FBit=false; /* FIXME - not handled */ +bool RRReady=false; +bool LRReady=true; /* FIXME - not handled (as if we couldn't keep up with 9600bps :-) */ +bool DISC_PBit=false; -static u8 LastStatus=0xff; /* Last Status byte */ +u8 LastStatus=0xff; /* Last Status byte */ /* RLP Parameters. FIXME: Reset these - e.g. when entering state 0 */ -static u8 RLP_SEND_WS = RLP_M-1; -static u8 RLP_RCV_WS = RLP_M-1; -static u8 RLP_Timeout1_Limit = 55; -static u8 RLP_N2 = 15; /* Maximum number of retransmisions. GSM spec says 6 here, but - Nokia will XID this. */ -static u8 RLP_T2=0; -static u8 RLP_VersionNumber=0; +u8 RLP_SEND_WS = RLP_M-1; +u8 RLP_RCV_WS = RLP_M-1; +u8 RLP_Timeout1_Limit = 55; +u8 RLP_N2 = 15; /* Maximum number of retransmisions. GSM spec says 6 here, but + Nokia will XID this. */ +u8 RLP_T2=0; +u8 RLP_VersionNumber=0; @@ -204,7 +197,7 @@ void RLP_SetUserRequest(RLP_UserRequests type, bool value) { /* Check whether a user event is set */ -static bool RLP_GetUserRequest(RLP_UserRequests type) { +bool RLP_GetUserRequest(RLP_UserRequests type) { bool result=false, *x; @@ -237,7 +230,7 @@ static bool RLP_GetUserRequest(RLP_UserRequests type) { return result; } -static void RLP_SetTimer(int *timer) +void RLP_SetTimer(int *timer) { *timer=(int)(RLP_Timeout1_Limit/RLP_T_Scaling); } @@ -287,7 +280,7 @@ static bool InWindow(u8 val, u8 lower, u8 upper) return (val <= upper) || (val >= lower); } -static void RLP_Init_link_vars(void) +void RLP_Init_link_vars(void) { int i; @@ -312,7 +305,7 @@ static void RLP_Init_link_vars(void) } -static void RLP_AddRingBufferDataToSlots(void) +void RLP_AddRingBufferDataToSlots(void) { u8 buffer[24]; int size; @@ -336,11 +329,9 @@ static void RLP_AddRingBufferDataToSlots(void) } -#ifndef UCLINUX - /* FIXME: Remove this after finishing. */ -static void X(RLP_F96Frame *frame) { +void X(RLP_F96Frame *frame) { int i; @@ -349,10 +340,9 @@ static void X(RLP_F96Frame *frame) { } -#endif /* UCLINUX */ -static void ResetAllT_RCVS(void) +void ResetAllT_RCVS(void) { int i; @@ -363,7 +353,7 @@ static void ResetAllT_RCVS(void) /* This function is used for sending RLP frames to the phone. */ -static void RLP_SendF96Frame(RLP_FrameTypes FrameType, +void RLP_SendF96Frame(RLP_FrameTypes FrameType, bool OutCR, bool OutPF, u8 OutNR, u8 OutNS, u8 *OutData, u8 OutDTX) @@ -604,8 +594,6 @@ static void RLP_SendF96Frame(RLP_FrameTypes FrameType, } -static void RLP_DecodeF96Header(RLP_F96Frame *frame, RLP_F96Header *header); - /* Check_input_PDU in Serge's code. */ void RLP_DisplayF96Frame(RLP_F96Frame *frame) @@ -942,14 +930,14 @@ void RLP_DisplayF96Frame(RLP_F96Frame *frame) /* FIXME: real TEST_Handling - we do not handle TEST yet. */ -static void TEST_Handling() { +void TEST_Handling() { } /* FIXME: better XID_handling - but this will answer a XID command. */ -static bool XID_Handling (RLP_F96Frame *frame, RLP_F96Header *header) { +bool XID_Handling (RLP_F96Frame *frame, RLP_F96Header *header) { u8 count; u8 type; @@ -1038,7 +1026,7 @@ static bool XID_Handling (RLP_F96Frame *frame, RLP_F96Header *header) { } -static bool Send_TXU(RLP_F96Frame *frame, RLP_F96Header *header) { +bool Send_TXU(RLP_F96Frame *frame, RLP_F96Header *header) { #ifdef DEBUG // fprintf(stdout, _("Send_TXU()\n")); @@ -1082,7 +1070,7 @@ static bool Send_TXU(RLP_F96Frame *frame, RLP_F96Header *header) { /* Deliver data */ -static void RLP_DeliverAllInSeqIF() +void RLP_DeliverAllInSeqIF() { int i,j; @@ -1110,7 +1098,7 @@ static void RLP_DeliverAllInSeqIF() /* Mark any missing information frames between VR and Ns*/ -static void RLP_MarkMissingIF(u8 Ns) +void RLP_MarkMissingIF(u8 Ns) { u8 i; for (i=VR; i!=Ns; i=Incr(i)) { @@ -1121,7 +1109,7 @@ static void RLP_MarkMissingIF(u8 Ns) /* Information frame handler */ -static bool RLP_I_Handler(RLP_F96Frame *frame, RLP_F96Header *header) +bool RLP_I_Handler(RLP_F96Frame *frame, RLP_F96Header *header) { if ((header->CR) && (header->PF)) @@ -1154,7 +1142,7 @@ static bool RLP_I_Handler(RLP_F96Frame *frame, RLP_F96Header *header) /* Mark acknowledged send frames */ -static void RLP_AdvanceVA(u8 Nr) +void RLP_AdvanceVA(u8 Nr) { while (VA!=Nr) { S[VA].State=_idle; @@ -1165,7 +1153,7 @@ static void RLP_AdvanceVA(u8 Nr) /* Decrease VS back down to Nr since these have not been acknowledged */ -static void RLP_DecreaseVS(u8 Nr) +void RLP_DecreaseVS(u8 Nr) { while (VS!=Nr) { VS=Decr(VS); @@ -1175,7 +1163,7 @@ static void RLP_DecreaseVS(u8 Nr) /* Supervisory frame handling */ -static void RLP_S_Handler(RLP_F96Frame *frame, RLP_F96Header *header) +void RLP_S_Handler(RLP_F96Frame *frame, RLP_F96Header *header) { u8 i; @@ -1231,7 +1219,7 @@ static void RLP_S_Handler(RLP_F96Frame *frame, RLP_F96Header *header) /* Find the first SREJ frame */ -static bool RLP_SREJSlot(u8 *x) +bool RLP_SREJSlot(u8 *x) { u8 i; @@ -1247,7 +1235,7 @@ static bool RLP_SREJSlot(u8 *x) /* Check if any SREJ frames need sending, if not send the next in line */ -static bool RLP_PrepareDataToTransmit(u8 *p) +bool RLP_PrepareDataToTransmit(u8 *p) { u8 i; @@ -1270,7 +1258,7 @@ static bool RLP_PrepareDataToTransmit(u8 *p) /* Send a SREJ command */ -static void RLP_SendSREJ(u8 x) +void RLP_SendSREJ(u8 x) { u8 k; @@ -1310,7 +1298,7 @@ static void RLP_SendSREJ(u8 x) /* Send a command */ -static void RLP_Send_XX_Cmd(RLP_FrameTypes type) +void RLP_Send_XX_Cmd(RLP_FrameTypes type) { u8 k; @@ -1348,7 +1336,7 @@ static void RLP_Send_XX_Cmd(RLP_FrameTypes type) /* Send a Response */ -static void RLP_Send_XX_Resp(RLP_FrameTypes type) +void RLP_Send_XX_Resp(RLP_FrameTypes type) { u8 k; @@ -1374,7 +1362,7 @@ static void RLP_Send_XX_Resp(RLP_FrameTypes type) /* Decide which frame to use and send it - currently only used in state 4 */ -static void RLP_SendData() +void RLP_SendData() { u8 x; @@ -1394,7 +1382,7 @@ static void RLP_SendData() else RLP_Send_XX_Cmd(RLPFT_S_RNR); } -static void MAIN_STATE_MACHINE(RLP_F96Frame *frame, RLP_F96Header *header) { +void MAIN_STATE_MACHINE(RLP_F96Frame *frame, RLP_F96Header *header) { int i; switch (CurrentState) { @@ -1755,6 +1743,7 @@ static void MAIN_STATE_MACHINE(RLP_F96Frame *frame, RLP_F96Header *header) { if(SABM_State!=_idle) printf("[SABM_State %d]",SABM_State); if(DISC_State!=_idle) printf("[DISC_State %d]",DISC_State); if(DM_State!=_idle) printf("[DM_State %d]",DM_State); + if(XI_R_State!=_idle) printf("[XI_R_State %d]",XI_R_State); if(XID_C_State!=_idle) printf("[XID_C_State %d]",XID_C_State); if(XID_R_State!=_idle) printf("[XID_R_State %d]",XID_R_State); if(TEST_R_State!=_idle) printf("[TEST_R_State %d]",TEST_R_State); @@ -1936,9 +1925,7 @@ static void MAIN_STATE_MACHINE(RLP_F96Frame *frame, RLP_F96Header *header) { exact implementation of section 5.2.2.6, Exchange Identification, XID of the GSM specification 04.22. */ -#ifdef RLP_DEBUG - -static void RLP_DisplayXID(u8 *frame) +void RLP_DisplayXID(u8 *frame) { int count = 25; /* Sanity check */ @@ -2018,12 +2005,10 @@ static void RLP_DisplayXID(u8 *frame) return; } -#endif /* RLP_DEBUG */ - /* Given a pointer to an F9.6 Frame, split data out into component parts of header and determine frame type. */ -static void RLP_DecodeF96Header(RLP_F96Frame *frame, RLP_F96Header *header) +void RLP_DecodeF96Header(RLP_F96Frame *frame, RLP_F96Header *header) { /* Poll/Final bit. */