|
RPi Locator and Display Services
|
#include <stdlib.h>#include <string.h>#include <glib.h>#include <gio/gio.h>#include <glib-unix.h>#include <gio/gnetworking.h>#include <ifaddrs.h>
Include dependency graph for cmdDS.c:Go to the source code of this file.
Data Structures | |
| struct | _ipBroadcastArray |
| struct | _registryData |
| struct | _signalData |
| struct | _controlData |
Macros | |
| #define | PACKAGE_VERSION "0.9.0" |
| #define | PACKAGE_NAME "cmdDS" |
| #define | PACKAGE_DESCRIPTION "Display Messages from other Raspberry Pi's on the network." |
| #define | G_OPTION_FLAG_NONE 0 |
| #define | UDP_COMM_PORT 48029 |
| #define | UDP_BROADCAST_PORT 48028 |
| #define | UDP_REGULAR_PORT 48027 |
| #define | MS_TEN_MINUTES 600000 |
| #define | SZ_TIMESTAMP_BUFF 32 |
| #define | SZ_PARAMS_BUFF 64 |
| #define | SZ_RMTADDR_BUFF 256 |
| #define | SZ_MESSAGE_BUFF 512 |
| #define | SZ_RESPONSE_BUFF 256 |
| #define | SZ_CHAR_LABEL 48 |
| #define | SZ_INFO_BUFF 256 |
| #define | SZ_CHAR_BUFF 128 |
| #define | SZ_LINE_BUFF 512 |
| #define | SZ_COMM_BUFF 256 |
| #define | SKN_UDP_ANY_PORT 0 |
| #define | ARY_MAX_INTF 8 |
| #define | PLATFORM_ERROR -1 |
Typedefs | |
| typedef struct _ipBroadcastArray | IPBroadcastArray |
| typedef struct _ipBroadcastArray * | PIPBroadcastArray |
| typedef struct _registryData | RegData |
| typedef struct _registryData * | PRegData |
| typedef struct _registryData ** | PPRegData |
| typedef struct _signalData | USignalData |
| typedef struct _signalData * | PUSignalData |
| typedef struct _controlData | ControlData |
| typedef struct _controlData * | PControlData |
Functions | |
| gchar * | skn_get_timestamp () |
| gchar * | skn_strip (gchar *alpha) |
| gchar * | skn_gio_condition_to_string (GIOCondition condition) |
| PPRegData | udp_registry_response_parser (PRegData msg, gchar *response) |
| PIPBroadcastArray | skn_get_default_interface_name_and_ipv4_address (char *intf, char *ipv4) |
| gint | skn_get_broadcast_ip_array (PIPBroadcastArray paB) |
| gint | skn_get_default_interface_name (char *pchDefaultInterfaceName) |
| gboolean | skn_udp_network_broadcast_all_interfaces (GSocket *gSock, PIPBroadcastArray pab) |
| static gboolean | cb_unix_signal_handler (PUSignalData psig) |
| static gboolean | cb_udp_request_handler (GSocket *socket, GIOCondition condition, PControlData pctrl) |
| static gboolean | cb_udp_broadcast_response_handler (GSocket *gSock, GIOCondition condition, PControlData pctrl) |
| PIPBroadcastArray | skn_get_default_interface_name_and_ipv4_address (gchar *intf, gchar *ipv4) |
| int | main (int argc, char **argv) |
| #define ARY_MAX_INTF 8 |
Definition at line 59 of file cmdDS.c.
Referenced by skn_get_broadcast_ip_array().
| #define PACKAGE_DESCRIPTION "Display Messages from other Raspberry Pi's on the network." |
| #define PACKAGE_VERSION "0.9.0" |
cmdDS.c IOT/RaspberryPi message display service gcc -v pkg-config --cflags --libs glib-2.0 gio-2.0 -O3 -Wall cmdDS.c -o cmdDS
Program Flow:
| #define PLATFORM_ERROR -1 |
Definition at line 60 of file cmdDS.c.
Referenced by skn_get_broadcast_ip_array(), and skn_get_default_interface_name_and_ipv4_address().
| #define SZ_CHAR_BUFF 128 |
Definition at line 54 of file cmdDS.c.
Referenced by skn_get_broadcast_ip_array(), and skn_get_default_interface_name_and_ipv4_address().
| #define SZ_INFO_BUFF 256 |
Definition at line 53 of file cmdDS.c.
Referenced by skn_get_default_interface_name().
| #define SZ_RESPONSE_BUFF 256 |
Definition at line 50 of file cmdDS.c.
Referenced by cb_udp_broadcast_response_handler().
| #define SZ_RMTADDR_BUFF 256 |
Definition at line 48 of file cmdDS.c.
Referenced by udp_registry_response_parser().
| #define UDP_BROADCAST_PORT 48028 |
Definition at line 42 of file cmdDS.c.
Referenced by main(), and skn_udp_network_broadcast_all_interfaces().
| typedef struct _controlData ControlData |
| typedef struct _ipBroadcastArray IPBroadcastArray |
| typedef struct _controlData * PControlData |
| typedef struct _ipBroadcastArray * PIPBroadcastArray |
| typedef struct _registryData ** PPRegData |
| typedef struct _registryData * PRegData |
| typedef struct _signalData * PUSignalData |
| typedef struct _registryData RegData |
| typedef struct _signalData USignalData |
|
static |
Definition at line 495 of file cmdDS.c.
References _registryData::ch_from, _registryData::ch_ip, _registryData::ch_message, _registryData::ch_name, _registryData::ch_port, _controlData::ch_this_ip, _registryData::ch_timestamp, _controlData::gUDPPort, _controlData::loop, _controlData::pch_service_name, _controlData::resolver, skn_get_timestamp(), skn_gio_condition_to_string(), SZ_RESPONSE_BUFF, and udp_registry_response_parser().
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 429 of file cmdDS.c.
References _controlData::ch_read, _controlData::ch_request, _controlData::ch_response, _controlData::loop, _controlData::resolver, skn_get_timestamp(), and skn_gio_condition_to_string().
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 307 of file cmdDS.c.
References _signalData::loop, and _signalData::signalName.
Referenced by main().
Here is the caller graph for this function:| int main | ( | int | argc, |
| char ** | argv | ||
| ) |
Definition at line 632 of file cmdDS.c.
References cb_udp_broadcast_response_handler(), cb_udp_request_handler(), cb_unix_signal_handler(), _controlData::ch_intfName, _controlData::ch_this_ip, FALSE, G_OPTION_FLAG_NONE, _controlData::gbSock, _controlData::gSourceId, _controlData::gUDPPort, _signalData::loop, _controlData::loop, _controlData::pch_service_name, _controlData::resolver, _signalData::signalName, skn_get_default_interface_name_and_ipv4_address(), skn_udp_network_broadcast_all_interfaces(), TRUE, UDP_BROADCAST_PORT, and UDP_COMM_PORT.
Here is the call graph for this function:| gint skn_get_broadcast_ip_array | ( | PIPBroadcastArray | paB | ) |
Collect IP and Broadcast Addresses for this machine
Definition at line 170 of file cmdDS.c.
References ARY_MAX_INTF, _ipBroadcastArray::broadAddrStr, _ipBroadcastArray::cbName, _ipBroadcastArray::chDefaultIntfName, _ipBroadcastArray::count, _ipBroadcastArray::defaultIndex, _ipBroadcastArray::ifNameStr, _ipBroadcastArray::ipAddrStr, _ipBroadcastArray::maskAddrStr, PLATFORM_ERROR, skn_get_default_interface_name(), and SZ_CHAR_BUFF.
Referenced by skn_get_default_interface_name_and_ipv4_address().
Here is the call graph for this function:
Here is the caller graph for this function:| gint skn_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 231 of file cmdDS.c.
References skn_strip(), and SZ_INFO_BUFF.
Referenced by skn_get_broadcast_ip_array().
Here is the call graph for this function:
Here is the caller graph for this function:| PIPBroadcastArray skn_get_default_interface_name_and_ipv4_address | ( | char * | intf, |
| char * | ipv4 | ||
| ) |
| PIPBroadcastArray skn_get_default_interface_name_and_ipv4_address | ( | gchar * | intf, |
| gchar * | ipv4 | ||
| ) |
Definition at line 150 of file cmdDS.c.
References _ipBroadcastArray::chDefaultIntfName, _ipBroadcastArray::defaultIndex, _ipBroadcastArray::ipAddrStr, PLATFORM_ERROR, skn_get_broadcast_ip_array(), and SZ_CHAR_BUFF.
Here is the call graph for this function:| gchar* skn_get_timestamp | ( | ) |
Definition at line 312 of file cmdDS.c.
Referenced by cb_udp_broadcast_response_handler(), and cb_udp_request_handler().
Here is the caller graph for this function:| gchar* skn_gio_condition_to_string | ( | GIOCondition | condition | ) |
Definition at line 603 of file cmdDS.c.
Referenced by cb_udp_broadcast_response_handler(), and cb_udp_request_handler().
Here is the caller graph for this function:| gchar* skn_strip | ( | gchar * | alpha | ) |
Remove Trailing and Leading Blanks
Definition at line 124 of file cmdDS.c.
Referenced by skn_get_default_interface_name().
Here is the caller graph for this function:| gboolean skn_udp_network_broadcast_all_interfaces | ( | GSocket * | gSock, |
| PIPBroadcastArray | paB | ||
| ) |
Send a registry request on the broadcast ip of all interfaces
| gSock | IN GLib active/bound socket with broadcast enabled |
| ch_request | IN Greetings message, anytext |
| ch_intfName | OUT Default Ethernet Interface Name |
| ch_ipAddress | OUT Default Ethernet IP Address |
Definition at line 282 of file cmdDS.c.
References _ipBroadcastArray::broadAddrStr, _ipBroadcastArray::count, _ipBroadcastArray::defaultIndex, _ipBroadcastArray::ifNameStr, _ipBroadcastArray::ipAddrStr, TRUE, and UDP_BROADCAST_PORT.
Referenced by main().
Here is the caller graph for this function:Parse this response message
Format: name=rpi_locator_service,ip=10.100.1.19,port=48028| name=lcd_display_service,ip=10.100.1.19,port=48029|
the vertical bar char '|' is the line separator, % and ; are also supported
Definition at line 329 of file cmdDS.c.
References _registryData::ch_ip, _registryData::ch_name, _registryData::ch_port, FALSE, SZ_RMTADDR_BUFF, and TRUE.
Referenced by cb_udp_broadcast_response_handler().
Here is the caller graph for this function: