#include <unistd.h>#include "gwlib/gwlib.h"Include dependency graph for udpfeed.c:

Go to the source code of this file.
Defines | |
| #define | UDP_MAXIMUM (65535 - 40) |
Functions | |
| void | help (void) |
| void | send_file (int udpsock, char *filename, Octstr *address) |
| int | main (int argc, char **argv) |
Variables | |
| unsigned char | usage [] |
| Octstr * | hostname |
| int | port = 9200 |
| double | interval = 1.0 |
| long | maxsize = UDP_MAXIMUM |
|
|
|
|
|
Definition at line 89 of file udpfeed.c. 00089 {
00090 info(0, "\n%s", usage);
00091 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 114 of file udpfeed.c. References error(), getopt(), gwlib_init(), gwlib_shutdown(), gwthread_sleep(), help(), hostname, interval, maxsize, octstr_create, octstr_destroy(), optarg, optind, port, send_file(), udp_client_socket(), udp_create_address(), and warning(). 00114 {
00115 int opt;
00116 Octstr *address;
00117 int udpsock;
00118
00119 gwlib_init();
00120
00121 /* Set defaults that can't be set statically */
00122 hostname = octstr_create("localhost");
00123
00124 while ((opt = getopt(argc, argv, "hg:p:i:m:")) != EOF) {
00125 switch(opt) {
00126 case 'g':
00127 octstr_destroy(hostname);
00128 hostname = octstr_create(optarg);
00129 break;
00130
00131 case 'p':
00132 port = atoi(optarg);
00133 break;
00134
00135 case 'i':
00136 interval = atof(optarg);
00137 break;
00138
00139 case 'm':
00140 maxsize = atol(optarg);
00141 if (maxsize > UDP_MAXIMUM) {
00142 maxsize = UDP_MAXIMUM;
00143 warning(0, "-m: truncated to UDP maximum of"
00144 "%ld bytes.", maxsize);
00145 }
00146 break;
00147
00148 case 'h':
00149 help();
00150 exit(0);
00151 break;
00152
00153 case '?':
00154 default:
00155 error(0, "Unknown option '%c'", opt);
00156 help();
00157 exit(1);
00158 break;
00159 }
00160 }
00161
00162 address = udp_create_address(hostname, port);
00163 udpsock = udp_client_socket();
00164 if (udpsock < 0)
00165 exit(1);
00166
00167 for ( ; optind < argc; optind++) {
00168 send_file(udpsock, argv[optind], address);
00169 if (interval > 0 && optind + 1 < argc)
00170 gwthread_sleep(interval);
00171 }
00172
00173 octstr_destroy(address);
00174 octstr_destroy(hostname);
00175 gwlib_shutdown();
00176 return 0;
00177 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 93 of file udpfeed.c. References filename, info(), maxsize, octstr_destroy(), octstr_len(), octstr_read_file(), octstr_truncate(), udp_sendto(), and warning(). Referenced by main(). 00093 {
00094 Octstr *contents;
00095
00096 contents = octstr_read_file(filename);
00097 if (contents == NULL) {
00098 info(0, "Skipping \"%s\".", filename);
00099 return;
00100 }
00101
00102 info(0, "Sending \"%s\", %ld octets.", filename, octstr_len(contents));
00103
00104 if (octstr_len(contents) > maxsize) {
00105 octstr_truncate(contents, maxsize);
00106 warning(0, "Truncating to %ld octets.", maxsize);
00107 }
00108
00109 udp_sendto(udpsock, contents, address);
00110
00111 octstr_destroy(contents);
00112 }
|
Here is the call graph for this function:

|
|
|
|
|
|
|
|
Definition at line 87 of file udpfeed.c. Referenced by main(), and send_file(). |
|
|
|
|
|
Initial value: "\ Usage: udpfeed [options] files...\n\ \n\ where options are:\n\ \n\ -h help\n\ -g hostname name of IP number of host to send to (default: localhost)\n\ -p port port number to send to (default: 9200)\n\ -i interval delay between packers (default: 1.0 seconds)\n\ \n\ Each file will be sent as a single packet.\n\ " Definition at line 71 of file udpfeed.c. Referenced by help(). |