Skip to content
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

Decouple transport from session management. #1424

Merged
merged 34 commits into from
Jul 9, 2020

Conversation

andy31415
Copy link
Contributor

Problem

Currently a separate session manager is created for every transport (e.g. ESP creates 2: one for ipv4 and one for ipv6). There should be a central session and encryption management rather than per protocol.

Summary of Changes

Decouples transport from session management.

fixes #1339

As we make transports generic, the source should be a peer address
rather than a packet info. This is because different transports may have
different address information (specifically type may be different).
The intent is to merge session management as more transports are being
added. Specifically having a single session management for both IPv4 and
IPv6 for ESP.
@CLAassistant
Copy link

CLAassistant commented Jul 2, 2020

CLA assistant check
All committers have signed the CLA.

@andy31415

This comment has been minimized.

Copy link
Contributor

@woody-apple woody-apple left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pan-apple
Copy link
Contributor

LGTM

@woody-apple
Copy link
Contributor

@jelderton @hawk248 @robszewczyk ?

src/transport/Tuple.h Outdated Show resolved Hide resolved
src/transport/Tuple.h Show resolved Hide resolved
src/transport/Tuple.h Show resolved Hide resolved
class Tuple : public Base
{
public:
CHIP_ERROR SendMessage(const MessageHeader & header, const Transport::PeerAddress & address,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include method Doxygen documentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an override of the Base, which includes DoxyGen.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the Doxygen @overload to indicate that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Was not aware @overload is a thing.

That being said, this is redundant: method already has an 'override' C++ tag for this purpose. Then again unsure if Doxygen notices.

return SendMessageImpl<0>(header, address, msgBuf);
}

bool CanSendToPeer(const Transport::PeerAddress & address) override { return CanSendToPeerImpl<0>(address); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include method Doxygen documentation.

Style nit: please don't one-line the declaration and implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restyler fights me here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@woody-apple or @rwalker-apple, thoughts or insights here? Do we have a clang-format option that enforces one-liners? If so, can we disable it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it may be a side-effect of line-wrapping, will look

Copy link
Contributor

@rwalker-apple rwalker-apple Jul 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't achievable with clang-format unless we want to change line width (I don't)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, no, I don't think we should change line width either. However, I find it surprising that if @andy31415 makes a method function body in a header in a "traditional" non-one-liner style:

rvalue name(params, ...)
{
    return someother_function(params);
}

that clang-format / restyler forces this to a one-liner.

src/transport/Tuple.h Outdated Show resolved Hide resolved
src/transport/Tuple.h Show resolved Hide resolved
src/transport/Tuple.h Show resolved Hide resolved
src/transport/Tuple.h Show resolved Hide resolved
src/transport/Tuple.h Show resolved Hide resolved
src/transport/Tuple.h Show resolved Hide resolved
* - BLE transports only support BLE. TCP/UDP support IP addresses
* - Multicasts only supported by UDP
*
* @param TransporTypes the ORDERED list of transport types grouped together. Order matters in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @param needs to be @tparam, per here.

Also TransporTypes -> TransportTypes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are other template parameter instances below that I believe need to be likewise tweaked.

Copy link
Contributor Author

@andy31415 andy31415 Jul 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. VSCode colors @param but not @tparam so I was unsure if the tparam is a thing or not. A search seems to indicate it exists, so I will trust the search. It also turns out (as per below) that I cannot actually verify since our doc build is toast on master

class Tuple : public Base
{
public:
/** @overload */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. When running make doc, does the right thing happen or does Doxygen squawk?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make doc yells at me as 'does not exist' and 'docdist' also complains. There is a makefile under a 'docs' directory however make in there does not do anything.

I am not sure how to build docs :( Still looking though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created #1486 for this: just tried on master checkout and help claims make doc builds docs, however instead I get an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got the docs to build and as a result I made some code formatting changes.

Also found that @overload does more harm than good: if I add it, doxygen adds automatically a 'This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.' where as if I do not add it, it copies over the doxygen from the base class (which seems to be what we want.

I dropped overloads as a result.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks for checking it out.

@woody-apple woody-apple requested a review from gerickson July 9, 2020 02:26
@woody-apple
Copy link
Contributor

@andy31415 can we rebase, and fix conflicts here?

@andy31415 andy31415 merged commit ace290d into project-chip:master Jul 9, 2020
@andy31415 andy31415 deleted the 02_multi_transport branch October 9, 2020 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for multiple transports
9 participants