File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 5151#define ICMP_E_RECVFROM -13 /* extra: error code */
5252#define ICMP_E_RECVSMALL -15 /* extra: recv bytes */
5353#define ICMP_E_BINDDEV -17 /* extra: error bind */
54+ #define ICMP_E_FILTER -19 /* extra: error filter */
5455
5556/* Negative even number represent warning(recoverable) */
5657
Original file line number Diff line number Diff line change 5353 ****************************************************************************/
5454
5555#define ICMP_IOBUFFER_SIZE (x ) (sizeof(struct icmp_hdr_s) + (x))
56+ #define ICMP_SET_FILTER (t ) (~(1U << (t)))
5657
5758/****************************************************************************
5859 * Private Types
@@ -197,6 +198,9 @@ void icmp_ping(FAR const struct ping_info_s *info)
197198 int ret ;
198199 int ch ;
199200 int i ;
201+ #ifdef CONFIG_NET_SOCKOPTS
202+ int filter ;
203+ #endif
200204
201205 g_exiting = false;
202206 signal (SIGINT , sigexit );
@@ -246,6 +250,19 @@ void icmp_ping(FAR const struct ping_info_s *info)
246250 }
247251#endif
248252
253+ #ifdef CONFIG_NET_SOCKOPTS
254+ filter = ICMP_SET_FILTER (ICMP_ECHO_REPLY );
255+ ret = setsockopt (priv -> sockfd , IPPROTO_ICMP , ICMP_FILTER ,
256+ & filter , sizeof (filter ));
257+ if (ret < 0 )
258+ {
259+ icmp_callback (& result , ICMP_E_FILTER , errno );
260+ close (priv -> sockfd );
261+ free (priv );
262+ return ;
263+ }
264+ #endif
265+
249266 priv -> kickoff = clock ();
250267
251268 memset (& priv -> destaddr , 0 , sizeof (struct sockaddr_in ));
You can’t perform that action at this time.
0 commit comments