-
Notifications
You must be signed in to change notification settings - Fork 2k
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
pkg/paho-mqtt: add support for gnrc #17004
Open
vera
wants to merge
11
commits into
RIOT-OS:master
Choose a base branch
from
vera:pkg_paho-mqtt_gnrc
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.
+718
−27
Open
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
72a4370
tests: add tests for pkg/paho-mqtt
vera 67f9c7f
pkg/paho-mqtt: add support for gnrc
vera 3e93d65
fixup! pkg/paho-mqtt: add support for gnrc
vera 2dc9f10
fixup! tests: add tests for pkg/paho-mqtt
vera 3ceb415
fixup! pkg/paho-mqtt: add support for gnrc
vera cae67df
fixup! pkg/paho-mqtt: add support for gnrc
vera 5e35cb3
fixup! pkg/paho-mqtt: add support for gnrc
vera a0d0f64
fixup! pkg/paho-mqtt: add support for gnrc
vera 51c0a1b
fixup! tests: add tests for pkg/paho-mqtt
vera c0dbef1
fixup! tests: add tests for pkg/paho-mqtt
vera ad3b13e
fixup! pkg/paho-mqtt: add support for gnrc
vera 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
fixup! pkg/paho-mqtt: add support for gnrc
- Loading branch information
commit 3e93d65eb7d0b64444ad7696034d64e2844877fa
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -59,9 +59,9 @@ static int mqtt_read(struct Network *n, unsigned char *buf, int len, | |
|
||
#if defined(MODULE_LWIP) | ||
/* As LWIP doesn't support packet reading byte per byte and | ||
* PAHO MQTT reads like that to decode it on the fly, | ||
* we read TSRB_MAX_SIZE at once and keep them in a ring buffer. | ||
*/ | ||
* PAHO MQTT reads like that to decode it on the fly, | ||
* we read TSRB_MAX_SIZE at once and keep them in a ring buffer. | ||
*/ | ||
_buf = _temp_buf; | ||
_len = TSRB_MAX_SIZE; | ||
_timeout = 0; | ||
|
@@ -134,13 +134,24 @@ int NetworkConnect(Network *n, char *addr_ip, int port) | |
ipv4_addr_from_str((ipv4_addr_t *)&remote.addr, _local_ip)) { | ||
remote.port = port; | ||
} | ||
else if (IS_USED(MODULE_IPV6_ADDR)) { | ||
/* ipvN_addr_from_str modifies input buffer */ | ||
strncpy(_local_ip, addr_ip, sizeof(_local_ip)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm personally not a fan of size_t addr_ip_len = strlen(addr_ip);
if (addr_ip_len + 1 > sizeof(_local_ip)) {
return -EINVAL;
}
memcpy(_local_ip, addr_ip, addr_ip_len);
_local_ip[addr_ip_len] = [0]; |
||
|
||
#if defined(MODULE_GNRC) | ||
char *iface = ipv6_addr_split_iface(_local_ip); | ||
if ((!iface) && (gnrc_netif_numof() == 1)) { | ||
remote.netif = gnrc_netif_iter(NULL)->pid; | ||
} | ||
else if (iface) { | ||
remote.netif = atoi(iface); | ||
} | ||
#endif | ||
|
||
/* ipvN_addr_from_str modifies input buffer */ | ||
strncpy(_local_ip, addr_ip, sizeof(_local_ip)); | ||
if (IS_USED(MODULE_IPV6_ADDR) && (remote.port == 0) && | ||
ipv6_addr_from_str((ipv6_addr_t *)&remote.addr, _local_ip)) { | ||
if (ipv6_addr_from_str((ipv6_addr_t *)&remote.addr, _local_ip)) { | ||
remote.port = port; | ||
remote.family = AF_INET6; | ||
} | ||
} | ||
|
||
if (remote.port == 0) { | ||
|
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.
Are you sure about that? The char pointer is declared as
const
and briefly skimming the code doesn't reveal any bug that results in disregarding theconst
ness.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.
Yes, I think you are right and I also wondered about this but I kept the comment unchanged since I thought it is not directly relevant for my changes and I didn't want to overcomplicate this PR. I will take a look at this again.
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 can't see a reason not to use
ipvN_addr_from_str()
directly. (And I have also found another place where this is already done: tests/lwip/ip.c:116 and tests/lwip/ip.c:130)I have removed the comment and the
strncpy
.