-
Notifications
You must be signed in to change notification settings - Fork 696
netutils/ping: improve ping and ping6 for get_host error handling #3404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
masc2008
wants to merge
1
commit into
apache:master
Choose a base branch
from
masc2008:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| /**************************************************************************** | ||
| * apps/include/netutils/icmp_pub.h | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| * | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. The | ||
| * ASF licenses this file to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance with the | ||
| * License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
| * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
| * License for the specific language governing permissions and limitations | ||
| * under the License. | ||
| * | ||
| ****************************************************************************/ | ||
|
|
||
| #ifndef __APPS_INCLUDE_NETUTILS_ICMP_PUB_H | ||
| #define __APPS_INCLUDE_NETUTILS_ICMP_PUB_H | ||
|
|
||
| #define ICMP_E_HOSTIP -1 /* extra: not used */ | ||
|
|
||
| struct ping_result_s; | ||
|
|
||
| struct ping_info_s | ||
| { | ||
| FAR const char *hostname; /* Host name to ping */ | ||
| #ifdef CONFIG_NET_BINDTODEVICE | ||
| FAR const char *devname; /* Device name to bind */ | ||
| #endif | ||
| uint16_t flag; /* v4 or v6 */ | ||
| uint16_t count; /* Number of pings requested */ | ||
| uint16_t datalen; /* Number of bytes to be sent */ | ||
| uint16_t delay; /* Deciseconds to delay between pings */ | ||
| uint16_t timeout; /* Deciseconds to wait response before timeout */ | ||
| FAR void *priv; /* Private context for callback */ | ||
| void (*callback)(FAR const struct ping_result_s *result); | ||
| }; | ||
|
|
||
| struct ping_result_s | ||
| { | ||
| int code; /* Notice code ICMPv6_I/E/W_XXX */ | ||
| long extra; /* Extra information for code */ | ||
| union | ||
| { | ||
| #ifdef CONFIG_SYSTEM_PING | ||
| struct in_addr v4; /* Target address to ping */ | ||
| #endif | ||
| #ifdef CONFIG_SYSTEM_PING6 | ||
| struct in6_addr v6; /* Target address to ping */ | ||
| #endif | ||
| } dest; | ||
| uint16_t nrequests; /* Number of ICMP ECHO requests sent */ | ||
| uint16_t nreplies; /* Number of matching ICMP ECHO replies received */ | ||
| uint16_t outsize; /* Bytes(include ICMP header) to be sent */ | ||
| uint16_t id; /* ICMPv6_ECHO id */ | ||
| uint16_t seqno; /* ICMPv6_ECHO seqno */ | ||
| FAR const struct ping_info_s *info; | ||
| }; | ||
|
|
||
| #undef EXTERN | ||
| #if defined(__cplusplus) | ||
| #define EXTERN extern "C" | ||
| extern "C" | ||
| { | ||
| #else | ||
| #define EXTERN extern | ||
| #endif | ||
|
|
||
| void icmp_ping(FAR const struct ping_info_s *info); | ||
| void icmp6_ping(FAR const struct ping_info_s *info); | ||
|
|
||
| #undef EXTERN | ||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
| #endif /* __APPS_INCLUDE_NETUTILS_ICMP_PUB_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /**************************************************************************** | ||
| * apps/include/netutils/ping_pub.h | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| * | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. The | ||
| * ASF licenses this file to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance with the | ||
| * License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
| * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
| * License for the specific language governing permissions and limitations | ||
| * under the License. | ||
| * | ||
| ****************************************************************************/ | ||
|
|
||
| #ifndef __APPS_INCLUDE_NETUTILS_PING_PUB_H | ||
| #define __APPS_INCLUDE_NETUTILS_PING_PUB_H | ||
|
|
||
| struct ping_priv_s | ||
| { | ||
| int code; /* Notice code ICMP_I/E/W_XXX */ | ||
| long tmin; /* Minimum round trip time */ | ||
| long tmax; /* Maximum round trip time */ | ||
| long long tsum; /* Sum of all times, for doing average */ | ||
| long long tsum2; /* Sum2 is the sum of the squares of sum ,for doing mean deviation */ | ||
| }; | ||
|
|
||
| #undef EXTERN | ||
| #if defined(__cplusplus) | ||
| #define EXTERN extern "C" | ||
| extern "C" | ||
| { | ||
| #else | ||
| #define EXTERN extern | ||
| #endif | ||
|
|
||
| void ping_result(FAR const struct ping_result_s *result); | ||
| void ping6_result(FAR const struct ping_result_s *result); | ||
|
|
||
| #undef EXTERN | ||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| #endif /* __APPS_INCLUDE_NETUTILS_PING_PUB_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move the reorg change to new pr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The purpose is to let ping_result_s and ping6_result_s share same data structure. since in the callback same pointer was transferred, they will be used in different callback. same reason to ping_info_s and ping6_info_s.
if they have have private structure, and changed privately, then it will have very high risk, not easy to maintain them. considering this, should let them share same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key change is here: others are for this:

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xiaoxiang781216 , any further concern?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping and ping6 is totally seperated in the old implementation, so I would suggest that:
either is better than the current change which couple ping/ping6 in adhoc way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say ipv4/ipv6 ping should be in one file, and that is correct way. if choose that direction: FreeBSD version of ping can match the requirement, so why do we need do such basic code again? what I did is some work with accept able cost and fully leverage the current file. if re-org based current ping code, it will a new folder with some repeated data structures. this task has afflicted me too long. I would rather give up...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say ipv4/ipv6 ping should be in one file, and that is correct way. if choose that direction: FreeBSD version of ping can match the requirement, so why do we need do such basic code again? what I did is some work with accept able cost and fully leverage the current file. if re-org based current ping code, it will a new folder with some repeated data structures. this task has afflicted me too long. I would rather give up...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say ipv4/ipv6 ping should be in one file, and that is correct way. if choose that direction: FreeBSD version of ping can match the requirement, so why do we need do such basic code again? what I did is some work with accept able cost and fully leverage the current file. if re-org based current ping code, it will a new folder with some repeated data structures. this task has afflicted me too long. I would rather give up...