batman-adv: bla2 & gateway mode interaction fix
[openwrt/svn-archive/archive.git] / net / atftp / patches / 120-retry_setting.patch
1 Index: atftp-0.7/tftp.c
2 ===================================================================
3 --- atftp-0.7.orig/tftp.c 2007-08-02 23:04:23.000000000 +0200
4 +++ atftp-0.7/tftp.c 2007-08-02 23:04:23.000000000 +0200
5 @@ -967,6 +967,7 @@
6 { "tftp-timeout", 1, NULL, 'T'},
7 { "mode", 1, NULL, 'M'},
8 { "option", 1, NULL, 'O'},
9 + { "retry", 1, NULL, 'R'},
10 #if 1
11 { "timeout", 1, NULL, 't'},
12 { "blksize", 1, NULL, 'b'},
13 @@ -986,11 +987,16 @@
14 };
15
16 /* Support old argument until 0.8 */
17 - while ((c = getopt_long(argc, argv, /*"gpl:r:Vh"*/ "gpl:r:Vht:b:sm",
18 + while ((c = getopt_long(argc, argv, /*"gpl:r:Vh"*/ "gpl:r:Vht:b:smR:",
19 options, &option_index)) != EOF)
20 {
21 switch (c)
22 {
23 + case 'R':
24 + snprintf(string, sizeof(string), "option retry %s", optarg);
25 + make_arg(string, &ac, &av);
26 + process_cmd(ac, av);
27 + break;
28 case 'g':
29 interactive = 0;
30 if ((action == PUT) || (action == MGET))
31 Index: atftp-0.7/tftp_def.c
32 ===================================================================
33 --- atftp-0.7.orig/tftp_def.c 2007-08-02 23:04:23.000000000 +0200
34 +++ atftp-0.7/tftp_def.c 2007-08-02 23:04:23.000000000 +0200
35 @@ -37,6 +37,7 @@
36 { "timeout", "5", 0, 1 }, /* 2348, 2349, 2090. */
37 { "blksize", "512", 0, 1 }, /* This is the default option */
38 { "multicast", "", 0, 1 }, /* structure */
39 + { "retry", "5", 0, 1 },
40 { "", "", 0, 0}
41 };
42
43 Index: atftp-0.7/tftp_def.h
44 ===================================================================
45 --- atftp-0.7.orig/tftp_def.h 2007-08-02 23:04:23.000000000 +0200
46 +++ atftp-0.7/tftp_def.h 2007-08-02 23:04:23.000000000 +0200
47 @@ -40,7 +40,8 @@
48 #define OPT_TIMEOUT 3
49 #define OPT_BLKSIZE 4
50 #define OPT_MULTICAST 5
51 -#define OPT_NUMBER 7
52 +#define OPT_RETRY 6
53 +#define OPT_NUMBER 8
54
55 #define OPT_SIZE 12
56 #define VAL_SIZE MAXLEN
57 Index: atftp-0.7/tftp_file.c
58 ===================================================================
59 --- atftp-0.7.orig/tftp_file.c 2007-08-02 23:04:23.000000000 +0200
60 +++ atftp-0.7/tftp_file.c 2007-08-02 23:04:23.000000000 +0200
61 @@ -123,6 +123,7 @@
62 struct tftphdr *tftphdr = (struct tftphdr *)data->data_buffer;
63 FILE *fp = NULL; /* the local file pointer */
64 int number_of_timeout = 0;
65 + int num_retry = atoi(data->tftp_options[OPT_RETRY].value);
66 int convert = 0; /* if true, do netascii convertion */
67
68 int oacks = 0; /* count OACK for improved error checking */
69 @@ -141,7 +142,7 @@
70
71 int prev_block_number = 0; /* needed to support netascii convertion */
72 int temp = 0;
73 -
74 +
75 data->file_size = 0;
76 tftp_cancel = 0;
77 from.sin_addr.s_addr = 0;
78 @@ -288,7 +289,7 @@
79 case GET_TIMEOUT:
80 number_of_timeout++;
81 fprintf(stderr, "timeout: retrying...\n");
82 - if (number_of_timeout > NB_OF_RETRY)
83 + if ((num_retry > 0) && (number_of_timeout > num_retry))
84 state = S_ABORT;
85 else
86 state = timeout_state;
87 @@ -325,7 +326,7 @@
88 number_of_timeout++;
89 fprintf(stderr, "tftp: packet discard <%s:%d>.\n",
90 inet_ntoa(from.sin_addr), ntohs(from.sin_port));
91 - if (number_of_timeout > NB_OF_RETRY)
92 + if ((num_retry > 0) && (number_of_timeout > num_retry))
93 state = S_ABORT;
94 break;
95 case ERR:
96 @@ -614,6 +615,7 @@
97 struct tftphdr *tftphdr = (struct tftphdr *)data->data_buffer;
98 FILE *fp; /* the local file pointer */
99 int number_of_timeout = 0;
100 + int num_retry = atoi(data->tftp_options[OPT_RETRY].value);
101 struct stat file_stat;
102 int convert = 0; /* if true, do netascii convertion */
103 char string[MAXLEN];
104 @@ -751,7 +753,7 @@
105 case GET_TIMEOUT:
106 number_of_timeout++;
107 fprintf(stderr, "timeout: retrying...\n");
108 - if (number_of_timeout > NB_OF_RETRY)
109 + if ((num_retry > 0) && (number_of_timeout > num_retry))
110 state = S_ABORT;
111 else
112 state = timeout_state;
113 @@ -797,7 +799,7 @@
114 number_of_timeout++;
115 fprintf(stderr, "tftp: packet discard <%s:%d>.\n",
116 inet_ntoa(from.sin_addr), ntohs(from.sin_port));
117 - if (number_of_timeout > NB_OF_RETRY)
118 + if ((num_retry > 0) && (number_of_timeout > num_retry))
119 state = S_ABORT;
120 break;
121 case ERR: