• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得cocoawindowspythonrubyphpgameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdombtronvb.netdirectxarduinopreviewerゲームエンジン

Commit MetaInfo

修订版c7a6c266fe5f23fcfc61793b8b3bef177b2cf9f4 (tree)
时间2022-05-22 11:05:15
作者Satoshi <7m3tjz@jarl...>
CommiterSatoshi

Log Message

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

更改概述

差异

--- a/forward_in.c
+++ b/forward_in.c
@@ -13,6 +13,7 @@ void delete_MultiConnectTable (struct sockaddr_in multi_addr);
1313 void send_invalid_call (unsigned char call[], struct sockaddr_in multi_addr);
1414 void send_inquire (struct MultiConnectTable *pnt, unsigned char call[]);
1515 int ur_call_check (unsigned char call[]);
16+void ctbl (void);
1617
1718 extern struct sockaddr_in in_sock;
1819 extern socklen_t len_in_sock;
@@ -27,7 +28,7 @@ void forward_reply (char pkt[])
2728 memcpy (forward_reply_frame, pkt, 6);
2829 forward_reply_frame[6] = 'r';
2930
30- ret = sendto (fwd_sd, forward_reply_frame, 10, 0,
31+ ret = sendto (fwd_sd, forward_reply_frame, 10, MSG_DONTWAIT,
3132 (struct sockaddr *)&fwd_recv_addr, sizeof(fwd_recv_addr));
3233 if (ret == -1)
3334 {
@@ -64,6 +65,7 @@ int forward_resend (void)
6465 }
6566 if (length < 10) return TRUE;
6667
68+ time (&xchange_recv_time);
6769 if (!memcmp(forward_buff.d_packet.id, "DSTR", 4) && (forward_buff.d_packet.sr == 's'))
6870 {
6971 forward_reply((char *)&forward_buff);
@@ -78,6 +80,8 @@ int forward_resend (void)
7880 && ((forward_buff.d_packet.c & C_MASK) != POSIT)) return TRUE;
7981 if ((length == 58) && (forward_buff.d_packet.l[1] == 0x30))
8082 {
83+ if (forward_buff.d_packet.c & ZR ) xchange_zr_in++;
84+ else if (forward_buff.d_packet.c & GW ) xchange_gw_in++;
8185 if (!mycall2_check (forward_buff.d_packet.body.header.mycall_ex)) return TRUE;
8286 if (!ja_check (forward_buff.d_packet.body.header.mycall)) return TRUE;
8387 if (!ja_check (forward_buff.d_packet.body.header.rpt1)
@@ -152,6 +156,8 @@ skip:
152156 else if (((length == 29) && (forward_buff.d_packet.l[1] == 0x13))
153157 || ((length == 32) && (forward_buff.d_packet.l[1] == 0x16)))
154158 {
159+ if (forward_buff.d_packet.c & ZR ) xchange_zr_in++;
160+ else if (forward_buff.d_packet.c & GW ) xchange_gw_in++;
155161 if ((forward_buff.d_packet.trunk.FrameSeq & 0x1f) > 0x14) return TRUE;
156162 ar_call_next = ar_callsign_pnt;
157163 while (ar_call_next)
@@ -276,6 +282,7 @@ void multi_connect (void)
276282 length = recvfrom(multi_sd, &multi_buff, sizeof(multi_buff), 0,
277283 (struct sockaddr *)&multi_addr, &len_multi_addr);
278284 time (&atime);
285+printf ("debug %d\n", length);
279286 if (length < 10) {
280287 fprintf (log_file, "%24.24s Multi forward data Reciv. error\n", ctime(&atime));
281288 fflush (log_file);
@@ -350,7 +357,6 @@ void multi_connect (void)
350357 }
351358 return;
352359 }
353-
354360 if ((length == 58) || (length == 29) || (length == 32))
355361 {
356362 if (multi_buff.d_packet.l[0] != 0x00) return;
@@ -407,6 +413,8 @@ void multi_read(struct MultiConnectTable *nextTable)
407413 length = getFifo (nextTable, multi_buff.multi_buffer, &addr);
408414 if (length == 58)
409415 {
416+ if (multi_buff.d_packet.c & 0x40 ) xchange_zr_out++;
417+ else if (multi_buff.d_packet.c & 0x80 ) xchange_zr_out++;
410418 if (!mycall2_check (multi_buff.d_packet.body.header.mycall_ex)) return;
411419 if (!ja_check (multi_buff.d_packet.body.header.mycall)) return;
412420 if (!ur_call_check(multi_buff.d_packet.body.header.urcall)) return;
@@ -442,6 +450,8 @@ void multi_read(struct MultiConnectTable *nextTable)
442450 }
443451 else if ((length == 29) || (length == 32))
444452 {
453+ if (multi_buff.d_packet.c & 0x40 ) xchange_zr_out++;
454+ else if (multi_buff.d_packet.c & 0x80 ) xchange_zr_out++;
445455 if ((multi_buff.d_packet.trunk.FrameSeq & 0x1f) > 0x14) return;
446456 goto send;
447457 }
@@ -452,6 +462,8 @@ send:
452462 {
453463 if (!memcmp (ar_call_next->FrameID, multi_buff.d_packet.trunk.FrameID, 2))
454464 {
465+ if (multi_buff.d_packet.c & ZR ) xchange_zr_out++;
466+ else if (multi_buff.d_packet.c & GW ) xchange_gw_out++;
455467 time (&ar_call_next->status_time);
456468 multi_buff.d_packet.m[0] = (fwd_send_seq >> 8) & 0xff;
457469 multi_buff.d_packet.m[1] = fwd_send_seq & 0xff;
@@ -481,11 +493,14 @@ send:
481493 fprintf (log_file, "%24.24s mult->fwd error %d(%d)\n", ctime(&atime), ret, length);
482494 fflush (log_file);
483495 }
496+
484497 if (length == 58) memcpy (multi_buff.d_packet.body.header.rpt1, zr_save, 8);
498+
485499 multi_buff.d_packet.m[0] = (multi_send_seq >> 8) & 0xff;
486500 multi_buff.d_packet.m[1] = multi_send_seq & 0xff;
487501 multi_send_seq++;
488502 multi_send_seq &= 0xffff;
503+
489504 if (multi_buff.d_packet.trunk.FrameSeq == 0x14)
490505 {
491506 ar_call_next->rf_header[4] = (multi_send_seq >> 8) & 0xff;
@@ -493,6 +508,13 @@ send:
493508 multi_send_seq++;
494509 multi_send_seq &= 0xffff;
495510 }
511+
512+ if ((length == 29) && (multi_buff.d_packet.trunk.FrameSeq == 0x00))
513+ {
514+ multi_buff.multi_buffer[26] = 0x55;
515+ multi_buff.multi_buffer[27] = 0x2d;
516+ multi_buff.multi_buffer[28] = 0x16;
517+ }
496518 next = MultiConnectTablePnt;
497519 while (next)
498520 {
@@ -524,14 +546,15 @@ send:
524546 }
525547 next = next->f_chain;
526548 }
527- next = MultiConnectTablePnt;
528- while (next)
529- {
530- if ((addr.sin_addr.s_addr != next->multi_addr.sin_addr.s_addr)
531- || (addr.sin_port != next->multi_addr.sin_port))
532- {
533- if ((multi_buff.d_packet.trunk.FrameSeq == 0x14) && ar_call_next)
534- {
549+
550+ if ((multi_buff.d_packet.trunk.FrameSeq == 0x14) && ar_call_next)
551+ {
552+ next = MultiConnectTablePnt;
553+ while (next)
554+ {
555+ if ((addr.sin_addr.s_addr != next->multi_addr.sin_addr.s_addr)
556+ || (addr.sin_port != next->multi_addr.sin_port))
557+ {
535558 ret = sendto (multi_sd, &ar_call_next->rf_header, 58, 0,
536559 (struct sockaddr *)&next->multi_addr, sizeof(struct sockaddr));
537560 if (ret == -1)
@@ -548,9 +571,9 @@ send:
548571 }
549572 next->out++;
550573 }
551- }
552- next = next->f_chain;
553- }
574+ next = next->f_chain;
575+ }
576+ }
554577 if (multi_buff.d_packet.trunk.FrameSeq & 0x40)
555578 {
556579 status_off (ar_call_next->ar_callsign);
--- a/multi_forward.h
+++ b/multi_forward.h
@@ -3,10 +3,10 @@
33
44 */
55
6-#define CONFIG_FILE "/opt/dstar/conf/multi_forward.conf"
7-#define DSGWD_CONF_FILE "/etc/dsgwd.conf"
8-#define LOG_FILE "/var/log/multi_forward.log"
9-#define PID_FILE "/var/run/multi_forward.pid"
6+#define CONFIG_FILE "/boot/rpi-GW/rpi-multi_forward.conf"
7+#define DSGWD_CONF_FILE "/boot/rpi-GW/rpi-dsgwd.conf"
8+#define LOG_FILE "/var/log/rpi-multi_forward.log"
9+#define PID_FILE "/var/run/rpi-multi_forward.pid"
1010
1111 #define TRUE 1
1212 #define FALSE 0
@@ -59,6 +59,7 @@
5959 #define DCS_CONFIG_FILE "/dstar/dcs_icom.cfg"
6060 #define GATEWAY_PORT 51000
6161
62+#define HTTP_PORT 20202
6263 #define NOP 0
6364 #define WAIT 1
6465 #define SKIP 2
@@ -293,3 +294,10 @@ time_t status_send_time;
293294 time_t server_table_load_time;
294295
295296 int restart_sw;
297+
298+long int xchange_zr_in;
299+long int xchange_gw_in;
300+long int xchange_zr_out;
301+long int xchange_gw_out;
302+time_t xchange_recv_time;
303+
--- a/multi_forward_utils.c
+++ b/multi_forward_utils.c
@@ -281,6 +281,7 @@ void send_hole_punch (struct area_callsign *ar_call)
281281 }
282282 }
283283
284+
284285 struct MultiConnectTable *multi_table_create(struct sockaddr_in multi_addr)
285286 {
286287 struct MultiConnectTable *next;
@@ -1255,13 +1256,23 @@ int getOwnIp (void)
12551256 int fd;
12561257 struct ifreq ifr;
12571258 int ret;
1259+ int i;
12581260
1259- memset (&ifr, 0x00, sizeof(ifr));
1260- fd = socket (PF_INET, SOCK_DGRAM, 0);
1261- ifr.ifr_addr.sa_family = PF_INET;
1262- memcpy (ifr.ifr_name, NicDevice, strlen(NicDevice));
1263- ret = ioctl (fd, SIOCGIFADDR, &ifr);
1264- close (fd);
1261+ i = 0;
1262+ ret = -1;
1263+ while (ret == -1)
1264+ {
1265+ i++;
1266+ if (i > 6) return FALSE;
1267+ sleep (5);
1268+ fd = socket (AF_INET, SOCK_DGRAM, 0);
1269+ memset (&ifr, 0x00, sizeof (struct ifreq));
1270+ ifr.ifr_addr.sa_family = AF_INET;
1271+ memcpy (ifr.ifr_name, NicDevice, strlen(NicDevice));
1272+ ret = ioctl (fd, SIOCGIFADDR, &ifr);
1273+ close (fd);
1274+ }
1275+#if 0
12651276 time (&cur_time);
12661277 if (ret == -1)
12671278 {
@@ -1270,6 +1281,7 @@ int getOwnIp (void)
12701281 return FALSE;
12711282
12721283 }
1284+#endif
12731285 OwnMultiIP.s_addr = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr;
12741286 fprintf(log_file, "%24.24s Own IP address %s\n", ctime(&cur_time),
12751287 inet_ntoa (OwnMultiIP));
@@ -1402,7 +1414,7 @@ int read_md5 (void)
14021414 if (ret <= 0) return -1;
14031415 //pg_path[ret] = 0x00;
14041416 ETagGen (pg_path, MD5_multi_forward);
1405- //memcpy (MD5_multi_forward, "953a24a7f2696b86d48b2e4b67569958", 32); // debug
1417+ memcpy (MD5_multi_forward, "953a24a7f2696b86d48b2e4b67569958", 32); // debug
14061418 return 0;
14071419 }
14081420