|
| | rsocket_alpn () noexcept |
| | Instantiate a new rsocket_alpn object.
|
| | rsocket_alpn (const rsocket_alpn &original) noexcept |
| | Instantiate a new rsocket_alpn object that is an independent copy of an existing rsocket_alpn object.
|
| | ~rsocket_alpn () noexcept |
| | Destructor for rsocket_alpn object, which releases all interally-allocated resources.
|
| rsocket_alpn & | add (const char *alpn_protocol, int len=-1) |
| | Add one protocol name to the internal ALPN protocol-list structure. If the protocol name provided is already in the list, or it's an empty string (or nullptr was provided), it will simply be ignored.
|
| rsocket_alpn & | add (const std::string &alpn_protocol) |
| | Add one protocol name to the internal ALPN protocol-list structure. If the protocol name provided is already in the list, or it's an empty string, it will simply be ignored.
|
| template<class... Ps> |
| rsocket_alpn & | add (const std::string &alpn_protocol, Ps... alpn_protocols) |
| | Add one or more new protocol names, which will be added to the internal ALPN protocol-list structure.
|
| const unsigned char * | data () noexcept |
| | Return pointer to entire ALPN protocol-list structure.
|
| rsocket_alpn & | del (const char *alpn_protocol, int len=-1) |
| | Delete one protocol name from the internal ALPN protocol-list structure. If the protocol name provided is not already in the list, or it's an empty string (or nullptr was provided), nothing will be deleted.
|
| rsocket_alpn & | del (const std::string &alpn_protocol) |
| | Delete one protocol name from the internal ALPN protocol-list structure.
|
| template<class... Ps> |
| rsocket_alpn & | del (const std::string &alpn_protocol, Ps... alpn_protocols) |
| | Delete one or more protocol names from the internal ALPN protocol-list.
|
| bool | exists (const char *alpn_protocol, int len=-1) noexcept |
| | Indicate whether a given ALPN protocol-name is in the internal structure.
|
| int | find (const char *alpn_protocol) |
| | Find the array position of the first respective ALPN protocol-name within the internal structure.
|
| size_t | operator[] (const char *alpn_protocol) |
| | Array-style access to the index of the respective ALPN protocol-name within the internal structure.
|
| std::string | operator[] (int index) |
| | Array-style access to the respective ALPN protocol-name within the internal structure, which yields the same result as that of the at() method.
|
| size_t | size () noexcept |
| | Return quantity of names in the internal ALPN protocol-list structure.
|
The rsocket_alpn class provides a specialized interface for easily managing a collection of ALPN protocol names, and maintaining the underlying structure that's always immediately ready for use with OpenSSL's ALPN callback function and any other uses that need this.
- Note
- There's no maximum limit on the number of ALPN protocol name entries that can be added (aside from system memory limits, of course).
At present, the official variety of ALPN protocol names is small, but as this list is expected to grow significantly as QUIC continues to gain popularity, a long list of protocol names will not be a hindering factor.
The DNS protocol uses the same format, although with a slight variation in that the total length of the ALPN structure is known beforehand.
An example of the format of ALPN is presented in the OpenSSL 3.5 documentation as follows:
static const unsigned char alpn_ossltest[] = {
8, 'h', 't', 't', 'p', '/', '1', '.', '0',
10, 'h', 'q', '-', 'i', 'n', 't', 'e', 'r', 'o', 'p',
};
This shows an example of having two entries, each of which begins with one byte indicating the length of the ALPN name, and then that exact quantity of characters (note that there are no terminating zeroes):
- <0x08> http/1.0
- <0x0a> hq-interop
The total size of the ALPN protocol-list is not included in the list data, and OpenSSL's documentation relies on sizeof(alpn_ossltest) to determine the size of the ALPN protocol-list. While this is fine for simple uses, this class provides a dymamically-maintained size that's always correct.
In summary, the purpose of this rsocket_alpn class is to eliminate the hassle of having to maintain ALPN protocol-list data, which sipmlifies coding efforts in a manner that also makes it much easier to develop software that can have more configuration options, including ALPN protocol-list sets.
- Author
- Randolf Richardson
- Version
- 1.00
- History
- 2025-Oct-24 v1.00 Initial version, which has a limited feature-set to get things working: add(), size(), and data() methods only
- 2025-Oct-26 v1.00 Added del(), exists(), find(), and operator[] methods