Kannel: Open Source WAP and SMS gateway  $Revision: 5037 $
wap_addr.h File Reference
#include "gwlib/gwlib.h"

Go to the source code of this file.

Data Structures

struct  WAPAddr
 
struct  WAPAddrTuple
 

Functions

WAPAddrwap_addr_create (Octstr *address, long port)
 
void wap_addr_destroy (WAPAddr *addr)
 
int wap_addr_same (WAPAddr *a, WAPAddr *b)
 
WAPAddrTuplewap_addr_tuple_create (Octstr *rmt_addr, long rmt_port, Octstr *lcl_addr, long lcl_port)
 
void wap_addr_tuple_destroy (WAPAddrTuple *tuple)
 
int wap_addr_tuple_same (WAPAddrTuple *a, WAPAddrTuple *b)
 
WAPAddrTuplewap_addr_tuple_duplicate (WAPAddrTuple *tuple)
 
void wap_addr_tuple_dump (WAPAddrTuple *tuple)
 

Function Documentation

WAPAddr* wap_addr_create ( Octstr address,
long  port 
)

Definition at line 68 of file wap_addr.c.

References WAPAddr::address, WAPAddr::iaddr, octstr_duplicate, octstr_get_cstr, WAPAddr::port, and port.

Referenced by wap_addr_tuple_create().

69 {
70  WAPAddr *addr;
71 
72  addr = gw_malloc(sizeof(*addr));
73  addr->address = octstr_duplicate(address);
74  addr->iaddr = inet_addr(octstr_get_cstr(address));
75  addr->port = port;
76  return addr;
77 }
in_addr_t iaddr
Definition: wap_addr.h:69
Octstr * address
Definition: wap_addr.h:68
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
static int port
Definition: fakesmsc.c:120
#define octstr_duplicate(ostr)
Definition: octstr.h:187
long port
Definition: wap_addr.h:70
void wap_addr_destroy ( WAPAddr addr)

Definition at line 80 of file wap_addr.c.

References WAPAddr::address, and octstr_destroy().

Referenced by wap_addr_tuple_destroy().

81 {
82  if (addr != NULL) {
83  octstr_destroy(addr->address);
84  gw_free(addr);
85  }
86 }
Octstr * address
Definition: wap_addr.h:68
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:322
int wap_addr_same ( WAPAddr a,
WAPAddr b 
)

Definition at line 89 of file wap_addr.c.

References WAPAddr::iaddr, and WAPAddr::port.

Referenced by wap_addr_tuple_same().

90 {
91  /* XXX which ordering gives the best heuristical performance? */
92  return a->port == b->port && a->iaddr == b->iaddr;
93 }
in_addr_t iaddr
Definition: wap_addr.h:69
long port
Definition: wap_addr.h:70
WAPAddrTuple* wap_addr_tuple_create ( Octstr rmt_addr,
long  rmt_port,
Octstr lcl_addr,
long  lcl_port 
)

Definition at line 96 of file wap_addr.c.

References WAPAddrTuple::local, WAPAddrTuple::remote, and wap_addr_create().

Referenced by addr_tuple_change_cliport(), main(), set_addr_tuple(), wap_addr_tuple_duplicate(), and wdp_msg2event().

98 {
99  WAPAddrTuple *tuple;
100 
101  tuple = gw_malloc(sizeof(*tuple));
102  tuple->remote = wap_addr_create(rmt_addr, rmt_port);
103  tuple->local = wap_addr_create(lcl_addr, lcl_port);
104  return tuple;
105 }
WAPAddr * local
Definition: wap_addr.h:74
WAPAddr * remote
Definition: wap_addr.h:74
WAPAddr * wap_addr_create(Octstr *address, long port)
Definition: wap_addr.c:68
void wap_addr_tuple_destroy ( WAPAddrTuple tuple)

Definition at line 108 of file wap_addr.c.

References WAPAddrTuple::local, WAPAddrTuple::remote, and wap_addr_destroy().

Referenced by cache_item_destroy(), find_session_machine(), and handle_push_message().

109 {
110  if (tuple != NULL) {
111  wap_addr_destroy(tuple->remote);
112  wap_addr_destroy(tuple->local);
113  gw_free(tuple);
114  }
115 }
WAPAddr * local
Definition: wap_addr.h:74
WAPAddr * remote
Definition: wap_addr.h:74
void wap_addr_destroy(WAPAddr *addr)
Definition: wap_addr.c:80
void wap_addr_tuple_dump ( WAPAddrTuple tuple)

Definition at line 137 of file wap_addr.c.

References WAPAddr::address, debug(), WAPAddrTuple::local, octstr_get_cstr, WAPAddr::port, and WAPAddrTuple::remote.

138 {
139  debug("wap", 0, "WAPAddrTuple %p = <%s:%ld> - <%s:%ld>",
140  (void *) tuple,
141  octstr_get_cstr(tuple->remote->address),
142  tuple->remote->port,
143  octstr_get_cstr(tuple->local->address),
144  tuple->local->port);
145 }
Octstr * address
Definition: wap_addr.h:68
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
WAPAddr * local
Definition: wap_addr.h:74
long port
Definition: wap_addr.h:70
WAPAddr * remote
Definition: wap_addr.h:74
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:690
WAPAddrTuple* wap_addr_tuple_duplicate ( WAPAddrTuple tuple)

Definition at line 125 of file wap_addr.c.

References WAPAddr::address, WAPAddrTuple::local, WAPAddr::port, WAPAddrTuple::remote, and wap_addr_tuple_create().

Referenced by add_tid(), create_tr_abort_ind(), create_tr_invoke_cnf(), create_tr_invoke_ind(), create_tr_result_cnf(), find_session_machine(), indicate_push_connection(), indicate_push_resume(), indicate_resume(), init_machine_create(), make_session_request(), make_unit_push_request(), method_machine_create(), pack_error(), pack_into_push_datagram(), pack_into_result_datagram(), push_machine_create(), request_unit_push(), resp_machine_create(), return_unit_reply(), send_invoke(), session_machine_create(), unpack_abort(), unpack_ack(), unpack_datagram(), unpack_invoke(), unpack_negative_ack(), unpack_result(), unpack_segmented_invoke(), wtp_pack_abort(), wtp_pack_ack(), wtp_pack_invoke(), wtp_pack_result(), wtp_pack_sar_ack(), and wtp_pack_sar_result().

126 {
127  if (tuple == NULL)
128  return NULL;
129 
130  return wap_addr_tuple_create(tuple->remote->address,
131  tuple->remote->port,
132  tuple->local->address,
133  tuple->local->port);
134 }
Octstr * address
Definition: wap_addr.h:68
WAPAddr * local
Definition: wap_addr.h:74
long port
Definition: wap_addr.h:70
WAPAddr * remote
Definition: wap_addr.h:74
WAPAddrTuple * wap_addr_tuple_create(Octstr *rmt_addr, long rmt_port, Octstr *lcl_addr, long lcl_port)
Definition: wap_addr.c:96
int wap_addr_tuple_same ( WAPAddrTuple a,
WAPAddrTuple b 
)

Definition at line 118 of file wap_addr.c.

References WAPAddrTuple::local, WAPAddrTuple::remote, and wap_addr_same().

Referenced by is_wanted_init_machine(), is_wanted_resp_machine(), same_client(), tid_is_cached(), and transaction_belongs_to_session().

119 {
120  return wap_addr_same(a->remote, b->remote) &&
121  wap_addr_same(a->local, b->local);
122 }
WAPAddr * local
Definition: wap_addr.h:74
WAPAddr * remote
Definition: wap_addr.h:74
int wap_addr_same(WAPAddr *a, WAPAddr *b)
Definition: wap_addr.c:89
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.