@@ -600,6 +600,18 @@ channel_op_res_t channel_set_options(channel_t *this,
}
}
+ /*
+ * If requested, use a specific interface/IP address
+ */
+ if (channel_data->iface != NULL) {
+ if (curl_easy_setopt(channel_curl->handle,
+ CURLOPT_INTERFACE,
+ channel_data->iface) != CURLE_OK) {
+ result = CHANNEL_EINIT;
+ goto cleanup;
+ }
+ }
+
switch (method) {
case CHANNEL_GET:
if (curl_easy_setopt(channel_curl->handle, CURLOPT_CUSTOMREQUEST,
@@ -127,6 +127,9 @@ identify : (
# ciphers : string in the format used by CURL to set the allowed ciphers suite
# This allows to disable some ciphers, for example
# ciphers = "!eNULL:!aNULL:!EXP:!LOW:!MEDIUM:!ADH:!AECDH:!IDEA:!SEED:!MD5:!SHA:!RC4:HIGH+EECDH:HIGH+EDH";
+# interface : string
+# interface name (e.g. "eth0") or IP address to bind communication channel to.
+# This allows to select source interface/address for outgoing traffic, if needed.
suricatta :
{
@@ -37,6 +37,7 @@ typedef struct {
char *url;
char *auth;
char *request_body;
+ char *iface;
#ifdef CONFIG_JSON
json_object *json_reply;
#endif
@@ -42,6 +42,9 @@ void suricatta_channel_settings(void *elem, channel_data_t *chan)
GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "proxy", tmp);
if (strlen(tmp))
SETSTRING(chan->proxy, tmp);
+ GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "interface", tmp);
+ if (strlen(tmp))
+ SETSTRING(chan->iface, tmp);
}
server_op_res_t map_channel_retcode(channel_op_res_t response)
@@ -46,6 +46,7 @@ static struct option long_options[] = {
{"proxy", optional_argument, NULL, 'y'},
{"targettoken", required_argument, NULL, 'k'},
{"gatewaytoken", required_argument, NULL, 'g'},
+ {"interface", required_argument, NULL, 'f'},
{NULL, 0, NULL, 0}};
static unsigned short mandatory_argument_count = 0;
@@ -1443,7 +1444,8 @@ void server_print_help(void)
"\t -y, --proxy Use proxy. Either give proxy URL, else "
"{http,all}_proxy env is tried.\n"
"\t -k, --targettoken Set target token.\n"
- "\t -g, --gatewaytoken Set gateway token.\n",
+ "\t -g, --gatewaytoken Set gateway token.\n"
+ "\t -f, --interface Set the network interface to connect to Hawkbit.\n",
CHANNEL_DEFAULT_POLLING_INTERVAL, CHANNEL_DEFAULT_RESUME_TRIES,
CHANNEL_DEFAULT_RESUME_DELAY);
}
@@ -1519,7 +1521,7 @@ server_op_res_t server_start(char *fname, int argc, char *argv[])
/* reset to optind=1 to parse suricatta's argument vector */
optind = 1;
opterr = 0;
- while ((choice = getopt_long(argc, argv, "t:i:c:u:p:xr:y::w:k:g:",
+ while ((choice = getopt_long(argc, argv, "t:i:c:u:p:xr:y::w:k:g:f:",
long_options, NULL)) != -1) {
switch (choice) {
case 't':
@@ -1595,6 +1597,9 @@ server_op_res_t server_start(char *fname, int argc, char *argv[])
channel_data_defaults.retry_sleep =
(unsigned int)strtoul(optarg, NULL, 10);
break;
+ case 'f':
+ SETSTRING(channel_data_defaults.iface, optarg);
+ break;
/* Ignore not recognized options, they can be already parsed by the caller */
case '?':
break;