RPi Locator and Display Services
udp_locator_service.c File Reference
+ Include dependency graph for udp_locator_service.c:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

udp_locator_service.c

  • Server

cmdline: ./udp_locator_service -m "<delimited-response-message-string>"

delimited-response-message-string : required order -> name,ip,port,line-delimiter... format: "name=<service-name>,ip=<service-ipaddress>ddd.ddd.ddd.ddd,port=<service-portnumber>ddddd <line-delimiter>" name=<service-name> text_string_with_no_spaces ip=<service-ipaddress> ddd.ddd.ddd.ddd port=<service-portnumber> ddddd REQUIRED <line-delimiter> is one of these '|', '', ';'

example: -m "name=lcd_display_service,ip=192.168.1.15,port=48028|" udp_locator_service -m "mame=rpi_locator_service, ip=10.100.1.19, port=48028|name=lcd_display_service, pip=10.100.1.19, port=48029|name=rpi_locator_service, ip=10.100.1.19, port=48028|name=lcd_display_service, port=48029|"

Definition at line 20 of file udp_locator_service.c.

References gd_ch_program_name, gd_i_socket, gd_pch_effective_userid, gd_pch_message, gi_exit_flag, PACKAGE_VERSION, SD_EMERG, SD_NOTICE, service_registry_entry_response_message_log(), service_registry_provider(), service_registry_valiadate_response_format(), signals_cleanup(), signals_init(), SKN_FIND_RPI_PORT, skn_get_userids(), skn_handle_locator_command_line(), skn_program_name_and_description_set(), skn_udp_host_create_broadcast_socket(), and SZ_COMM_BUFF.

21 {
22  int exit_code = EXIT_SUCCESS;
23  char response[SZ_COMM_BUFF];
24 
25  memset(response, 0, sizeof(response));
26 
28  "udp_locator_service",
29  "Provides IPv4 Address/Port Service info."
30  );
31 
32  if (skn_handle_locator_command_line(argc, argv) == EXIT_FAILURE) {
33  exit(EXIT_FAILURE);
34  }
35  if (gd_pch_message != NULL) {
36  strncpy(response, gd_pch_message, sizeof(response));
37  free(gd_pch_message); // from strdup()
38  gd_pch_message = response;
39  }
41  skn_logger(SD_NOTICE, "%s-%s is in startup mode as user(%s)", gd_ch_program_name, PACKAGE_VERSION, gd_pch_effective_userid);
42 
43  if ((strlen(response) > 16) && (service_registry_valiadate_response_format(response) == EXIT_FAILURE)) {
44  skn_logger(SD_EMERG, "Message format is invalid! cannot proceed.");
46  exit(EXIT_FAILURE);
47  }
48 
49  /* Initialize Signal handler */
50  signals_init();
51 
53  if (gd_i_socket == EXIT_FAILURE) {
54  skn_logger(SD_EMERG, "Application Host Init Failed! ExitCode=%d", exit_code);
56  exit(EXIT_FAILURE);
57  }
58 
59  exit_code = service_registry_provider(gd_i_socket, response);
60  skn_logger(SD_NOTICE, "Application ExitCode=%d", exit_code);
61 
62  if (gd_i_socket) close(gd_i_socket);
64 
65  skn_logger(SD_NOTICE, "\n============================\nShutdown Complete\n============================\n");
66 
67  exit(exit_code);
68 }
int service_registry_provider(int i_socket, char *response)
void signals_init()
void signals_cleanup(int sig)
int skn_handle_locator_command_line(int argc, char **argv)
char * gd_pch_message
uid_t skn_get_userids()
#define SZ_COMM_BUFF
Definition: cmdDC.c:59
#define SD_EMERG
void service_registry_entry_response_message_log(const char *response)
char gd_ch_program_name[SZ_INFO_BUFF]
int service_registry_valiadate_response_format(const char *response)
sig_atomic_t gi_exit_flag
#define SD_NOTICE
int skn_udp_host_create_broadcast_socket(int port, double rcvTimeout)
char * gd_pch_effective_userid
void skn_program_name_and_description_set(const char *name, const char *desc)
#define PACKAGE_VERSION
Definition: cmdDC.c:19
#define SKN_FIND_RPI_PORT
int gd_i_socket

+ Here is the call graph for this function: