73 #include <sys/types.h> 74 #include <sys/socket.h> 75 #include <netinet/in.h> 84 #define MAXSTRLEN 1024 86 #define PU_DLT_APP_DESC "udp adaptor application" 87 #define PU_DLT_CONTEXT_DESC "udp adaptor context" 89 #define PU_DLT_APP "UDPA" 90 #define PU_DLT_CONTEXT "UDPC" 94 int
main(
int argc,
char* argv[])
101 struct sockaddr_in client_addr, server_addr;
113 while ((opt = getopt(argc, argv,
"a:c:hp:v:")) != -1)
131 printf(
"Usage: dlt-adaptor-udp [options]\n");
132 printf(
"Adaptor for forwarding received UDP messages to DLT daemon.\n");
133 printf(
"%s \n", version);
134 printf(
"Options:\n");
135 printf(
"-a apid - Set application id to apid (default: UDPA)\n");
136 printf(
"-c ctid - Set context id to ctid (default: UDPC)\n");
137 printf(
"-p - Set receive port number for UDP messages (default: %d) \n", port);
138 printf(
"-v verbosity level - Set verbosity level (Default: INFO, values: FATAL ERROR WARN INFO DEBUG VERBOSE)\n");
139 printf(
"-h - This help\n");
150 if(!strcmp(optarg,
"FATAL"))
155 else if(!strcmp(optarg,
"ERROR"))
160 else if(!strcmp(optarg,
"WARN"))
165 else if(!strcmp(optarg,
"INFO"))
170 else if(!strcmp(optarg,
"DEBUG"))
175 else if(!strcmp(optarg,
"VERBOSE"))
181 printf(
"Wrong verbosity level, setting to INFO. Accepted values are: FATAL ERROR WARN INFO DEBUG VERBOSE\n");
189 fprintf(stderr,
"Unknown option '%c'\n", optopt);
197 if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) == -1)
199 if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
207 server_addr.sin_family = AF_INET6;
209 server_addr.sin_family = AF_INET;
211 server_addr.sin_port = htons(port);
212 server_addr.sin_addr.s_addr = INADDR_ANY;
213 bzero(&(server_addr.sin_zero), 8);
216 if (bind(sock, (
struct sockaddr *)&server_addr,
217 sizeof(
struct sockaddr)) == -1)
223 addr_len =
sizeof(
struct sockaddr);
232 bytes_read = recvfrom(sock, recv_data,
MAXSTRLEN, 0,
233 (
struct sockaddr *)&client_addr, &addr_len);
235 if (bytes_read == -1)
249 recv_data[bytes_read] =
'\0';
#define DLT_UNREGISTER_APP()
void dlt_set_id(char *id, const char *text)
int main(int argc, char *argv[])
#define DLT_REGISTER_APP(APPID, DESCRIPTION)
#define DLT_REGISTER_CONTEXT(CONTEXT, CONTEXTID, DESCRIPTION)
#define DLT_UNREGISTER_CONTEXT(CONTEXT)
DLT_DECLARE_CONTEXT(mycontext)
#define DLT_LOG(CONTEXT, LOGLEVEL, ARGS...)
void dlt_get_version(char *buf, size_t size)
#define PU_DLT_CONTEXT_DESC