diff options
Diffstat (limited to 'bpqaxip.c')
| -rw-r--r-- | bpqaxip.c | 51 |
1 files changed, 35 insertions, 16 deletions
@@ -204,7 +204,7 @@ int Update_MH_KeepAlive(struct AXIPPORTINFO * PORT, struct in_addr ipad, char pr unsigned short int compute_crc(unsigned char *buf,int l);
unsigned int find_arp(unsigned char * call);
BOOL add_arp_entry(struct AXIPPORTINFO * PORT, unsigned char * call, UCHAR * ip, int len, int port,unsigned char * name,
-int keepalive, BOOL BCFlag, BOOL AutoAdded, int TCPMode, int SourcePort, BOOL IPv6, int noUpdate);
+ int keepalive, BOOL BCFlag, BOOL AutoAdded, int TCPMode, int SourcePort, BOOL IPv6, int noUpdate, int useSourcePort);
BOOL add_bc_entry(struct AXIPPORTINFO * PORT, unsigned char * call, int len);
BOOL convtoax25(unsigned char * callsign, unsigned char * ax25call, int * calllen);
static BOOL ReadConfigFile(int Port);
@@ -213,7 +213,7 @@ int CheckKeepalives(struct AXIPPORTINFO * PORT); BOOL CopyScreentoBuffer(char * buff, struct AXIPPORTINFO * PORT);
int DumpFrameInHex(unsigned char * msg, int len);
VOID SendFrame(struct AXIPPORTINFO * PORT, struct arp_table_entry * arp_table, UCHAR * buff, int txlen);
-BOOL CheckSourceisResolvable(struct AXIPPORTINFO * PORT, char * call, int Port, VOID * rxaddr);
+BOOL CheckSourceisResolvable(struct AXIPPORTINFO * PORT, char * call, int FromPort, VOID * rxaddr, int ToPort);
int DataSocket_Read(struct arp_table_entry * sockptr, SOCKET sock);
int GetMessageFromBuffer(struct AXIPPORTINFO * PORT, char * Buffer);
int KissEncode(UCHAR * inbuff, UCHAR * outbuff, int len);
@@ -429,7 +429,7 @@ static size_t ExtProc(int fn, int port, PMESSAGE buff) if (PORT->Checkifcanreply)
{
- if (CheckSourceisResolvable(PORT, call, 0, &RXaddr))
+ if (CheckSourceisResolvable(PORT, call, 0, &RXaddr, 0))
return 1;
@@ -437,7 +437,7 @@ static size_t ExtProc(int fn, int port, PMESSAGE buff) // Can't reply. If AutoConfig is set, add to table and accept, else reject
if (PORT->AutoAddARP)
- return add_arp_entry(PORT, call, (UCHAR *)&RXaddr.rxaddr.sin_addr.s_addr, 7, 0, inet_ntoa(RXaddr.rxaddr.sin_addr), 0, PORT->AutoAddBC, TRUE, 0, 0, FALSE, 0);
+ return add_arp_entry(PORT, call, (UCHAR *)&RXaddr.rxaddr.sin_addr.s_addr, 7, 0, inet_ntoa(RXaddr.rxaddr.sin_addr), 0, PORT->AutoAddBC, TRUE, 0, 0, FALSE, 0, 0);
else
{
char From[11] = "|";
@@ -536,7 +536,7 @@ static size_t ExtProc(int fn, int port, PMESSAGE buff) if (PORT->Checkifcanreply)
{
- if (CheckSourceisResolvable(PORT, call, htons(RXaddr.rxaddr.sin_port), &RXaddr))
+ if (CheckSourceisResolvable(PORT, call, htons(RXaddr.rxaddr.sin_port), &RXaddr, PORT->udpport[i]))
return 1;
else
{
@@ -547,10 +547,10 @@ static size_t ExtProc(int fn, int port, PMESSAGE buff) {
char Addr[80];
Format_Addr((UCHAR *)&RXaddr.rxaddr6.sin6_addr, Addr, TRUE);
- return add_arp_entry(PORT, call, (UCHAR *)&RXaddr.rxaddr6.sin6_addr, 7, htons(RXaddr.rxaddr6.sin6_port), Addr, 0, PORT->AutoAddBC, TRUE, 0, PORT->udpport[i], TRUE, 0);
+ return add_arp_entry(PORT, call, (UCHAR *)&RXaddr.rxaddr6.sin6_addr, 7, htons(RXaddr.rxaddr6.sin6_port), Addr, 0, PORT->AutoAddBC, TRUE, 0, PORT->udpport[i], TRUE, 0, 0);
}
else
- return add_arp_entry(PORT, call, (UCHAR *)&RXaddr.rxaddr.sin_addr.s_addr, 7, htons(RXaddr.rxaddr.sin_port), inet_ntoa(RXaddr.rxaddr.sin_addr), 0, PORT->AutoAddBC, TRUE, 0, PORT->udpport[i], FALSE, 0);
+ return add_arp_entry(PORT, call, (UCHAR *)&RXaddr.rxaddr.sin_addr.s_addr, 7, htons(RXaddr.rxaddr.sin_port), inet_ntoa(RXaddr.rxaddr.sin_addr), 0, PORT->AutoAddBC, TRUE, 0, PORT->udpport[i], FALSE, 0, 0);
else
{
char From[11] = "|";
@@ -733,7 +733,7 @@ VOID SendFrame(struct AXIPPORTINFO * PORT, struct arp_table_entry * arp_table, U return;
}
- // Seelcte source port by choosing right socket
+ // Select source port by choosing right socket
// First Set Default for Protocol
@@ -1343,6 +1343,7 @@ LRESULT FAR PASCAL ConfigWndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lPa char axcall[7];
BOOL UDPFlag, BCFlag;
struct AXIPPORTINFO * PORT;
+ int useSourcePort = 0;
for (i=1; i <= MAXBPQPORTS; i++)
{
@@ -1391,7 +1392,7 @@ LRESULT FAR PASCAL ConfigWndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lPa {
if (convtoax25(call,axcall,&calllen))
{
- add_arp_entry(PORT, axcall,0,calllen,port,host,Interval, BCFlag, FALSE, 0, port, FALSE, 0);
+ add_arp_entry(PORT, axcall,0,calllen,port,host,Interval, BCFlag, FALSE, 0, port, FALSE, 0, useSourcePort);
ResolveDelay = 2;
return(DestroyWindow(hWnd));
}
@@ -2147,6 +2148,7 @@ static int ProcessLine(char * buf, struct AXIPPORTINFO * PORT) int Interval;
int noUpdate=FALSE;
int TCPMode;
+ int useSourcePort = 0;
ptr = strtok(buf, " \t\n\r");
@@ -2234,6 +2236,7 @@ static int ProcessLine(char * buf, struct AXIPPORTINFO * PORT) bcflag=0;
TCPMode=0;
SourcePort = 0;
+ useSourcePort = 0;
//
// Look for (optional) KEEPALIVE, DYNAMIC, UDP or BROADCAST params
@@ -2264,7 +2267,14 @@ static int ProcessLine(char * buf, struct AXIPPORTINFO * PORT) if (p_udpport == NULL) return (FALSE);
- port = atoi(p_udpport);
+ if (_stricmp(p_udpport,"FROMPORT") == 0)
+ {
+ useSourcePort = TRUE;
+ port = 0;
+ }
+ else
+ port = atoi(p_udpport);
+
p_UDP = strtok(NULL, " \t\n\r");
continue;
}
@@ -2327,7 +2337,7 @@ static int ProcessLine(char * buf, struct AXIPPORTINFO * PORT) if (SourcePort == 0)
SourcePort = port;
- add_arp_entry(PORT, axcall, 0, calllen, port, p_ipad, Interval, bcflag, FALSE, TCPMode, SourcePort, FALSE, noUpdate);
+ add_arp_entry(PORT, axcall, 0, calllen, port, p_ipad, Interval, bcflag, FALSE, TCPMode, SourcePort, FALSE, noUpdate, useSourcePort);
return (TRUE);
}
} // End of Process MAP
@@ -2438,7 +2448,7 @@ BOOL convtoax25(unsigned char * callsign, unsigned char * ax25call,int * calllen }
BOOL add_arp_entry(struct AXIPPORTINFO * PORT, UCHAR * call, UCHAR * ip, int len, int port,
- UCHAR * name, int keepalive, BOOL BCFlag, BOOL AutoAdded, int TCPFlag, int SourcePort, BOOL IPv6, int noUpdate)
+ UCHAR * name, int keepalive, BOOL BCFlag, BOOL AutoAdded, int TCPFlag, int SourcePort, BOOL IPv6, int noUpdate, int useSourcePort)
{
struct arp_table_entry * arp;
@@ -2457,7 +2467,8 @@ BOOL add_arp_entry(struct AXIPPORTINFO * PORT, UCHAR * call, UCHAR * ip, int len arp->PORT = PORT;
- if (port == 0) PORT->needip = 1; // Enable Raw IP Mode
+ if (port == 0 && arp->replytoSourcePort == 0)
+ PORT->needip = 1; // Enable Raw IP Mode
arp->ResolveFlag=TRUE;
PORT->NeedResolver=TRUE;
@@ -2476,6 +2487,7 @@ BOOL add_arp_entry(struct AXIPPORTINFO * PORT, UCHAR * call, UCHAR * ip, int len arp->TCPMode = TCPFlag;
arp->noUpdate = noUpdate;
PORT->arp_table_len++;
+ arp->replytoSourcePort = useSourcePort;
if (PORT->MaxResWindowlength < (PORT->arp_table_len * 14) + 70)
PORT->MaxResWindowlength = (PORT->arp_table_len * 14) + 70;
@@ -2576,7 +2588,7 @@ int CheckKeepalives(struct AXIPPORTINFO * PORT) return (0);
}
-BOOL CheckSourceisResolvable(struct AXIPPORTINFO * PORT, char * call, int Port, VOID * rxaddr)
+BOOL CheckSourceisResolvable(struct AXIPPORTINFO * PORT, char * call, int FromPort, VOID * rxaddr, int ToPort)
{
// Makes sure we can reply to call before accepting message
@@ -2606,10 +2618,17 @@ BOOL CheckSourceisResolvable(struct AXIPPORTINFO * PORT, char * call, int Port, struct sockaddr_in * SA = rxaddr;
memcpy(&arp->destaddr.sin_addr.s_addr, &SA->sin_addr, 4);
}
- // Dont think I should update port
+ // Dont think I should update port unless using source port for dest
- //arp->port = Port;
+ if (arp->replytoSourcePort)
+ {
+ arp->port = FromPort;
+ arp->destaddr.sin_port = htons(arp->port);
+ if (arp->SourcePort == 0)
+ arp->SourcePort = ToPort;
+ }
}
+ arp->LastHeard = time(NULL);
return 1; // Ok to process
}
index++;
|
