@@ -60,8 +60,9 @@ void tftp_request(struct listener *listen, time_t now)
6060 char * prefix = daemon -> tftp_prefix ;
6161 struct tftp_prefix * pref ;
6262 union all_addr addra ;
63+ int family = listen -> addr .sa .sa_family ;
6364 /* Can always get recvd interface for IPv6 */
64- int check_dest = !option_bool (OPT_NOWILD ) || listen -> family == AF_INET6 ;
65+ int check_dest = !option_bool (OPT_NOWILD ) || family == AF_INET6 ;
6566 union {
6667 struct cmsghdr align ; /* this ensures alignment */
6768 char control6 [CMSG_SPACE (sizeof (struct in6_pktinfo ))];
@@ -118,10 +119,10 @@ void tftp_request(struct listener *listen, time_t now)
118119 if (msg .msg_controllen < sizeof (struct cmsghdr ))
119120 return ;
120121
121- addr .sa .sa_family = listen -> family ;
122+ addr .sa .sa_family = family ;
122123
123124#if defined(HAVE_LINUX_NETWORK )
124- if (listen -> family == AF_INET )
125+ if (family == AF_INET )
125126 for (cmptr = CMSG_FIRSTHDR (& msg ); cmptr ; cmptr = CMSG_NXTHDR (& msg , cmptr ))
126127 if (cmptr -> cmsg_level == IPPROTO_IP && cmptr -> cmsg_type == IP_PKTINFO )
127128 {
@@ -135,7 +136,7 @@ void tftp_request(struct listener *listen, time_t now)
135136 }
136137
137138#elif defined(HAVE_SOLARIS_NETWORK )
138- if (listen -> family == AF_INET )
139+ if (family == AF_INET )
139140 for (cmptr = CMSG_FIRSTHDR (& msg ); cmptr ; cmptr = CMSG_NXTHDR (& msg , cmptr ))
140141 {
141142 union {
@@ -151,7 +152,7 @@ void tftp_request(struct listener *listen, time_t now)
151152 }
152153
153154#elif defined(IP_RECVDSTADDR ) && defined(IP_RECVIF )
154- if (listen -> family == AF_INET )
155+ if (family == AF_INET )
155156 for (cmptr = CMSG_FIRSTHDR (& msg ); cmptr ; cmptr = CMSG_NXTHDR (& msg , cmptr ))
156157 {
157158 union {
@@ -168,7 +169,7 @@ void tftp_request(struct listener *listen, time_t now)
168169
169170#endif
170171
171- if (listen -> family == AF_INET6 )
172+ if (family == AF_INET6 )
172173 {
173174 for (cmptr = CMSG_FIRSTHDR (& msg ); cmptr ; cmptr = CMSG_NXTHDR (& msg , cmptr ))
174175 if (cmptr -> cmsg_level == IPPROTO_IPV6 && cmptr -> cmsg_type == daemon -> v6pktinfo )
@@ -191,7 +192,7 @@ void tftp_request(struct listener *listen, time_t now)
191192
192193 addra .addr4 = addr .in .sin_addr ;
193194
194- if (listen -> family == AF_INET6 )
195+ if (family == AF_INET6 )
195196 addra .addr6 = addr .in6 .sin6_addr ;
196197
197198 if (daemon -> tftp_interfaces )
@@ -207,12 +208,12 @@ void tftp_request(struct listener *listen, time_t now)
207208 else
208209 {
209210 /* Do the same as DHCP */
210- if (!iface_check (listen -> family , & addra , name , NULL ))
211+ if (!iface_check (family , & addra , name , NULL ))
211212 {
212213 if (!option_bool (OPT_CLEVERBIND ))
213214 enumerate_interfaces (0 );
214- if (!loopback_exception (listen -> tftpfd , listen -> family , & addra , name ) &&
215- !label_exception (if_index , listen -> family , & addra ))
215+ if (!loopback_exception (listen -> tftpfd , family , & addra , name ) &&
216+ !label_exception (if_index , family , & addra ))
216217 return ;
217218 }
218219
@@ -245,7 +246,7 @@ void tftp_request(struct listener *listen, time_t now)
245246 prefix = pref -> prefix ;
246247 }
247248
248- if (listen -> family == AF_INET )
249+ if (family == AF_INET )
249250 {
250251 addr .in .sin_port = htons (port );
251252#ifdef HAVE_SOCKADDR_SA_LEN
@@ -265,7 +266,7 @@ void tftp_request(struct listener *listen, time_t now)
265266 if (!(transfer = whine_malloc (sizeof (struct tftp_transfer ))))
266267 return ;
267268
268- if ((transfer -> sockfd = socket (listen -> family , SOCK_DGRAM , 0 )) == -1 )
269+ if ((transfer -> sockfd = socket (family , SOCK_DGRAM , 0 )) == -1 )
269270 {
270271 free (transfer );
271272 return ;
@@ -296,7 +297,7 @@ void tftp_request(struct listener *listen, time_t now)
296297 {
297298 if (++ port <= daemon -> end_tftp_port )
298299 {
299- if (listen -> family == AF_INET )
300+ if (family == AF_INET )
300301 addr .in .sin_port = htons (port );
301302 else
302303 addr .in6 .sin6_port = htons (port );
@@ -334,7 +335,7 @@ void tftp_request(struct listener *listen, time_t now)
334335 if ((opt = next (& p , end )) && !option_bool (OPT_TFTP_NOBLOCK ))
335336 {
336337 /* 32 bytes for IP, UDP and TFTP headers, 52 bytes for IPv6 */
337- int overhead = (listen -> family == AF_INET ) ? 32 : 52 ;
338+ int overhead = (family == AF_INET ) ? 32 : 52 ;
338339 transfer -> blocksize = atoi (opt );
339340 if (transfer -> blocksize < 1 )
340341 transfer -> blocksize = 1 ;
0 commit comments