|
11 | 11 | #include "srsran/e1ap/gateways/e1_local_connector_factory.h" |
12 | 12 | #include "srsran/cu_cp/cu_cp_e1_handler.h" |
13 | 13 | #include "srsran/e1ap/common/e1ap_message.h" |
| 14 | +#include "srsran/e1ap/gateways/e1_network_client_factory.h" |
| 15 | +#include "srsran/e1ap/gateways/e1_network_server_factory.h" |
14 | 16 | #include "srsran/pcap/dlt_pcap.h" |
15 | 17 |
|
16 | 18 | using namespace srsran; |
@@ -87,9 +89,64 @@ class e1_local_connector_impl final : public e1_local_connector |
87 | 89 | srs_cu_cp::cu_cp_e1_handler* cu_cp_e1_mng = nullptr; |
88 | 90 | }; |
89 | 91 |
|
| 92 | +/// Implementation of a CU-UP and CU-CP E1 SCTP-based gateway for the case that the DU and CU-CP are co-located. |
| 93 | +/// |
| 94 | +/// Note: This class should only be used for testing purposes. |
| 95 | +class e1_sctp_connector_impl final : public e1_local_connector |
| 96 | +{ |
| 97 | +public: |
| 98 | + e1_sctp_connector_impl(const e1_local_sctp_connector_config& cfg) : broker(cfg.broker), pcap_writer(cfg.pcap) |
| 99 | + { |
| 100 | + // Create SCTP server. |
| 101 | + sctp_network_gateway_config sctp; |
| 102 | + sctp.if_name = "E1"; |
| 103 | + sctp.ppid = E1AP_PPID; |
| 104 | + sctp.bind_address = "127.0.0.1"; |
| 105 | + // Use any bind port available. |
| 106 | + sctp.bind_port = 0; |
| 107 | + server = create_e1_gateway_server(e1_cu_sctp_gateway_config{sctp, broker, pcap_writer}); |
| 108 | + } |
| 109 | + |
| 110 | + void attach_cu_cp(srs_cu_cp::cu_cp_e1_handler& cu_e1_handler_) override |
| 111 | + { |
| 112 | + server->attach_cu_cp(cu_e1_handler_); |
| 113 | + |
| 114 | + // Create SCTP client. |
| 115 | + sctp_network_connector_config sctp_client; |
| 116 | + sctp_client.if_name = "E1"; |
| 117 | + sctp_client.dest_name = "CU-CP"; |
| 118 | + sctp_client.connect_address = "127.0.0.1"; |
| 119 | + sctp_client.connect_port = server->get_listen_port().value(); |
| 120 | + sctp_client.ppid = E1AP_PPID; |
| 121 | + // Note: We only need to save the PCAPs in one side of the connection. |
| 122 | + client = create_e1_gateway_client(e1_du_sctp_gateway_config{sctp_client, broker, *null_pcap_writer}); |
| 123 | + } |
| 124 | + |
| 125 | + std::optional<uint16_t> get_listen_port() const override { return server->get_listen_port(); } |
| 126 | + |
| 127 | + std::unique_ptr<e1ap_message_notifier> |
| 128 | + handle_cu_up_connection_request(std::unique_ptr<e1ap_message_notifier> cu_up_rx_pdu_notifier) override |
| 129 | + { |
| 130 | + // Connect client to server automatically. |
| 131 | + return client->handle_cu_up_connection_request(std::move(cu_up_rx_pdu_notifier)); |
| 132 | + } |
| 133 | + |
| 134 | +private: |
| 135 | + io_broker& broker; |
| 136 | + dlt_pcap& pcap_writer; |
| 137 | + std::unique_ptr<dlt_pcap> null_pcap_writer = create_null_dlt_pcap(); |
| 138 | + std::unique_ptr<srs_cu_cp::e1_connection_server> server; |
| 139 | + std::unique_ptr<srs_cu_up::e1_connection_client> client; |
| 140 | +}; |
| 141 | + |
90 | 142 | } // namespace |
91 | 143 |
|
92 | 144 | std::unique_ptr<e1_local_connector> srsran::create_e1_local_connector(const e1_local_connector_config& cfg) |
93 | 145 | { |
94 | 146 | return std::make_unique<e1_local_connector_impl>(cfg); |
95 | 147 | } |
| 148 | + |
| 149 | +std::unique_ptr<e1_local_connector> srsran::create_e1_local_connector(const e1_local_sctp_connector_config& cfg) |
| 150 | +{ |
| 151 | + return std::make_unique<e1_sctp_connector_impl>(cfg); |
| 152 | +} |
0 commit comments