From 727da5e28aa110f7931b696f1b1ba74e805bb9b4 Mon Sep 17 00:00:00 2001 From: Riza Sulistyo Date: Thu, 19 Jun 2014 05:07:12 +0000 Subject: Re #1771: Implement run-time configuration to set specific socket option. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4860 74dad513-b988-da41-8d7b-12977e46ad98 --- pjlib/include/pj/sock.h | 37 +++++++++++++++++++++++++++++++++++++ pjlib/include/pj/ssl_sock.h | 16 ++++++++++++++++ 2 files changed, 53 insertions(+) (limited to 'pjlib/include') diff --git a/pjlib/include/pj/sock.h b/pjlib/include/pj/sock.h index b7d1cb05..44d0fecd 100644 --- a/pjlib/include/pj/sock.h +++ b/pjlib/include/pj/sock.h @@ -616,6 +616,32 @@ typedef struct pj_ip_mreq { pj_in_addr imr_interface; /**< local IP address of interface. */ } pj_ip_mreq; +/* Maximum number of socket options. */ +#define PJ_MAX_SOCKOPT_PARAMS 4 + +/** + * Options to be set for the socket. + */ +typedef struct pj_sockopt_params +{ + /* The number of options to be applied. */ + unsigned cnt; + + /* Array of options to be applied. */ + struct { + /* The level at which the option is defined. */ + int level; + + /* Option name. */ + int optname; + + /* Pointer to the buffer in which the option is specified. */ + void *optval; + + /* Buffer size of the buffer pointed by optval. */ + int optlen; + } options[PJ_MAX_SOCKOPT_PARAMS]; +} pj_sockopt_params; /***************************************************************************** * @@ -1305,6 +1331,17 @@ PJ_DECL(pj_status_t) pj_sock_setsockopt( pj_sock_t sockfd, const void *optval, int optlen); +/** + * Set socket options associated with a socket. This method will apply all the + * options specified, and ignore any errors that might be raised. + * + * @param sockfd The socket descriptor. + * @param params The socket options. + * + * @return PJ_SUCCESS or the last error code. + */ +PJ_DECL(pj_status_t) pj_sock_setsockopt_params( pj_sock_t sockfd, + const pj_sockopt_params *params); /** * Helper function to set socket buffer size using #pj_sock_setsockopt() diff --git a/pjlib/include/pj/ssl_sock.h b/pjlib/include/pj/ssl_sock.h index 0d24a494..23843717 100644 --- a/pjlib/include/pj/ssl_sock.h +++ b/pjlib/include/pj/ssl_sock.h @@ -749,6 +749,22 @@ typedef struct pj_ssl_sock_param */ pj_bool_t qos_ignore_error; + /** + * Specify options to be set on the transport. + * + * By default there is no options. + * + */ + pj_sockopt_params sockopt_params; + + /** + * Specify if the transport should ignore any errors when setting the + * sockopt parameters. + * + * Default: PJ_TRUE + * + */ + pj_bool_t sockopt_ignore_error; } pj_ssl_sock_param; -- cgit v1.2.3