RPi Locator and Display Services
|
Go to the source code of this file.
Variables | |
sig_atomic_t | gi_exit_flag |
char * | gd_pch_message |
signed int | gd_i_debug |
int | gd_i_socket |
char | gd_ch_program_name [SZ_INFO_BUFF] |
char | gd_ch_program_desc [SZ_INFO_BUFF] |
char * | gd_pch_effective_userid |
char | gd_ch_ipAddress [SZ_CHAR_BUFF] |
char | gd_ch_intfName [SZ_CHAR_BUFF] |
char | gd_ch_hostName [SZ_CHAR_BUFF] |
char | gd_ch_hostShortName [SZ_CHAR_BUFF] |
int | gd_i_display |
int | gd_i_unique_registry |
int | gd_i_update |
char * | gd_pch_service_name |
int | gd_i_i2c_address |
int generate_datetime_info | ( | char * | msg | ) |
Definition at line 78 of file skn_network_helpers.c.
References SZ_INFO_BUFF, and TZ_ADJUST.
Referenced by main(), and skn_display_manager_do_work().
int generate_loadavg_info | ( | char * | msg | ) |
Definition at line 45 of file skn_network_helpers.c.
References PLATFORM_ERROR, and SZ_INFO_BUFF.
Referenced by main(), and skn_display_manager_do_work().
int generate_uname_info | ( | char * | msg | ) |
Definition at line 62 of file skn_network_helpers.c.
References skn_get_number_of_cpu_cores(), and SZ_INFO_BUFF.
Referenced by main(), and skn_display_manager_do_work().
int get_broadcast_ip_array | ( | PIPBroadcastArray | paB | ) |
Collect IP and Broadcast Addresses for this machine
Definition at line 214 of file skn_network_helpers.c.
References ARY_MAX_INTF, _ipBroadcastArray::broadAddrStr, _ipBroadcastArray::cbName, _ipBroadcastArray::chDefaultIntfName, _ipBroadcastArray::count, _ipBroadcastArray::defaultIndex, get_default_interface_name(), _ipBroadcastArray::ifNameStr, _ipBroadcastArray::ipAddrStr, _ipBroadcastArray::maskAddrStr, PLATFORM_ERROR, SD_ERR, and SZ_CHAR_BUFF.
Referenced by get_default_interface_name_and_ipv4_address(), service_registry_get_via_udp_broadcast(), service_registry_provider(), and skn_display_manager_message_consumer_thread().
int get_default_interface_name | ( | char * | pchDefaultInterfaceName | ) |
Retrieves default internet interface name into param
[jscott OSX]$ route -n get 0.0.0.0 route to: default destination: default mask: default gateway: 10.21.1.254 interface: en3 flags: <UP,GATEWAY,DONE,STATIC,PRCLONING> recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire 0 0 0 0 0 0 1500 0
Definition at line 275 of file skn_network_helpers.c.
References SD_ERR, skn_strip(), and SZ_INFO_BUFF.
Referenced by get_broadcast_ip_array().
void get_default_interface_name_and_ipv4_address | ( | char * | intf, |
char * | ipv4 | ||
) |
Definition at line 196 of file skn_network_helpers.c.
References _ipBroadcastArray::chDefaultIntfName, _ipBroadcastArray::defaultIndex, get_broadcast_ip_array(), _ipBroadcastArray::ipAddrStr, PLATFORM_ERROR, SD_ERR, and SZ_CHAR_BUFF.
Referenced by main().
void service_registry_destroy | ( | PServiceRegistry | psreg | ) |
Definition at line 1159 of file skn_network_helpers.c.
References _serviceRegistry::count, and _serviceRegistry::entry.
Referenced by main(), and service_registry_valiadate_response_format().
int service_registry_entry_count | ( | PServiceRegistry | psr | ) |
Returns the number of services in registry
Definition at line 947 of file skn_network_helpers.c.
References _serviceRegistry::count.
Referenced by main().
void service_registry_entry_response_message_log | ( | const char * | response | ) |
service_registry_entry_response_message_log()
Definition at line 907 of file skn_network_helpers.c.
References SD_NOTICE.
Referenced by main(), and service_registry_provider().
PRegistryEntry service_registry_find_entry | ( | PServiceRegistry | psreg, |
char * | serviceName | ||
) |
Definition at line 926 of file skn_network_helpers.c.
References _serviceRegistry::entry, and _serviceEntry::name.
Referenced by main(), and service_registry_entry_create().
void* service_registry_get_entry_field_ref | ( | PRegistryEntry | prent, |
char * | field | ||
) |
service_registry_get_entry_field_ref()
Definition at line 969 of file skn_network_helpers.c.
PServiceRegistry service_registry_get_via_udp_broadcast | ( | int | i_socket, |
char * | request | ||
) |
service_registry_get_via_udp_broadcast()
Definition at line 1094 of file skn_network_helpers.c.
References _ipBroadcastArray::broadAddrStr, _ipBroadcastArray::chDefaultIntfName, _ipBroadcastArray::count, _ipBroadcastArray::defaultIndex, gd_ch_intfName, gd_ch_ipAddress, get_broadcast_ip_array(), gi_exit_flag, _ipBroadcastArray::ifNameStr, _ipBroadcastArray::ipAddrStr, PLATFORM_ERROR, SD_DEBUG, SD_EMERG, SD_NOTICE, SD_WARNING, service_registry_create(), service_registry_response_parse(), skn_duration_in_milliseconds(), SKN_FIND_RPI_PORT, SKN_RUN_MODE_RUN, SZ_CHAR_BUFF, and SZ_INFO_BUFF.
Referenced by main().
int service_registry_list_entries | ( | PServiceRegistry | psr | ) |
Logs each entry in service registry
Definition at line 954 of file skn_network_helpers.c.
References _serviceRegistry::count, _serviceRegistry::entry, _serviceEntry::ip, _serviceEntry::name, _serviceEntry::port, and SD_INFO.
Referenced by main().
int service_registry_provider | ( | int | i_socket, |
char * | response | ||
) |
Definition at line 692 of file skn_network_helpers.c.
References _ipBroadcastArray::chDefaultIntfName, _ipBroadcastArray::defaultIndex, gd_i_display, gd_pch_service_name, get_broadcast_ip_array(), gi_exit_flag, _ipBroadcastArray::ipAddrStr, PLATFORM_ERROR, SD_DEBUG, SD_EMERG, SD_ERR, SD_NOTICE, service_registry_entry_response_message_log(), service_registry_valiadate_response_format(), SKN_FIND_RPI_PORT, SKN_RPI_DISPLAY_SERVICE_PORT, SKN_RUN_MODE_RUN, SZ_COMM_BUFF, and SZ_INFO_BUFF.
Referenced by main().
int service_registry_valiadate_response_format | ( | const char * | response | ) |
service_registry_valiadate_response_format()
Definition at line 869 of file skn_network_helpers.c.
References service_registry_create(), service_registry_destroy(), and service_registry_response_parse().
Referenced by main(), and service_registry_provider().
PServiceRegistry service_registry_valiadated_registry | ( | const char * | response | ) |
service_registry_valiadated_registry()
Definition at line 889 of file skn_network_helpers.c.
References service_registry_create(), and service_registry_response_parse().
void signals_cleanup | ( | int | sig | ) |
Definition at line 185 of file skn_network_helpers.c.
References gi_exit_flag, and SKN_RUN_MODE_RUN.
Referenced by main().
void signals_init | ( | ) |
Definition at line 179 of file skn_network_helpers.c.
References exit_handler().
Referenced by main().
void skn_display_manager_message_consumer_shutdown | ( | PDisplayManager | pdm | ) |
skn_display_manager_message_consumer(PDisplayManager pdm)
Definition at line 654 of file skn_rpi_helpers.c.
References _DISPLAY_MANAGER::dm_thread, _DISPLAY_MANAGER::i_socket, SD_NOTICE, SD_WARNING, and _DISPLAY_MANAGER::thread_complete.
Referenced by skn_display_manager_do_work().
int skn_display_manager_message_consumer_startup | ( | PDisplayManager | pdm | ) |
skn_display_manager_message_consumer(PDisplayManager pdm)
Definition at line 629 of file skn_rpi_helpers.c.
References _DISPLAY_MANAGER::dm_thread, _DISPLAY_MANAGER::i_socket, SD_EMERG, SD_NOTICE, SD_WARNING, skn_display_manager_message_consumer_thread(), SKN_RPI_DISPLAY_SERVICE_PORT, and skn_udp_host_create_regular_socket().
Referenced by skn_display_manager_do_work().
double skn_duration_in_milliseconds | ( | struct timeval * | pstart, |
struct timeval * | pend | ||
) |
skn_duration_in_microseconds()
Definition at line 622 of file skn_network_helpers.c.
Referenced by service_registry_get_via_udp_broadcast(), and skn_udp_service_request().
long skn_get_number_of_cpu_cores | ( | ) |
Definition at line 40 of file skn_network_helpers.c.
Referenced by generate_rpi_model_info(), generate_uname_info(), and main().
uid_t skn_get_userids | ( | ) |
DELAY FOR # uS WITHOUT SLEEPING Ref: http://www.raspberry-projects.com/pi/programming-in-c/timing/clock_gettime-for-acurate-timing
Using delayMicroseconds lets the linux scheduler decide to jump to another process. Using this function avoids letting the scheduler know we are pausing and provides much faster operation if you are needing to use lots of delays.
Fixup incase your building on for OSX, which does not implement clock_gettime()
#ifdef MACH #include <sys/time.h> #define CLOCK_REALTIME 0
clock_gettime is not implemented on OSX *
int clock_gettime(int clk_id, struct timespec* t) { struct timeval now; int rv = gettimeofday(&now, NULL); if (rv) return rv; t->tv_sec = now.tv_sec; t->tv_nsec = now.tv_usec * 1000; return 0; } #endif
void skn_delay_microseconds (int delay_us) { long int start_time; long int time_difference; struct timespec gettime_now;
clock_gettime(CLOCK_REALTIME, &gettime_now); start_time = gettime_now.tv_nsec; //Get nS value while (1) { clock_gettime(CLOCK_REALTIME, &gettime_now); time_difference = gettime_now.tv_nsec - start_time; if (time_difference < 0) time_difference += 1000000000; //(Rolls over every 1 second) if (time_difference > (delay_us * 1000)) //Delay for # nS break; } } Setup effective and real userid
Definition at line 152 of file skn_network_helpers.c.
References gd_pch_effective_userid.
Referenced by main().
int skn_handle_locator_command_line | ( | int | argc, |
char ** | argv | ||
) |
Definition at line 373 of file skn_network_helpers.c.
References gd_ch_program_name, gd_i_debug, gd_i_display, gd_i_i2c_address, gd_i_unique_registry, gd_i_update, gd_pch_message, gd_pch_service_name, PACKAGE_VERSION, SD_ERR, SD_WARNING, and skn_locator_print_usage().
Referenced by main().
void skn_program_name_and_description_set | ( | const char * | name, |
const char * | desc | ||
) |
Definition at line 462 of file skn_network_helpers.c.
References gd_ch_hostName, gd_ch_hostShortName, gd_ch_program_desc, gd_ch_program_name, and SZ_CHAR_BUFF.
Referenced by main().
PServiceRequest skn_service_request_create | ( | PRegistryEntry | pre, |
int | host_socket, | ||
char * | request | ||
) |
Definition at line 603 of file skn_network_helpers.c.
References _serviceRequest::cbName, _serviceRequest::pre, _serviceRequest::request, _serviceRequest::socket, and SZ_INFO_BUFF.
Referenced by main().
char* skn_strip | ( | char * | alpha | ) |
Remove Trailing and Leading Blanks
Definition at line 480 of file skn_network_helpers.c.
References SD_NOTICE, and SZ_LINE_BUFF.
Referenced by get_default_interface_name(), service_registry_entry_create_helper(), and service_registry_response_parse().
int skn_time_delay | ( | double | delay_time | ) |
Traditional Millisecond delay.
Definition at line 96 of file skn_network_helpers.c.
Referenced by skn_display_manager_do_work(), skn_display_manager_message_consumer_thread(), and skn_scroller_scroll_lines().
int skn_udp_host_create_broadcast_socket | ( | int | port, |
double | rcvTimeout | ||
) |
skn_udp_host_create_broadcast_socket()
Definition at line 568 of file skn_network_helpers.c.
References SD_EMERG, and SD_INFO.
Referenced by main().
int skn_udp_host_create_regular_socket | ( | int | port, |
double | rcvTimeout | ||
) |
skn_udp_host_create_regular_socket()
Definition at line 527 of file skn_network_helpers.c.
References SD_EMERG.
Referenced by main(), and skn_display_manager_message_consumer_startup().
int skn_udp_service_request | ( | PServiceRequest | psr | ) |
Definition at line 645 of file skn_network_helpers.c.
References _serviceEntry::ip, _serviceEntry::name, PLATFORM_ERROR, _serviceEntry::port, _serviceRequest::pre, _serviceRequest::request, _serviceRequest::response, SD_INFO, SD_NOTICE, SD_WARNING, skn_duration_in_milliseconds(), _serviceRequest::socket, and SZ_INFO_BUFF.
Referenced by main().
char gd_ch_hostName[SZ_CHAR_BUFF] |
Definition at line 24 of file skn_network_helpers.c.
Referenced by skn_program_name_and_description_set().
char gd_ch_hostShortName[SZ_CHAR_BUFF] |
Definition at line 25 of file skn_network_helpers.c.
Referenced by skn_program_name_and_description_set().
char gd_ch_intfName[SZ_CHAR_BUFF] |
Definition at line 23 of file skn_network_helpers.c.
Referenced by generate_rpi_model_info(), main(), and service_registry_get_via_udp_broadcast().
char gd_ch_ipAddress[SZ_CHAR_BUFF] |
Definition at line 22 of file skn_network_helpers.c.
Referenced by generate_rpi_model_info(), main(), and service_registry_get_via_udp_broadcast().
char gd_ch_program_desc[SZ_INFO_BUFF] |
Definition at line 16 of file skn_network_helpers.c.
Referenced by skn_display_print_usage(), skn_locator_print_usage(), and skn_program_name_and_description_set().
char gd_ch_program_name[SZ_INFO_BUFF] |
Definition at line 15 of file skn_network_helpers.c.
Referenced by main(), skn_display_print_usage(), skn_handle_display_command_line(), skn_handle_locator_command_line(), skn_locator_print_usage(), and skn_program_name_and_description_set().
signed int gd_i_debug |
Definition at line 14 of file skn_network_helpers.c.
Referenced by skn_handle_display_command_line(), and skn_handle_locator_command_line().
int gd_i_display |
Definition at line 19 of file skn_network_helpers.c.
Referenced by service_registry_provider(), and skn_handle_locator_command_line().
int gd_i_i2c_address |
Definition at line 27 of file skn_network_helpers.c.
int gd_i_socket |
Definition at line 18 of file skn_network_helpers.c.
Referenced by main().
int gd_i_unique_registry |
Definition at line 21 of file skn_network_helpers.c.
Referenced by service_registry_entry_create(), and skn_handle_locator_command_line().
int gd_i_update |
Definition at line 20 of file skn_network_helpers.c.
Referenced by main(), and skn_handle_locator_command_line().
char* gd_pch_effective_userid |
Definition at line 17 of file skn_network_helpers.c.
Referenced by main(), and skn_get_userids().
char* gd_pch_message |
Definition at line 12 of file skn_network_helpers.c.
Referenced by main(), skn_handle_display_command_line(), and skn_handle_locator_command_line().
char* gd_pch_service_name |
Definition at line 26 of file skn_network_helpers.c.
Referenced by main(), service_registry_provider(), and skn_handle_locator_command_line().
sig_atomic_t gi_exit_flag |
sknNetworkHelpers.c
Definition at line 11 of file skn_network_helpers.c.
Referenced by exit_handler(), main(), service_registry_get_via_udp_broadcast(), service_registry_provider(), signals_cleanup(), skn_display_manager_do_work(), skn_display_manager_message_consumer_thread(), skn_signal_manager_handler_thread(), skn_signal_manager_process_signals(), and skn_signal_manager_shutdown().