From 1b59c97bbcab20289b31fb240b597bc43501c49f Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Wed, 18 Oct 2023 20:55:05 -0700 Subject: [PATCH] [udp] remove `aIpProto` from `Ip6::Udp::SendDatagram()` (#9547) This commit removes the input `aIpProto` in `Upd::HandleDatagram()` method and assumes `kProtoUdp`. --- src/core/api/udp_api.cpp | 3 +-- src/core/meshcop/border_agent.cpp | 2 +- src/core/net/udp6.cpp | 6 +++--- src/core/net/udp6.hpp | 3 +-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/core/api/udp_api.cpp b/src/core/api/udp_api.cpp index 739fc4c36dc..5141a50b683 100644 --- a/src/core/api/udp_api.cpp +++ b/src/core/api/udp_api.cpp @@ -126,8 +126,7 @@ otError otUdpSendDatagram(otInstance *aInstance, otMessage *aMessage, otMessageI VerifyOrExit(!AsCoreType(aMessage).IsOriginThreadNetif(), error = kErrorInvalidArgs); - return AsCoreType(aInstance).Get().SendDatagram(AsCoreType(aMessage), AsCoreType(aMessageInfo), - Ip6::kProtoUdp); + return AsCoreType(aInstance).Get().SendDatagram(AsCoreType(aMessage), AsCoreType(aMessageInfo)); exit: return error; } diff --git a/src/core/meshcop/border_agent.cpp b/src/core/meshcop/border_agent.cpp index f73863c1df2..235e7a56d6c 100644 --- a/src/core/meshcop/border_agent.cpp +++ b/src/core/meshcop/border_agent.cpp @@ -334,7 +334,7 @@ template <> void BorderAgent::HandleTmf(Coap::Message &aMessage, co SuccessOrExit(error = Tlv::Find(aMessage, messageInfo.GetPeerAddr())); - SuccessOrExit(error = Get().SendDatagram(*message, messageInfo, Ip6::kProtoUdp)); + SuccessOrExit(error = Get().SendDatagram(*message, messageInfo)); mUdpProxyPort = udpEncapHeader.GetSourcePort(); LogInfo("Proxy transmit sent to %s", messageInfo.GetPeerAddr().ToString().AsCString()); diff --git a/src/core/net/udp6.cpp b/src/core/net/udp6.cpp index 3ddda61cd14..be62da2609a 100644 --- a/src/core/net/udp6.cpp +++ b/src/core/net/udp6.cpp @@ -355,7 +355,7 @@ Error Udp::SendTo(SocketHandle &aSocket, Message &aMessage, const MessageInfo &a else #endif { - SuccessOrExit(error = SendDatagram(aMessage, messageInfoLocal, kProtoUdp)); + SuccessOrExit(error = SendDatagram(aMessage, messageInfoLocal)); } exit: @@ -427,7 +427,7 @@ Message *Udp::NewMessage(uint16_t aReserved, const Message::Settings &aSettings) return Get().NewMessage(sizeof(Header) + aReserved, aSettings); } -Error Udp::SendDatagram(Message &aMessage, MessageInfo &aMessageInfo, uint8_t aIpProto) +Error Udp::SendDatagram(Message &aMessage, MessageInfo &aMessageInfo) { Error error = kErrorNone; @@ -451,7 +451,7 @@ Error Udp::SendDatagram(Message &aMessage, MessageInfo &aMessageInfo, uint8_t aI SuccessOrExit(error = aMessage.Prepend(udpHeader)); aMessage.SetOffset(0); - error = Get().SendDatagram(aMessage, aMessageInfo, aIpProto); + error = Get().SendDatagram(aMessage, aMessageInfo, kProtoUdp); } exit: diff --git a/src/core/net/udp6.hpp b/src/core/net/udp6.hpp index 8f7460a50f7..af30a611e4c 100644 --- a/src/core/net/udp6.hpp +++ b/src/core/net/udp6.hpp @@ -585,13 +585,12 @@ class Udp : public InstanceLocator, private NonCopyable * * @param[in] aMessage A reference to the message. * @param[in] aMessageInfo A reference to the message info associated with @p aMessage. - * @param[in] aIpProto The Internet Protocol value. * * @retval kErrorNone Successfully enqueued the message into an output interface. * @retval kErrorNoBufs Insufficient available buffer to add the IPv6 headers. * */ - Error SendDatagram(Message &aMessage, MessageInfo &aMessageInfo, uint8_t aIpProto); + Error SendDatagram(Message &aMessage, MessageInfo &aMessageInfo); /** * Handles a received UDP message.