Skip to content

Commit

Permalink
Update Ip6Address::FromString to support address string including
Browse files Browse the repository at this point in the history
interface name
  • Loading branch information
sunytt committed Nov 22, 2024
1 parent 7d32700 commit 6bcc5c5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/common/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,14 @@ void Ip6Address::CopyFrom(const struct in6_addr &aIn6Addr)
otbrError Ip6Address::FromString(const char *aStr, Ip6Address &aAddr)
{
int ret;
// The aStr may be in the format of "fe80::1%eth0"
char strCopy[strlen(aStr) + 1];
char *addr;

ret = inet_pton(AF_INET6, aStr, &aAddr.m8);
strcpy(strCopy, aStr);
addr = strtok(strCopy, "%");

ret = inet_pton(AF_INET6, addr, &aAddr.m8);

return ret == 1 ? OTBR_ERROR_NONE : OTBR_ERROR_INVALID_ARGS;
}
Expand Down

0 comments on commit 6bcc5c5

Please sign in to comment.