Fix for delta values reported by vFW vLB
[demo.git] / vnfs / VES5.0 / evel / evel-library / code / evel_training / 15-raise-signaling / hello_evel_world.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4
5 #include "evel.h"
6
7 /*****************************************************************************/
8 /* Local prototypes.                                                         */
9 /*****************************************************************************/
10 static void demo_signaling(void);
11
12 int main(int argc, char ** argv)
13 {
14   EVEL_ERR_CODES evel_rc = EVEL_SUCCESS;
15   EVENT_HEADER * heartbeat = NULL;
16
17   printf("\nHello AT&T Vendor Event world!\n");
18   fflush(stdout);
19
20   if (argc != 5)
21   {
22     fprintf(stderr,
23             "Usage: %s <FQDN>|<IP address> <port> "
24             "<username> <password>\n", argv[0]);
25     exit(-1);
26   }
27
28   /***************************************************************************/
29   /* Initialize                                                              */
30   /***************************************************************************/
31   if (evel_initialize(argv[1],                      /* FQDN                  */
32                       atoi(argv[2]),                /* Port                  */
33                       NULL,                         /* optional path         */
34                       NULL,                         /* optional topic        */
35                       0,                            /* HTTPS?                */
36                       argv[3],                      /* Username              */
37                       argv[4],                      /* Password              */
38                       EVEL_SOURCE_VIRTUAL_MACHINE,  /* Source type           */
39                       "EVEL training demo",         /* Role                  */
40                       0))                           /* Verbosity             */
41   {
42     fprintf(stderr, "\nFailed to initialize the EVEL library!!!\n");
43     exit(-1);
44   }
45   else
46   {
47     printf("\nInitialization completed\n");
48   }
49
50   /***************************************************************************/
51   /* Send a heartbeat just to show we're alive!                              */
52   /***************************************************************************/
53   heartbeat = evel_new_heartbeat();
54   if (heartbeat != NULL)
55   {
56     evel_rc = evel_post_event(heartbeat);
57     if (evel_rc != EVEL_SUCCESS)
58     {
59       printf("Post failed %d (%s)", evel_rc, evel_error_string());
60     }
61   }
62   else
63   {
64     printf("New heartbeat failed");
65   }
66
67   /***************************************************************************/
68   /* Raise a Signaling event                                                 */
69   /***************************************************************************/
70   demo_signaling();
71
72   /***************************************************************************/
73   /* Terminate                                                               */
74   /***************************************************************************/
75   sleep(1);
76   evel_terminate();
77   printf("Terminated\n");
78
79   return 0;
80 }
81
82 /**************************************************************************//**
83  * Create and send a Signaling event.
84  *****************************************************************************/
85 void demo_signaling(void)
86 {
87   EVENT_SIGNALING * event = NULL;
88   EVEL_ERR_CODES evel_rc = EVEL_SUCCESS;
89
90   event = evel_new_signaling("vendor_x_id",
91              "correlator", "1.0.3.1", "1234", "192.168.1.3","3456");
92   if (event != NULL)
93   {
94     evel_signaling_type_set(event, "Signaling");
95     evel_signaling_vnfmodule_name_set(event, "vendor_x_module");
96     evel_signaling_vnfname_set(event, "vendor_x_vnf");
97     evel_signaling_correlator_set(event, "vendor_x_correlator");
98     evel_signaling_local_ip_address_set(event, "1.0.3.1");
99     evel_signaling_local_port_set(event, "1031");
100     evel_signaling_remote_ip_address_set(event, "5.3.3.0");
101     evel_signaling_remote_port_set(event, "5330");
102     evel_signaling_compressed_sip_set(event, "compressed_sip");
103     evel_signaling_summary_sip_set(event, "summary_sip");
104     evel_rc = evel_post_event((EVENT_HEADER *) event);
105     if (evel_rc != EVEL_SUCCESS)
106     {
107       EVEL_ERROR("Post failed %d (%s)", evel_rc, evel_error_string());
108     }
109   }
110   else
111   {
112     EVEL_ERROR("New Signaling failed");
113   }
114   printf("   Processed Signaling\n");
115 }