From c13d50fab9defaab546d421a2d7026aca516afe1 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Fri, 8 Aug 2014 22:19:47 -0700 Subject: [PATCH] core: Add command line option to provide SSID --- src/main.c | 7 ++++++- src/wiphy.c | 7 +++++++ src/wiphy.h | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index bc39163b..12f45f1d 100644 --- a/src/main.c +++ b/src/main.c @@ -51,10 +51,12 @@ static void usage(void) "Usage:\n"); printf("\tiwd [options]\n"); printf("Options:\n" + "\t-S, --ssid SSID of network\n" "\t-h, --help Show help options\n"); } static const struct option main_options[] = { + { "ssid", required_argument, NULL, 'S' }, { "version", no_argument, NULL, 'v' }, { "help", no_argument, NULL, 'h' }, { } @@ -70,11 +72,14 @@ int main(int argc, char *argv[]) for (;;) { int opt; - opt = getopt_long(argc, argv, "vh", main_options, NULL); + opt = getopt_long(argc, argv, "S:vh", main_options, NULL); if (opt < 0) break; switch (opt) { + case 'S': + wiphy_set_ssid(optarg); + break; case 'v': printf("%s\n", VERSION); return EXIT_SUCCESS; diff --git a/src/wiphy.c b/src/wiphy.c index 774ee1db..6cc7fbfd 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -33,6 +33,8 @@ #include "linux/nl80211.h" #include "src/wiphy.h" +static const char *network_ssid = NULL; + static struct l_genl *genl = NULL; static struct l_genl_family *nl80211 = NULL; @@ -542,3 +544,8 @@ void wiphy_notify_dellink(uint32_t index) l_queue_foreach(wiphy_list, wiphy_check_dellink, L_UINT_TO_PTR(index)); } + +void wiphy_set_ssid(const char *ssid) +{ + network_ssid = ssid; +} diff --git a/src/wiphy.h b/src/wiphy.h index 13535a33..76e1977b 100644 --- a/src/wiphy.h +++ b/src/wiphy.h @@ -27,3 +27,5 @@ bool wiphy_init(void); bool wiphy_exit(void); void wiphy_notify_dellink(uint32_t index); + +void wiphy_set_ssid(const char *ssid);