diff options
| author | Dave Hibberd <hibby@debian.org> | 2025-07-14 23:14:11 +0100 |
|---|---|---|
| committer | Dave Hibberd <hibby@debian.org> | 2025-07-14 23:14:11 +0100 |
| commit | b2315840b26a7ae5c38b0f9ed25e597f320c545e (patch) | |
| tree | 4eaec3a3c8f5825155c5a94161dbd7e360a35c0e /AGWAPI.c | |
| parent | 0d3ee7fd56efa24ba652fbc17f98dd10458e8054 (diff) | |
New upstream version 6.0.24.75+repackupstream/6.0.24.75+repack
Diffstat (limited to 'AGWAPI.c')
| -rw-r--r-- | AGWAPI.c | 60 |
1 files changed, 43 insertions, 17 deletions
@@ -36,7 +36,8 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses struct AGWHeader
{
- unsigned int Port;
+ uint8_t Port;
+ uint8_t filler1[3];
unsigned char DataKind;
unsigned char filler2;
unsigned char PID;
@@ -128,7 +129,7 @@ int DataSocket_Write(struct AGWSocketConnectionInfo * sockptr, SOCKET sock); int AGWGetSessionKey(char * key, struct AGWSocketConnectionInfo * sockptr);
int ProcessAGWCommand(struct AGWSocketConnectionInfo * sockptr);
int SendDataToAppl(int Stream, byte * Buffer, int Length);
-int InternalAGWDecodeFrame(char * msg, char * buffer, time_t Stamp, int * FrameType, int useLocalTime, int doNodes);
+int InternalAGWDecodeFrame(MESSAGE * msg, char * buffer, time_t Stamp, int * FrameType, int useLocalTime, int doNodes);
int AGWDataSocket_Disconnect( struct AGWSocketConnectionInfo * sockptr);
int SendRawPacket(struct AGWSocketConnectionInfo * sockptr, char *txmsg, int Length);
int ShowApps();
@@ -720,7 +721,7 @@ int AGWDoMonitorData() RawLen = monbuff->LENGTH;
- if (RawLen < 7 || RawLen > 350)
+ if (RawLen < MSGHDDRLEN || RawLen > 350)
{
ReleaseBuffer(monbuff);
FreeSemaphore(&Semaphore);
@@ -734,12 +735,16 @@ int AGWDoMonitorData() ReleaseBuffer(monbuff);
FreeSemaphore(&Semaphore);
+
+ // Set monbuff to point to the copy
+
+ monbuff = (MESSAGE *)Buffer;
//' 4 byte chain
//' 1 byte port - top bit = transmit
//' 2 byte length (LO-HI)
- Port = Buffer[4];
+ Port = monbuff->PORT;
if (Port > 127)
{
@@ -751,6 +756,12 @@ int AGWDoMonitorData() RXFlag = TRUE;
}
+ if (Port == 0)
+ {
+ Debugprintf("AGWMON Port number is zero");
+ return 0;
+ }
+
// Can now have different mon flags per connection, so need to run decode for each socket
for (n = 1; n<= CurrentSockets; n++)
@@ -759,7 +770,7 @@ int AGWDoMonitorData() if (sockptr->SocketActive && sockptr->MonFlag && (RXFlag || LoopMonFlag))
{
- Length = InternalAGWDecodeFrame(Buffer, AGWBuffer, Stamp, &Frametype, sockptr->useLocalTime, sockptr->doNodes);
+ Length = InternalAGWDecodeFrame(monbuff, AGWBuffer, Stamp, &Frametype, sockptr->useLocalTime, sockptr->doNodes);
if (Length > 0)
{
@@ -803,7 +814,7 @@ int AGWDoMonitorData() }
}
- RawLen = RawLen - 6;
+ RawLen = RawLen - (MSGHDDRLEN - 1); // One more for KISS control
if (RXFlag || Loopflag) // Send transmitted frames if requested
{
@@ -811,8 +822,12 @@ int AGWDoMonitorData() //
// Send raw data to any sockets that have requested Raw frames
//
-
- Buffer[6]=0;
+
+ // Format is ax.25 packet prceeded by a KISS command byte 00 for channel 1 0x10 for channel 2 etc
+ // As this is an application API I think all should go as Port 1
+
+
+ Buffer[MSGHDDRLEN - 1] = 0; // Just in case big-endian
AGWTXHeader.Port = Port - 1; // AGW Ports start from 0
AGWTXHeader.DataKind = 'K';
@@ -824,14 +839,12 @@ int AGWDoMonitorData() sockptr=&Sockets[n];
if (sockptr->SocketActive && sockptr->RawFlag)
- SendRawPacket(sockptr, &Buffer[6], RawLen);
+ SendRawPacket(sockptr, &Buffer[MSGHDDRLEN - 1], RawLen);
}
}
}
-
- return 0;
-
+ return 0;
}
int DeleteConnection(struct BPQConnectionInfo * Con)
@@ -1128,6 +1141,7 @@ int AGWDataSocket_Read(struct AGWSocketConnectionInfo * sockptr, SOCKET sock) int ProcessAGWCommand(struct AGWSocketConnectionInfo * sockptr)
{
int AGWVersion[2]={2003,999};
+ byte AGWPortCaps[12] = { 0, 255, 30, 10, 63, 10, 4, 0, 1, 0, 0, 0 };
char AGWRegReply[1];
struct BPQConnectionInfo * Connection;
int Stream;
@@ -1195,7 +1209,7 @@ int ProcessAGWCommand(struct AGWSocketConnectionInfo * sockptr) // Need to convert port index (used by AGW) to port number
- conport=GetPortNumber(VisiblePortToRealPort[key[0]-48]);
+ conport=GetPortNumber(VisiblePortToRealPort[key[0]-49] + 1);
n = sprintf(ConnectMsg,"C %d %s",conport,ToCall);
@@ -1293,9 +1307,7 @@ int ProcessAGWCommand(struct AGWSocketConnectionInfo * sockptr) // Version
memset(&AGWTXHeader,0,36);
-
AGWTXHeader.DataKind = 'R';
-
AGWTXHeader.DataLength = 8; // Length
SendtoSocket(sockptr->socket, (char *)&AGWVersion[0]);
@@ -1309,15 +1321,27 @@ int ProcessAGWCommand(struct AGWSocketConnectionInfo * sockptr) memset(&AGWTXHeader,0,36);
-
AGWTXHeader.DataKind = 'G';
-
AGWTXHeader.DataLength =(int)strlen(AGWPorts)+1; // Length
SendtoSocket(sockptr->socket, AGWPorts);
return 0;
+
+ case 'g': + + // Port capabilities. Currently hard-coded. + + AGWTXHeader.Port = sockptr->AGWRXHeader.Port; + AGWTXHeader.DataKind = 'g'; + AGWTXHeader.DataLength = 12; + + SendtoSocket(sockptr->socket, (char *)&AGWPortCaps[0]); + + return 0; + +
case 'k':
@@ -1416,6 +1440,8 @@ int ProcessAGWCommand(struct AGWSocketConnectionInfo * sockptr) AGWTXHeader.DataKind = 'X';
+ memcpy(&AGWTXHeader.callfrom, RegCall, 10);
+
AGWTXHeader.DataLength = 1; // Length
AGWRegReply[0] = 1;
|
