Skip to content

Commit

Permalink
QUIC Refactor: Fix ANSI - struct definition duplications
Browse files Browse the repository at this point in the history
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from #22674)
  • Loading branch information
hlandau committed Dec 21, 2023
1 parent 99655cb commit ff3a26b
Show file tree
Hide file tree
Showing 18 changed files with 33 additions and 39 deletions.
3 changes: 1 addition & 2 deletions include/internal/quic_ackm.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@
# include "internal/quic_cc.h"
# include "internal/quic_types.h"
# include "internal/quic_wire.h"
# include "internal/quic_predef.h"
# include "internal/time.h"
# include "internal/list.h"

# ifndef OPENSSL_NO_QUIC

typedef struct ossl_ackm_st OSSL_ACKM;

OSSL_ACKM *ossl_ackm_new(OSSL_TIME (*now)(void *arg),
void *now_arg,
OSSL_STATM *statm,
Expand Down
7 changes: 3 additions & 4 deletions include/internal/quic_cc.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@

#include "openssl/params.h"
#include "internal/time.h"
#include "internal/quic_predef.h"

# ifndef OPENSSL_NO_QUIC

typedef struct ossl_cc_data_st OSSL_CC_DATA;

typedef struct ossl_cc_ack_info_st {
/* The time the packet being acknowledged was originally sent. */
OSSL_TIME tx_time;
Expand Down Expand Up @@ -80,7 +79,7 @@ typedef struct ossl_cc_ecn_info_st {
*/
#define OSSL_CC_LOST_FLAG_PERSISTENT_CONGESTION (1U << 0)

typedef struct ossl_cc_method_st {
struct ossl_cc_method_st {
/*
* Instantiation.
*/
Expand Down Expand Up @@ -209,7 +208,7 @@ typedef struct ossl_cc_method_st {
*/
int (*on_ecn)(OSSL_CC_DATA *ccdata,
const OSSL_CC_ECN_INFO *info);
} OSSL_CC_METHOD;
};

extern const OSSL_CC_METHOD ossl_cc_dummy_method;
extern const OSSL_CC_METHOD ossl_cc_newreno_method;
Expand Down
2 changes: 1 addition & 1 deletion include/internal/quic_cfq.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

# include <openssl/ssl.h>
# include "internal/quic_types.h"
# include "internal/quic_predef.h"

# ifndef OPENSSL_NO_QUIC

Expand Down Expand Up @@ -63,7 +64,6 @@ int ossl_quic_cfq_item_is_unreliable(const QUIC_CFQ_ITEM *item);
* QUIC Control Frame Queue
* ========================
*/
typedef struct quic_cfq_st QUIC_CFQ;

QUIC_CFQ *ossl_quic_cfq_new(void);
void ossl_quic_cfq_free(QUIC_CFQ *cfq);
Expand Down
2 changes: 0 additions & 2 deletions include/internal/quic_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ typedef struct quic_channel_args_st {
SSL *tls;
} QUIC_CHANNEL_ARGS;

typedef struct quic_channel_st QUIC_CHANNEL;

/* Represents the cause for a connection's termination. */
typedef struct quic_terminate_cause_st {
/*
Expand Down
6 changes: 1 addition & 5 deletions include/internal/quic_demux.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

# include <openssl/ssl.h>
# include "internal/quic_types.h"
# include "internal/quic_predef.h"
# include "internal/bio_addr.h"
# include "internal/time.h"
# include "internal/list.h"
Expand Down Expand Up @@ -82,8 +83,6 @@
* same allocation.
*/

typedef struct quic_urxe_st QUIC_URXE;

/* Maximum number of packets we allow to exist in one datagram. */
#define QUIC_MAX_PKT_PER_URXE (sizeof(uint64_t) * 8)

Expand Down Expand Up @@ -158,9 +157,6 @@ void ossl_quic_urxe_remove(QUIC_URXE_LIST *l, QUIC_URXE *e);
void ossl_quic_urxe_insert_head(QUIC_URXE_LIST *l, QUIC_URXE *e);
void ossl_quic_urxe_insert_tail(QUIC_URXE_LIST *l, QUIC_URXE *e);

/* Opaque type representing a demuxer. */
typedef struct quic_demux_st QUIC_DEMUX;

/*
* Called when a datagram is received for a given connection ID.
*
Expand Down
2 changes: 1 addition & 1 deletion include/internal/quic_lcidm.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# include "internal/time.h"
# include "internal/quic_types.h"
# include "internal/quic_wire.h"
# include "internal/quic_predef.h"

# ifndef OPENSSL_NO_QUIC

Expand Down Expand Up @@ -95,7 +96,6 @@
* An ODCID has no sequence number associated with it. It is the only CID to
* lack one.
*/
typedef struct quic_lcidm_st QUIC_LCIDM;

/*
* Creates a new LCIDM. lcid_len is the length to use for LCIDs in bytes, which
Expand Down
2 changes: 0 additions & 2 deletions include/internal/quic_port.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ typedef struct quic_port_args_st {
int is_multi_conn;
} QUIC_PORT_ARGS;

typedef struct quic_port_st QUIC_PORT;

QUIC_PORT *ossl_quic_port_new(const QUIC_PORT_ARGS *args);

void ossl_quic_port_free(QUIC_PORT *port);
Expand Down
1 change: 1 addition & 0 deletions include/internal/quic_predef.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ typedef struct quic_port_st QUIC_PORT;
typedef struct quic_channel_st QUIC_CHANNEL;
typedef struct quic_tls_st QUIC_TLS;
typedef struct quic_txpim_st QUIC_TXPIM;
typedef struct quic_fifd_st QUIC_FIFD;
typedef struct quic_cfq_st QUIC_CFQ;
typedef struct ossl_quic_tx_packetiser_st OSSL_QUIC_TX_PACKETISER;
typedef struct ossl_ackm_st OSSL_ACKM;
Expand Down
9 changes: 5 additions & 4 deletions include/internal/quic_reactor.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

# include "internal/time.h"
# include "internal/sockets.h"
# include "internal/quic_predef.h"
# include <openssl/bio.h>

# ifndef OPENSSL_NO_QUIC
Expand Down Expand Up @@ -67,11 +68,11 @@
* adaptation layer on top of our internal asynchronous I/O API as exposed by
* the reactor interface.
*/
typedef struct quic_tick_result_st {
struct quic_tick_result_st {
char net_read_desired;
char net_write_desired;
OSSL_TIME tick_deadline;
} QUIC_TICK_RESULT;
};

static ossl_inline ossl_unused void
ossl_quic_tick_result_merge_into(QUIC_TICK_RESULT *r,
Expand All @@ -82,7 +83,7 @@ ossl_quic_tick_result_merge_into(QUIC_TICK_RESULT *r,
r->tick_deadline = ossl_time_min(r->tick_deadline, src->tick_deadline);
}

typedef struct quic_reactor_st {
struct quic_reactor_st {
/*
* BIO poll descriptors which can be polled. poll_r is a poll descriptor
* which becomes readable when the QUIC state machine can potentially do
Expand Down Expand Up @@ -110,7 +111,7 @@ typedef struct quic_reactor_st {
*/
unsigned int can_poll_r : 1;
unsigned int can_poll_w : 1;
} QUIC_REACTOR;
};

void ossl_quic_reactor_init(QUIC_REACTOR *rtor,
void (*tick_cb)(QUIC_TICK_RESULT *res, void *arg,
Expand Down
5 changes: 3 additions & 2 deletions include/internal/quic_record_rx.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# include <openssl/ssl.h>
# include "internal/quic_wire_pkt.h"
# include "internal/quic_types.h"
# include "internal/quic_predef.h"
# include "internal/quic_record_util.h"
# include "internal/quic_demux.h"

Expand Down Expand Up @@ -178,7 +179,7 @@ int ossl_qrx_discard_enc_level(OSSL_QRX *qrx, uint32_t enc_level);
*/

/* Information about a received packet. */
typedef struct ossl_qrx_pkt_st {
struct ossl_qrx_pkt_st {
/*
* Points to a logical representation of the decoded QUIC packet header. The
* data and len fields point to the decrypted QUIC payload (i.e., to a
Expand Down Expand Up @@ -224,7 +225,7 @@ typedef struct ossl_qrx_pkt_st {
* packets.
*/
uint64_t key_epoch;
} OSSL_QRX_PKT;
};

/*
* Tries to read a new decrypted packet from the QRX.
Expand Down
5 changes: 3 additions & 2 deletions include/internal/quic_record_tx.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# include <openssl/ssl.h>
# include "internal/quic_wire_pkt.h"
# include "internal/quic_types.h"
# include "internal/quic_predef.h"
# include "internal/quic_record_util.h"

# ifndef OPENSSL_NO_QUIC
Expand Down Expand Up @@ -148,7 +149,7 @@ uint32_t ossl_qrl_get_suite_cipher_tag_len(uint32_t suite_id);
* -------------------
*/

typedef struct ossl_qtx_pkt_st {
struct ossl_qtx_pkt_st {
/* Logical packet header to be serialized. */
QUIC_PKT_HDR *hdr;

Expand Down Expand Up @@ -176,7 +177,7 @@ typedef struct ossl_qtx_pkt_st {

/* Packet flags. Zero or more OSSL_QTX_PKT_FLAG_* values. */
uint32_t flags;
} OSSL_QTX_PKT;
};

/*
* More packets will be written which should be coalesced into a single
Expand Down
2 changes: 1 addition & 1 deletion include/internal/quic_srtm.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# include "internal/time.h"
# include "internal/quic_types.h"
# include "internal/quic_wire.h"
# include "internal/quic_predef.h"

# ifndef OPENSSL_NO_QUIC

Expand Down Expand Up @@ -53,7 +54,6 @@
* The opaque pointer may be used for any purpose but is intended to represent a
* connection identity and must therefore be consistent (usefully comparable).
*/
typedef struct quic_srtm_st QUIC_SRTM;

/* Creates a new empty SRTM instance. */
QUIC_SRTM *ossl_quic_srtm_new(OSSL_LIB_CTX *libctx, const char *propq);
Expand Down
5 changes: 3 additions & 2 deletions include/internal/quic_statm.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@

# include <openssl/ssl.h>
# include "internal/time.h"
# include "internal/quic_predef.h"

# ifndef OPENSSL_NO_QUIC

typedef struct ossl_statm_st {
struct ossl_statm_st {
OSSL_TIME smoothed_rtt, latest_rtt, min_rtt, rtt_variance;
char have_first_sample;
} OSSL_STATM;
};

typedef struct ossl_rtt_info_st {
/* As defined in RFC 9002. */
Expand Down
3 changes: 1 addition & 2 deletions include/internal/quic_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "internal/e_os.h"
#include "internal/time.h"
#include "internal/quic_types.h"
#include "internal/quic_predef.h"
#include "internal/quic_wire.h"
#include "internal/quic_record_tx.h"
#include "internal/quic_record_rx.h"
Expand Down Expand Up @@ -51,7 +52,6 @@
* datagrams. The terms 'send' and 'receive' are used when referring to the
* stream abstraction. Applications send; we transmit.
*/
typedef struct quic_sstream_st QUIC_SSTREAM;

/*
* Instantiates a new QUIC_SSTREAM. init_buf_size specifies the initial size of
Expand Down Expand Up @@ -312,7 +312,6 @@ void ossl_quic_sstream_set_cleanse(QUIC_SSTREAM *qss, int cleanse);
* (i.e., for a unidirectional receiving stream or for the receiving component
* of a bidirectional stream).
*/
typedef struct quic_rstream_st QUIC_RSTREAM;

/*
* Create a new instance of QUIC_RSTREAM with pointers to the flow
Expand Down
6 changes: 3 additions & 3 deletions include/internal/quic_stream_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# include "internal/time.h"
# include "internal/common.h"
# include "internal/quic_types.h"
# include "internal/quic_predef.h"
# include "internal/quic_stream.h"
# include "internal/quic_fc.h"
# include <openssl/lhash.h>
Expand All @@ -27,7 +28,6 @@
*
* Logical QUIC stream composing all relevant send and receive components.
*/
typedef struct quic_stream_st QUIC_STREAM;

typedef struct quic_stream_list_node_st QUIC_STREAM_LIST_NODE;

Expand Down Expand Up @@ -514,7 +514,7 @@ static ossl_inline ossl_unused int ossl_quic_stream_recv_get_final_size(const QU
* - allows iteration over the active streams only.
*
*/
typedef struct quic_stream_map_st {
struct quic_stream_map_st {
LHASH_OF(QUIC_STREAM) *map;
QUIC_STREAM_LIST_NODE active_list;
QUIC_STREAM_LIST_NODE accept_list;
Expand All @@ -527,7 +527,7 @@ typedef struct quic_stream_map_st {
QUIC_RXFC *max_streams_bidi_rxfc;
QUIC_RXFC *max_streams_uni_rxfc;
int is_server;
} QUIC_STREAM_MAP;
};

/*
* get_stream_limit is a callback which is called to retrieve the current stream
Expand Down
6 changes: 4 additions & 2 deletions include/internal/quic_tls.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

# include <openssl/ssl.h>
# include "internal/quic_stream.h"
# include "internal/quic_predef.h"


typedef struct quic_tls_st QUIC_TLS;
# ifndef OPENSSL_NO_QUIC

typedef struct quic_tls_args_st {
/*
Expand Down Expand Up @@ -103,4 +103,6 @@ int ossl_quic_tls_get_error(QUIC_TLS *qtls,
int ossl_quic_tls_is_cert_request(QUIC_TLS *qtls);
int ossl_quic_tls_has_bad_max_early_data(QUIC_TLS *qtls);

# endif

#endif
3 changes: 1 addition & 2 deletions include/internal/quic_txp.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

# include <openssl/ssl.h>
# include "internal/quic_types.h"
# include "internal/quic_predef.h"
# include "internal/quic_record_tx.h"
# include "internal/quic_cfq.h"
# include "internal/quic_txpim.h"
Expand Down Expand Up @@ -59,8 +60,6 @@ typedef struct ossl_quic_tx_packetiser_args_st {

} OSSL_QUIC_TX_PACKETISER_ARGS;

typedef struct ossl_quic_tx_packetiser_st OSSL_QUIC_TX_PACKETISER;

OSSL_QUIC_TX_PACKETISER *ossl_quic_tx_packetiser_new(const OSSL_QUIC_TX_PACKETISER_ARGS *args);

typedef void (ossl_quic_initial_token_free_fn)(const unsigned char *buf,
Expand Down
3 changes: 1 addition & 2 deletions include/internal/quic_txpim.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

# include <openssl/ssl.h>
# include "internal/quic_types.h"
# include "internal/quic_predef.h"
# include "internal/quic_cfq.h"
# include "internal/quic_ackm.h"

Expand All @@ -21,8 +22,6 @@
* QUIC Transmitted Packet Information Manager
* ===========================================
*/
typedef struct quic_txpim_st QUIC_TXPIM;
typedef struct quic_fifd_st QUIC_FIFD;

typedef struct quic_txpim_pkt_st {
/* ACKM-specific data. Caller should fill this. */
Expand Down

0 comments on commit ff3a26b

Please sign in to comment.