MT#55283 unify constructor signatures

All functions that create listener objects take a read-only endpoint, so
make them as const.

Remove the extra TOS argument to make all signatures the same.

Change-Id: I722c7665b192476d90dbf0ece200d0bfd34cb9eb
pull/1759/head
Richard Fuchs 2 years ago
parent 3a9409352d
commit 267f965098

@ -1255,7 +1255,7 @@ static void cli_free(void *p) {
streambuf_listener_shutdown(&c->listener);
}
struct cli *cli_new(endpoint_t *ep) {
struct cli *cli_new(const endpoint_t *ep) {
struct cli *c;
c = obj_alloc0("cli", sizeof(*c), cli_free);

@ -533,7 +533,7 @@ void control_ng_free(void *p) {
g_hash_table_destroy(tcp_connections_hash);
}
struct control_ng *control_ng_new(endpoint_t *ep, unsigned char tos) {
struct control_ng *control_ng_new(const endpoint_t *ep) {
struct control_ng *c;
c = obj_alloc0("control_ng", sizeof(*c), control_ng_free);
@ -542,8 +542,8 @@ struct control_ng *control_ng_new(endpoint_t *ep, unsigned char tos) {
if (udp_listener_init(&c->udp_listener, ep, control_ng_incoming, &c->obj))
goto fail2;
if (tos)
set_tos(&c->udp_listener, tos);
if (rtpe_config.control_tos)
set_tos(&c->udp_listener, rtpe_config.control_tos);
if (rtpe_config.control_pmtu)
set_pmtu_disc(&c->udp_listener,
rtpe_config.control_pmtu == PMTU_DISC_WANT ? IP_PMTUDISC_WANT : IP_PMTUDISC_DONT);
@ -554,7 +554,7 @@ fail2:
return NULL;
}
struct control_ng *control_ng_tcp_new(endpoint_t *ep) {
struct control_ng *control_ng_tcp_new(const endpoint_t *ep) {
struct control_ng * ctrl_ng = obj_alloc0("control_ng", sizeof(*ctrl_ng), NULL);
ctrl_ng->udp_listener.fd = -1;

@ -151,7 +151,7 @@ static void control_tcp_free(void *p) {
pcre_free_study(c->parse_ree);
}
struct control_tcp *control_tcp_new(endpoint_t *ep) {
struct control_tcp *control_tcp_new(const endpoint_t *ep) {
struct control_tcp *c;
const char *errptr;
int erroff;

@ -142,7 +142,7 @@ void control_udp_free(void *p) {
cookie_cache_cleanup(&u->cookie_cache);
}
struct control_udp *control_udp_new(endpoint_t *ep) {
struct control_udp *control_udp_new(const endpoint_t *ep) {
struct control_udp *c;
const char *errptr;
int erroff;

@ -1157,15 +1157,13 @@ no_kernel:
if (rtpe_config.ng_listen_ep[0].port) {
interfaces_exclude_port(rtpe_config.ng_listen_ep[0].port);
rtpe_control_ng[0] = control_ng_new(&rtpe_config.ng_listen_ep[0],
rtpe_config.control_tos);
rtpe_control_ng[0] = control_ng_new(&rtpe_config.ng_listen_ep[0]);
if (!rtpe_control_ng[0])
die("Failed to open UDP NG control connection port (%s): %s",
endpoint_print_buf(&rtpe_config.ng_listen_ep[0]),
strerror(errno));
if (rtpe_config.ng_listen_ep[1].port) {
rtpe_control_ng[1] = control_ng_new(&rtpe_config.ng_listen_ep[1],
rtpe_config.control_tos);
rtpe_control_ng[1] = control_ng_new(&rtpe_config.ng_listen_ep[1]);
if (!rtpe_control_ng[1])
die("Failed to open UDP NG control connection port (%s): %s",
endpoint_print_buf(&rtpe_config.ng_listen_ep[1]),

@ -22,7 +22,7 @@ struct cli_writer {
struct call_monologue *ml;
};
struct cli *cli_new(endpoint_t *);
struct cli *cli_new(const endpoint_t *);
void cli_handle(str *instr, struct cli_writer *);

@ -65,8 +65,8 @@ struct ng_buffer {
extern const char *ng_command_strings[NGC_COUNT];
extern const char *ng_command_strings_short[NGC_COUNT];
struct control_ng *control_ng_new(endpoint_t *, unsigned char);
struct control_ng *control_ng_tcp_new(endpoint_t *);
struct control_ng *control_ng_new(const endpoint_t *);
struct control_ng *control_ng_tcp_new(const endpoint_t *);
void notify_ng_tcp_clients(str *);
void control_ng_init(void);
void control_ng_cleanup(void);

@ -34,7 +34,7 @@ struct streambuf_stream;
struct control_tcp *control_tcp_new(endpoint_t *);
struct control_tcp *control_tcp_new(const endpoint_t *);

@ -55,7 +55,7 @@ struct control_udp {
struct control_udp *control_udp_new(endpoint_t *);
struct control_udp *control_udp_new(const endpoint_t *);

Loading…
Cancel
Save