• R/O
  • HTTP
  • SSH
  • HTTPS

multi_forward: Commit


Commit MetaInfo

Revisionbd088c635788b9edf49c1f6d0ec3c9d4036a7a2b (tree)
Zeit2019-10-24 16:35:21
Autorroot <jk1zrw@user...>
Commiterroot

Log Message

modified: forward_in.c
modified: multi_forward.h
modified: multi_forward_utils.c

Ändern Zusammenfassung

Diff

--- a/forward_in.c
+++ b/forward_in.c
@@ -282,31 +282,6 @@ int forward_init(void)
282282 return TRUE;
283283 }
284284
285-struct MultiConnectTable *multi_table_create(char call[], struct sockaddr_in multi_addr)
286-{
287- struct MultiConnectTable *next;
288-
289- next = malloc (sizeof(struct MultiConnectTable));
290- next->f_chain = MultiConnectTablePnt;
291- memcpy (&next->multi_addr, &multi_addr, sizeof (multi_addr));
292- time (&next->AccessTime);
293- next->in = 0;
294- next->out = 0;
295- next->gw = 0;
296- next->zr = 0;
297- next->auth = AUTH_WAIT;
298- next->xmit = XMIT_FALSE;
299- memcpy (next->auth_callsign, call, 8);
300- memset (next->xmit_callsign, 0x20, 8);
301- memset (next->ar_callsign, 0x20, 8);
302- next->Rp = malloc (sizeof (struct FifoPkt) - 1024);
303- next->Wp = next->Rp;
304- next->Rp->next = NULL;
305- next->hole_punch = FALSE;
306- MultiConnectTablePnt = next;
307- return next;
308-}
309-
310285 void multi_connect (void)
311286 {
312287 int length;
@@ -374,10 +349,20 @@ void multi_connect (void)
374349 send_invalid_call (&multi_buff.multi_buffer[16], multi_addr);
375350 return;
376351 }
377- next = multi_table_create (&multi_buff.multi_buffer[16], multi_addr);
378- send_inquire(&multi_buff.multi_buffer[16]);
379- next->auth = AUTH_WAIT;
380- gettimeofday (&next->AuthInquireTime, NULL);
352+ next = MultiConnectTablePnt;
353+ while (next)
354+ {
355+ if ((multi_addr.sin_addr.s_addr == next->multi_addr.sin_addr.s_addr)
356+ && (multi_addr.sin_port == next->multi_addr.sin_port))
357+ {
358+ memcpy (next->auth_callsign, &multi_buff.multi_buffer[16], 8);
359+ send_inquire(&multi_buff.multi_buffer[16]);
360+ next->auth = AUTH_WAIT;
361+ gettimeofday (&next->AuthInquireTime, NULL);
362+ break;
363+ }
364+ next = next->f_chain;
365+ }
381366 return;
382367 }
383368 next:
--- a/multi_forward.h
+++ b/multi_forward.h
@@ -99,7 +99,6 @@ struct MultiConnectTable
9999 long int gw;
100100 char auth;
101101 char xmit;
102- char hole_punch;
103102 };
104103
105104 struct MultiConnectTable *MultiConnectTablePnt;
--- a/multi_forward_utils.c
+++ b/multi_forward_utils.c
@@ -246,6 +246,29 @@ void send_hole_punch (void)
246246 }
247247 }
248248
249+struct MultiConnectTable *multi_table_create(struct sockaddr_in multi_addr)
250+{
251+ struct MultiConnectTable *next;
252+
253+ next = malloc (sizeof(struct MultiConnectTable));
254+ next->f_chain = MultiConnectTablePnt;
255+ memcpy (&next->multi_addr, &multi_addr, sizeof (multi_addr));
256+ time (&next->AccessTime);
257+ next->in = 0;
258+ next->out = 0;
259+ next->gw = 0;
260+ next->zr = 0;
261+ next->auth = AUTH_WAIT;
262+ next->xmit = XMIT_FALSE;
263+ memset (next->auth_callsign, 0x20, 8);
264+ memset (next->xmit_callsign, 0x20, 8);
265+ memset (next->ar_callsign, 0x20, 8);
266+ next->Rp = malloc (sizeof (struct FifoPkt) - 1024);
267+ next->Wp = next->Rp;
268+ next->Rp->next = NULL;
269+ MultiConnectTablePnt = next;
270+ return next;
271+}
249272 void read_hole_punch (char buff[], int length)
250273 {
251274 char ip_add[20];
@@ -256,6 +279,7 @@ void read_hole_punch (char buff[], int length)
256279 int len;
257280 time_t atime;
258281 struct MultiConnectTable *pnt;
282+ struct MultiConnectTable *next;
259283
260284 port = multi_port;
261285 if (length == 10)
@@ -281,19 +305,18 @@ void read_hole_punch (char buff[], int length)
281305 hole_addr.sin_family = AF_INET;
282306 hole_addr.sin_port = htons(port);
283307 hole_addr.sin_addr.s_addr = inet_addr(ip_add);
284-#if 0
308+
285309 pnt = MultiConnectTablePnt;
286310 while (pnt)
287311 {
288312 if ((pnt->multi_addr.sin_addr.s_addr == hole_addr.sin_addr.s_addr)
289313 && (pnt->multi_addr.sin_port == hole_addr.sin_port))
290314 {
291- pnt->hole_punch = TRUE;
292315 break;
293316 }
294317 pnt = pnt->f_chain;
295318 }
296-#endif
319+ if (pnt == NULL) next = multi_table_create (hole_addr);
297320
298321 ret = sendto (multi_sd, buff, 25, 0,
299322 (struct sockaddr *)&hole_addr, sizeof(hole_addr));
Show on old repository browser