Kannel: Open Source WAP and SMS gateway  $Revision: 5037 $
test_boxc.c File Reference
#include "gwlib/gwlib.h"
#include "gw/msg.h"
#include "gw/shared.h"

Go to the source code of this file.

Functions

static void help (void)
 
static void run_connects (void)
 
int main (int argc, char **argv)
 

Variables

static unsigned long port = 13001
 
static unsigned int no_conn = 1
 
static Octstrhost
 

Function Documentation

static void help ( void  )
static

Definition at line 67 of file test_boxc.c.

References info().

Referenced by main().

68 {
69  info(0, "Usage: test_boxc [options] ...");
70  info(0, "where options are:");
71  info(0, "-v number");
72  info(0, " set log level for stderr logging");
73  info(0, "-h hostname");
74  info(0, " hostname where bearerbox is running (default: localhost)");
75  info(0, "-p number");
76  info(0, " port for smsbox connections on bearerbox host (default: 13001)");
77  info(0, "-c number");
78  info(0, " numer of sequential connections that are made and closed (default: 1)");
79 }
void info(int err, const char *fmt,...)
Definition: log.c:636
int main ( int  argc,
char **  argv 
)

Definition at line 109 of file test_boxc.c.

References error(), getopt(), gwlib_init(), gwlib_shutdown(), help(), log_set_output_level(), no_conn, octstr_create, octstr_destroy(), optarg, optind, panic, and run_connects().

110 {
111  int opt;
112 
113  gwlib_init();
114 
115  host = octstr_create("localhost");
116 
117  while ((opt = getopt(argc, argv, "v:h:p:c:")) != EOF) {
118  switch (opt) {
119  case 'v':
121  break;
122 
123  case 'h':
126  break;
127 
128  case 'p':
129  port = atoi(optarg);
130  break;
131 
132  case 'c':
133  no_conn = atoi(optarg);
134  break;
135 
136  case '?':
137  default:
138  error(0, "Invalid option %c", opt);
139  help();
140  panic(0, "Stopping.");
141  }
142  }
143 
144  if (!optind) {
145  help();
146  exit(0);
147  }
148 
149  run_connects();
150 
152 
153  gwlib_shutdown();
154 
155  return 0;
156 }
static unsigned int no_conn
Definition: test_boxc.c:83
void error(int err, const char *fmt,...)
Definition: log.c:612
Definition: http.c:1998
static Octstr * host
Definition: test_boxc.c:84
int optind
Definition: attgetopt.c:80
static void help(void)
Definition: test_boxc.c:67
int getopt(int argc, char **argv, char *opts)
Definition: attgetopt.c:84
void log_set_output_level(enum output_level level)
Definition: log.c:217
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:322
#define octstr_create(cstr)
Definition: octstr.h:125
char * optarg
Definition: attgetopt.c:82
#define panic
Definition: log.h:87
void gwlib_shutdown(void)
Definition: gwlib.c:94
void gwlib_init(void)
Definition: gwlib.c:78
static void run_connects(void)
Definition: test_boxc.c:86
static void run_connects ( void  )
static

Definition at line 86 of file test_boxc.c.

References close_connection_to_bearerbox(), cmd_identify, connect_to_bearerbox(), msg, msg_create, no_conn, octstr_create, and write_to_bearerbox().

Referenced by main().

87 {
88  unsigned int i;
89  Msg *msg;
90 
91  for (i = 1; i <= no_conn; i++) {
92 
93  /* connect to Kannel's bearerbox */
94  connect_to_bearerbox(host, port, 0, NULL);
95 
96  /* identify ourself to bearerbox */
97  msg = msg_create(admin);
98  msg->admin.command = cmd_identify;
99  msg->admin.boxc_id = octstr_create("test-smsbox");
100  write_to_bearerbox(msg);
101 
102  /* do something, like passing MT messages */
103 
104  /* close connection and shutdown */
106  }
107 }
static unsigned int no_conn
Definition: test_boxc.c:83
Definition: http.c:1998
static Octstr * host
Definition: test_boxc.c:84
#define msg_create(type)
Definition: msg.h:136
Definition: msg.h:79
void connect_to_bearerbox(Octstr *host, int port, int ssl, Octstr *our_host)
Definition: shared.c:108
#define octstr_create(cstr)
Definition: octstr.h:125
void close_connection_to_bearerbox(void)
Definition: shared.c:122
void write_to_bearerbox(Msg *pmsg)
Definition: shared.c:142
static XMLRPCDocument * msg
Definition: test_xmlrpc.c:86

Variable Documentation

Octstr* host
static

Definition at line 84 of file test_boxc.c.

unsigned int no_conn = 1
static

Definition at line 83 of file test_boxc.c.

Referenced by main(), and run_connects().

unsigned long port = 13001
static

Definition at line 82 of file test_boxc.c.

See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.