@@ -144,7 +144,7 @@ int isValidIpAddress(char *ipAddress)
144144}
145145
146146
147- int tmo_update_time (const struct shell * shell , char * host )
147+ int tmo_update_time (const struct shell * shell , char * host , int iface_idx )
148148{
149149#if defined(CONFIG_NET_IPV6 )
150150#ifdef DEBUG
@@ -161,14 +161,18 @@ int tmo_update_time(const struct shell *shell, char *host)
161161 // Set the first byte's bits to 00,011,011 for li = 0, vn = 3, and mode = 3. The rest will be left set to zero.
162162 * ( ( char * ) & packet + 0 ) = 0x1b ; // Represents 27 in base 10 or 00011011 in base 2.
163163
164- int iface_idx = 2 ;
165164 struct net_if * iface = net_if_get_by_index (iface_idx );
165+
166+ if (tmo_offload_init (iface_idx )) {
167+ return -1 ;
168+ }
169+
166170 if (iface == NULL ) {
167171 shell_error (shell , "Interface %d not found" , iface_idx );
168172 return - EINVAL ;
169173 }
170174
171- int sd = zsock_socket_ext (AF_INET , SOCK_DGRAM , IPPROTO_UDP , iface );
175+ int sd = zsock_socket_ext (AF_INET , SOCK_DGRAM , IPPROTO_UDP , iface );
172176 if (sd == -1 ) {
173177 shell_error (shell , "Socket creation failed, errno = %d" , errno );
174178 return 0 ;
@@ -215,12 +219,9 @@ int tmo_update_time(const struct shell *shell, char *host)
215219 while (total < recvsize || recvsize == 0 ) {
216220 stat = zsock_recv (sd , (( char * ) & packet ) + total , recvsize - total , ZSOCK_MSG_DONTWAIT );
217221 if (stat == -1 ) {
218- if ((total == 0 ) || (errno != EAGAIN )) {
219- shell_error (shell , "recv failed, errno = %d" , errno );
220- zsock_close (sd );
221- return -1 ;
222- }
223- break ;
222+ shell_error (shell , "recv failed, errno = %d" , errno );
223+ zsock_close (sd );
224+ return -1 ;
224225 }
225226 total += stat ;
226227 }
0 commit comments