Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

smasi_pdu.h File Reference

#include "gwlib/gwlib.h"
#include "smasi_pdu.def"

Include dependency graph for smasi_pdu.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Data Structures

struct  SMASI_PDU

Defines

#define SMASI_HYPHEN_ID   0x00000010
#define NONTERMINATED(name)
#define COMATERMINATED(name)
#define PDU(name, id, fields)   name = id,
#define NONTERMINATED(name)   Octstr *name;
#define COMATERMINATED(name)   Octstr *name;
#define PDU(name, id, fields)   struct name { fields } name;
#define GSM_ADDR_TON_UNKNOWN   0x00000000
#define GSM_ADDR_TON_INTERNATIONAL   0x00000001
#define GSM_ADDR_TON_NATIONAL   0x00000002
#define GSM_ADDR_TON_NETWORKSPECIFIC   0x00000003
#define GSM_ADDR_TON_SUBSCRIBER   0x00000004
#define GSM_ADDR_TON_ALPHANUMERIC   0x00000005
#define GSM_ADDR_TON_ABBREVIATED   0x00000006
#define GSM_ADDR_TON_EXTENSION   0x00000007
#define GSM_ADDR_NPI_UNKNOWN   0x00000000
#define GSM_ADDR_NPI_E164   0x00000001
#define GSM_ADDR_NPI_X121   0x00000003
#define GSM_ADDR_NPI_TELEX   0x00000004
#define GSM_ADDR_NPI_NATIONAL   0x00000008
#define GSM_ADDR_NPI_PRIVATE   0x00000009
#define GSM_ADDR_NPI_ERMES   0x0000000A
#define GSM_ADDR_NPI_EXTENSION   0x0000000F
#define ESM_CLASS_DEFAULT_SMSC_MODE   0x00000000
#define ESM_CLASS_DATAGRAM_MODE   0x00000001
#define ESM_CLASS_FORWARD_MODE   0x00000002
#define ESM_CLASS_STORE_AND_FORWARD_MODE   0x00000003
#define ESM_CLASS_DELIVERY_ACK   0x00000008
#define ESM_CLASS_USER_ACK   0x00000010
#define ESM_CLASS_UDH_INDICATOR   0x00000040
#define ESM_CLASS_RPI   0x00000080
#define ESM_CLASS_UDH_AND_RPI   0x000000C0

Typedefs

typedef SMASI_PDU SMASI_PDU

Enumerations

enum  {
  name, id, LogonReq, x00000001,
  LogonConf, x00000002, LogonRej, x00000003,
  LogoffReq, x00000004, LogoffConf, x00000005,
  SubmitReq, x00000010, SubmitConf, x00000011,
  SubmitRej, x00000012, DeliverReq, x00000013,
  DeliverConf, x00000014, DeliverRej, x00000015,
  Error, x80000016, EnquireLinkReq, x80000017,
  EnquireLinkConf, x80000018, SMASI_PDU_DUMMY_TYPE
}

Functions

SMASI_PDUsmasi_pdu_create (unsigned long type)
void smasi_pdu_destroy (SMASI_PDU *pdu)
int smasi_pdu_is_valid (SMASI_PDU *pdu)
Octstrsmasi_pdu_pack (SMASI_PDU *pdu)
SMASI_PDUsmasi_pdu_unpack (Octstr *data_without_len)
void smasi_pdu_dump (SMASI_PDU *pdu)
Octstrsmasi_pdu_read (Connection *conn)


Define Documentation

#define COMATERMINATED name   )     Octstr *name;
 

Definition at line 90 of file smasi_pdu.h.

#define COMATERMINATED name   ) 
 

Definition at line 90 of file smasi_pdu.h.

#define ESM_CLASS_DATAGRAM_MODE   0x00000001
 

Definition at line 124 of file smasi_pdu.h.

#define ESM_CLASS_DEFAULT_SMSC_MODE   0x00000000
 

Definition at line 123 of file smasi_pdu.h.

#define ESM_CLASS_DELIVERY_ACK   0x00000008
 

Definition at line 127 of file smasi_pdu.h.

#define ESM_CLASS_FORWARD_MODE   0x00000002
 

Definition at line 125 of file smasi_pdu.h.

#define ESM_CLASS_RPI   0x00000080
 

Definition at line 130 of file smasi_pdu.h.

#define ESM_CLASS_STORE_AND_FORWARD_MODE   0x00000003
 

Definition at line 126 of file smasi_pdu.h.

#define ESM_CLASS_UDH_AND_RPI   0x000000C0
 

Definition at line 131 of file smasi_pdu.h.

#define ESM_CLASS_UDH_INDICATOR   0x00000040
 

Definition at line 129 of file smasi_pdu.h.

#define ESM_CLASS_USER_ACK   0x00000010
 

Definition at line 128 of file smasi_pdu.h.

#define GSM_ADDR_NPI_E164   0x00000001
 

Definition at line 112 of file smasi_pdu.h.

Referenced by get_dest_addr_npi(), and get_source_addr_npi().

#define GSM_ADDR_NPI_ERMES   0x0000000A
 

Definition at line 117 of file smasi_pdu.h.

#define GSM_ADDR_NPI_EXTENSION   0x0000000F
 

Definition at line 118 of file smasi_pdu.h.

#define GSM_ADDR_NPI_NATIONAL   0x00000008
 

Definition at line 115 of file smasi_pdu.h.

#define GSM_ADDR_NPI_PRIVATE   0x00000009
 

Definition at line 116 of file smasi_pdu.h.

#define GSM_ADDR_NPI_TELEX   0x00000004
 

Definition at line 114 of file smasi_pdu.h.

#define GSM_ADDR_NPI_UNKNOWN   0x00000000
 

Definition at line 111 of file smasi_pdu.h.

#define GSM_ADDR_NPI_X121   0x00000003
 

Definition at line 113 of file smasi_pdu.h.

#define GSM_ADDR_TON_ABBREVIATED   0x00000006
 

Definition at line 108 of file smasi_pdu.h.

#define GSM_ADDR_TON_ALPHANUMERIC   0x00000005
 

Definition at line 107 of file smasi_pdu.h.

Referenced by convert_addr_from_pdu(), and get_originator_type().

#define GSM_ADDR_TON_EXTENSION   0x00000007
 

Definition at line 109 of file smasi_pdu.h.

#define GSM_ADDR_TON_INTERNATIONAL   0x00000001
 

Definition at line 103 of file smasi_pdu.h.

Referenced by convert_addr_from_pdu(), get_dest_addr_ton(), get_originator_type(), and get_source_addr_ton().

#define GSM_ADDR_TON_NATIONAL   0x00000002
 

Definition at line 104 of file smasi_pdu.h.

#define GSM_ADDR_TON_NETWORKSPECIFIC   0x00000003
 

Definition at line 105 of file smasi_pdu.h.

#define GSM_ADDR_TON_SUBSCRIBER   0x00000004
 

Definition at line 106 of file smasi_pdu.h.

#define GSM_ADDR_TON_UNKNOWN   0x00000000
 

Definition at line 102 of file smasi_pdu.h.

#define NONTERMINATED name   )     Octstr *name;
 

Definition at line 89 of file smasi_pdu.h.

#define NONTERMINATED name   ) 
 

Definition at line 89 of file smasi_pdu.h.

#define PDU name,
id,
fields   )     struct name { fields } name;
 

Definition at line 91 of file smasi_pdu.h.

#define PDU name,
id,
fields   )     name = id,
 

Definition at line 91 of file smasi_pdu.h.

#define SMASI_HYPHEN_ID   0x00000010
 

Definition at line 73 of file smasi_pdu.h.


Typedef Documentation

typedef struct SMASI_PDU SMASI_PDU
 

Definition at line 83 of file smasi_pdu.h.


Enumeration Type Documentation

anonymous enum
 

Enumeration values:
name 
id 
LogonReq 
x00000001 
LogonConf 
x00000002 
LogonRej 
x00000003 
LogoffReq 
x00000004 
LogoffConf 
x00000005 
SubmitReq 
x00000010 
SubmitConf 
x00000011 
SubmitRej 
x00000012 
DeliverReq 
x00000013 
DeliverConf 
x00000014 
DeliverRej 
x00000015 
Error 
x80000016 
EnquireLinkReq 
x80000017 
EnquireLinkConf 
x80000018 
SMASI_PDU_DUMMY_TYPE 

Definition at line 75 of file smasi_pdu.h.

00075      {
00076     #define NONTERMINATED(name)
00077     #define COMATERMINATED(name)
00078     #define PDU(name, id, fields) name = id,
00079     #include "smasi_pdu.def"
00080     SMASI_PDU_DUMMY_TYPE
00081 };


Function Documentation

SMASI_PDU* smasi_pdu_create unsigned long  type  ) 
 

Definition at line 132 of file smasi_pdu.c.

References pdu, SMASI_PDU::type, and warning().

Referenced by handle_pdu(), msg_to_pdu(), open_connection(), send_enquire_link(), send_logoff(), and smasi_pdu_unpack().

00133 {
00134     SMASI_PDU *pdu;
00135 
00136     pdu = gw_malloc(sizeof(*pdu));
00137     pdu->type = type;
00138 
00139     switch (type) {
00140     #define NONTERMINATED(name) p->name = NULL;
00141     #define COMATERMINATED(name) p->name = NULL;
00142     #define PDU(name, id, fields) \
00143         case id: { \
00144         struct name *p = &pdu->u.name; \
00145         pdu->type_name = #name; \
00146         pdu->needs_hyphen = (id < SMASI_HYPHEN_ID ? 1 : 0); \
00147         fields \
00148     } break;
00149     #include "smasi_pdu.def"
00150     default:
00151         warning(0, "Unknown SMASI_PDU type, internal error.");
00152         gw_free(pdu);
00153     return NULL;
00154     }
00155 
00156     return pdu;
00157 }

Here is the call graph for this function:

void smasi_pdu_destroy SMASI_PDU pdu  ) 
 

Definition at line 160 of file smasi_pdu.c.

References error(), pdu, and SMASI_PDU::type.

Referenced by handle_pdu(), open_connection(), send_enquire_link(), send_logoff(), send_messages(), and smasi_thread().

00161 {
00162     if (pdu == NULL)
00163         return;
00164 
00165     switch (pdu->type) {
00166     #define NONTERMINATED(name) octstr_destroy(p->name);
00167     #define COMATERMINATED(name) octstr_destroy(p->name);
00168     #define PDU(name, id, fields) \
00169         case id: { struct name *p = &pdu->u.name; fields } break;
00170     #include "smasi_pdu.def"
00171     default:
00172         error(0, "Unknown SMASI_PDU type, internal error while destroying.");
00173     }
00174     gw_free(pdu);
00175 }

Here is the call graph for this function:

void smasi_pdu_dump SMASI_PDU pdu  ) 
 

Definition at line 280 of file smasi_pdu.c.

References debug(), pdu, and warning().

Referenced by dump_pdu().

00281 {
00282     debug("sms.smasi", 0, "SMASI PDU %p dump:", (void *) pdu);
00283     debug("sms.smasi", 0, "  type_name: %s", pdu->type_name);
00284     switch (pdu->type) {
00285     #define NONTERMINATED(name) p = *(&p);
00286     #define COMATERMINATED(name) \
00287     octstr_dump_short(p->name, 2, #name);
00288     #define PDU(name, id, fields) \
00289         case id: { struct name *p = &pdu->u.name; fields } break;
00290     #include "smasi_pdu.def"
00291     default:
00292         warning(0, "Unknown SMASI_PDU type, internal error.");
00293     break;
00294     }
00295     debug("sms.smasi", 0, "SMASI PDU dump ends.");
00296 }

Here is the call graph for this function:

int smasi_pdu_is_valid SMASI_PDU pdu  ) 
 

Octstr* smasi_pdu_pack SMASI_PDU pdu  ) 
 

Definition at line 178 of file smasi_pdu.c.

References error(), SMASI_PDU::needs_hyphen, octstr_append_char(), octstr_append_cstr(), octstr_create, octstr_destroy(), octstr_insert(), pdu, SMASI_PDU::type, and SMASI_PDU::type_name.

Referenced by send_enquire_link(), send_logoff(), and send_pdu().

00179 {
00180     Octstr *os;
00181     Octstr *temp;
00182 
00183     os = octstr_create("");
00184 
00185     /*
00186      * Fix lengths of octet string fields.
00187      */
00188     switch (pdu->type) {
00189     #define NONTERMINATED(name) p = *(&p);
00190     #define COMATERMINATED(name) p = *(&p);
00191     #define PDU(name, id, fields) \
00192         case id: { struct name *p = &pdu->u.name; fields } break;
00193     #include "smasi_pdu.def"
00194     default:
00195         error(0, "Unknown SMASI_PDU type, internal error while packing.");
00196     }
00197 
00198     switch (pdu->type) {
00199     #define NONTERMINATED(name) p = *(&p);
00200     #define COMATERMINATED(name) \
00201     if (p->name != NULL) { octstr_append_cstr(os, #name); \
00202     octstr_append_char(os, '='); \
00203     octstr_append(os, p->name); \
00204     octstr_append_char(os, ','); }
00205     #define PDU(name, id, fields) \
00206         case id: { struct name *p = &pdu->u.name; fields } break;
00207     #include "smasi_pdu.def"
00208     default:
00209         error(0, "Unknown SMASI_PDU type, internal error while packing.");
00210     }
00211 
00212     octstr_append_char(os, '\n');
00213     temp = pdu->needs_hyphen ? octstr_create("!") : octstr_create("");
00214     octstr_append_cstr(temp, pdu->type_name); 
00215     octstr_append_char(temp, ':');
00216     octstr_insert(os, temp, 0);
00217     octstr_destroy(temp);
00218 
00219     return os;
00220 }

Here is the call graph for this function:

Octstr* smasi_pdu_read Connection conn  ) 
 

Definition at line 299 of file smasi_pdu.c.

References conn_read_line().

Referenced by read_pdu().

00300 {
00301     Octstr *line;
00302 
00303     line = conn_read_line(conn);    /* read one line */
00304     return line;
00305 }

Here is the call graph for this function:

SMASI_PDU* smasi_pdu_unpack Octstr data_without_len  ) 
 

Definition at line 223 of file smasi_pdu.c.

References decode_type(), octstr_destroy(), octstr_get_cstr, pdu, skip_until_after_colon(), smasi_pdu_create(), type, and warning().

Referenced by read_pdu().

00224 {
00225     SMASI_PDU *pdu;
00226     char *type_name;
00227     Octstr *temp;
00228     long pos;
00229     unsigned long type = 0;
00230 
00231     /* extract the PDU type identifier */
00232     temp = decode_type(data_without_len);
00233     type_name = (temp ? octstr_get_cstr(temp) : "");
00234 
00235     if (strcmp(type_name, "dummy") == 0) type = 0;
00236     #define NONTERMINATED(name) p = *(&p);
00237     #define COMATERMINATED(name) p = *(&p);
00238     #define PDU(name, id, fields) \
00239     else if (strcmp(type_name, #name) == 0) type = id;
00240     #include "smasi_pdu.def"
00241     else warning(0, "unknown SMASI PDU type");
00242 
00243     pdu = smasi_pdu_create(type);
00244     if (pdu == NULL) return NULL;
00245 
00246     pos = 0;
00247     skip_until_after_colon(data_without_len, &pos);
00248 
00249     switch (type) {
00250     #define NONTERMINATED(name) p = *(&p);
00251     #define COMATERMINATED(name) \
00252                 if (octstr_str_compare(field_name, #name) == 0 && field_value != NULL) \
00253                     p->name = octstr_duplicate(field_value);
00254     #define PDU(name, id, fields) \
00255         case id: { \
00256             Octstr * field_name = NULL; \
00257             Octstr * field_value = NULL; \
00258             struct name *p = &pdu->u.name; \
00259             while (pos < octstr_len(data_without_len)) { \
00260                 field_name = copy_until_assign(data_without_len, &pos); \
00261                 if (field_name == NULL) break; \
00262                 field_value = copy_until_coma(data_without_len, &pos); \
00263                 if (field_value == NULL) continue; \
00264                 fields \
00265                 octstr_destroy(field_name); \
00266                 octstr_destroy(field_value); \
00267             } \
00268         } break;
00269     #include "smasi_pdu.def"
00270     default:
00271         warning(0, "Unknown SMASI_PDU type, internal error while unpacking.");
00272     }
00273 
00274     octstr_destroy(temp);
00275 
00276     return pdu;
00277 }

Here is the call graph for this function:

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