Browse Source

Merge branch 'cgminer_rpc_mcast_fixes' into cg_merges_20130822a

Luke Dashjr 12 years ago
parent
commit
f4d4105e55
3 changed files with 9 additions and 19 deletions
  1. 4 0
      README
  2. 3 3
      api.c
  3. 2 16
      miner.c

+ 4 - 0
README

@@ -173,6 +173,10 @@ Options for both config file and command line:
 --api-listen        Listen for API requests (default: disabled)
 --api-listen        Listen for API requests (default: disabled)
                     By default any command that does not just display data returns access denied
                     By default any command that does not just display data returns access denied
                     See --api-allow to overcome this
                     See --api-allow to overcome this
+--api-mcast         Enable API Multicast listener, default: disabled
+--api-mcast-addr <arg> API Multicast listen address (default: "224.0.0.75")
+--api-mcast-code <arg> Code expected in the API Multicast (default: "FTW")
+--api-mcast-port <arg> Port number of miner API Multicast listener (default: 4028)
 --api-network       Allow API (if enabled) to listen on/for any address (default: only 127.0.0.1)
 --api-network       Allow API (if enabled) to listen on/for any address (default: only 127.0.0.1)
 --api-port          Port number of miner API (default: 4028)
 --api-port          Port number of miner API (default: 4028)
 --balance           Change multipool strategy from failover to even share balance
 --balance           Change multipool strategy from failover to even share balance

+ 3 - 3
api.c

@@ -3700,7 +3700,6 @@ static void mcast()
 	char *expect_code;
 	char *expect_code;
 	size_t expect_code_len;
 	size_t expect_code_len;
 	char buf[1024];
 	char buf[1024];
-	char reply[] = "cgm-" API_MCAST_CODE "-"; // constant
 	char replybuf[1024];
 	char replybuf[1024];
 
 
 	memset(&grp, 0, sizeof(grp));
 	memset(&grp, 0, sizeof(grp));
@@ -3793,7 +3792,8 @@ static void mcast()
 				reply_sock = socket(AF_INET, SOCK_DGRAM, 0);
 				reply_sock = socket(AF_INET, SOCK_DGRAM, 0);
 
 
 				snprintf(replybuf, sizeof(replybuf),
 				snprintf(replybuf, sizeof(replybuf),
-							"cgm-" API_MCAST_CODE "-%d",
+							"cgm-%s-%d",
+							opt_api_mcast_code,
 							opt_api_port);
 							opt_api_port);
 
 
 				rep = sendto(reply_sock, replybuf, strlen(replybuf)+1,
 				rep = sendto(reply_sock, replybuf, strlen(replybuf)+1,
@@ -3804,7 +3804,7 @@ static void mcast()
 								SOCKERRMSG, (int)reply_sock);
 								SOCKERRMSG, (int)reply_sock);
 				} else {
 				} else {
 					applog(LOG_DEBUG, "API mcast reply (%s) succeeded (%d) (%d)",
 					applog(LOG_DEBUG, "API mcast reply (%s) succeeded (%d) (%d)",
-								reply, (int)rep, (int)reply_sock);
+								replybuf, (int)rep, (int)reply_sock);
 				}
 				}
 
 
 				CLOSESOCKET(reply_sock);
 				CLOSESOCKET(reply_sock);

+ 2 - 16
miner.c

@@ -1290,20 +1290,6 @@ static char *set_api_description(const char *arg)
 	return NULL;
 	return NULL;
 }
 }
 
 
-static char *set_api_mcast_addr(const char *arg)
-{
-	opt_set_charp(arg, &opt_api_mcast_addr);
-
-	return NULL;
-}
-
-static char *set_api_mcast_code(const char *arg)
-{
-	opt_set_charp(arg, &opt_api_mcast_code);
-
-	return NULL;
-}
-
 #ifdef USE_ICARUS
 #ifdef USE_ICARUS
 static char *set_icarus_options(const char *arg)
 static char *set_icarus_options(const char *arg)
 {
 {
@@ -1384,10 +1370,10 @@ static struct opt_table opt_config_table[] = {
 			opt_set_bool, &opt_api_mcast,
 			opt_set_bool, &opt_api_mcast,
 			"Enable API Multicast listener, default: disabled"),
 			"Enable API Multicast listener, default: disabled"),
 	OPT_WITH_ARG("--api-mcast-addr",
 	OPT_WITH_ARG("--api-mcast-addr",
-		     set_api_mcast_addr, NULL, NULL,
+		     opt_set_charp, opt_show_charp, &opt_api_mcast_addr,
 		     "API Multicast listen address"),
 		     "API Multicast listen address"),
 	OPT_WITH_ARG("--api-mcast-code",
 	OPT_WITH_ARG("--api-mcast-code",
-		     set_api_mcast_code, NULL, NULL,
+		     opt_set_charp, opt_show_charp, &opt_api_mcast_code,
 		     "Code expected in the API Multicast"),
 		     "Code expected in the API Multicast"),
 	OPT_WITH_ARG("--api-mcast-port",
 	OPT_WITH_ARG("--api-mcast-port",
 		     set_int_1_to_65535, opt_show_intval, &opt_api_mcast_port,
 		     set_int_1_to_65535, opt_show_intval, &opt_api_mcast_port,