|
SQ6BOT > PSBBS 02.07.96 17:12l 110 Lines 2875 Bytes #-10324 (0) @ WW
BID : 276SR6BOX007
Read: GUEST
Subj: Loopback is almost ready!
Path: DB0AAB<DB0MFG<DB0PV<DB0WGS<OE3XSR<OE3XZR<OK0PBX<SP6KBL<SR6BOX
Sent: 960702/0344z @:SR6BOX.#WRO.POL.EU [BayCom-Mailbox [Wroclaw]] BCM1.37b
From: SQ6BOT @ SR6BOX.#WRO.POL.EU (Zipu)
To : PSBBS @ WW
Hi,
I was too unpatient and I sent these sources with lots of temporary
things. I just (5:30 AM ;-) ) finished rebuilding, separating and
cleaning up sources. Now it looks as follows:
BBS user level
^ |
| v
(buffer) (I haven't made any range checking here yet - filling
^ | this buffer up should cause sending RNR)
| v
AX.25 level (or just protocol level)
(buffer)
^ |
| v
Hardware level
and there is no such mess as there was before.
Here is an example - hardware level functions that support loopback.
Loopback_Tx() is called by AX.25 level function, that prepares whole
frame. It can be also called by, say, TCP/IP level function, or
any else.
Loopback_Rx() is running as a process (forked while attaching interface)
and checks if there is data available. If there is - it calls upper level
function (AX.25 interpreter - or anything else).
For each hardware it's enough to substitute only these two functions.
For example - for KISS TNC: KISS_Tx will send data through RS232 ( :-( )
instead of memcpy'ing and KISS_Rx will check whether TNC has some
data available. If it has - function will create axframe structure,
fill it and call upper level routine.
So you can try to write hardware drivers (when I send rest of sources
with definitions of structures like axframe, etc.)
Loopback functions follow this message.
73 de Peter
-------------------------------------------------------------------
/*
* This is ONLY for loopback - send frame immediately
*/
int Loopback_Tx(struct interface *i,struct axframe *axf)
{
int k;
struct axframe *in;
/*
* This is done by simple copying to loopback's input buffer.
* If there's no place then frame is discarded :-(
*/
/* Count waiting frames */
k=0;
in=i->Frame;
while(in!=NULL){
in=in->next;
k++;
}
if(k>=10)
/* There's no place for adding new frame - Goodbye! */
return(-1);
/* There IS place for new frame */
disable(); /* It should be atomic */
/* Create axframe structure */
in=calloc(1,sizeof(struct session));
if(i->Frame==NULL){
in->next=NULL;
i->Frame=in;
}else{
in->next=i->Frame->next;
i->Frame->next=in;
}
in->size=axf->size;
in->S=axf->S;
/* Create buffer */
in->buf=calloc(1,axf->size);
/* Following line contains the whole loopback idea ;-) */
memcpy(in->buf,axf->buf,axf->size);
enable();
}
/*
* Read from loopback
*/
int Loopback_Rx()
{
while(1){
if(CurProc->iface->Frame==NULL)
ForceSwitch(); /* Don't overload CPU if it's not necessary */
while(CurProc->iface->Frame!=NULL)
/* There is a frame in receive queue */
ReceiveAX25();
}
}
Read previous mail | Read next mail
| |