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

wsp_caps.h File Reference

#include "gwlib/gwlib.h"

Include dependency graph for wsp_caps.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  capability

Typedefs

typedef capability Capability

Enumerations

enum  known_caps {
  WSP_CAPS_CLIENT_SDU_SIZE = 0, WSP_CAPS_SERVER_SDU_SIZE = 1, WSP_CAPS_PROTOCOL_OPTIONS = 2, WSP_CAPS_METHOD_MOR = 3,
  WSP_CAPS_PUSH_MOR = 4, WSP_CAPS_EXTENDED_METHODS = 5, WSP_CAPS_HEADER_CODE_PAGES = 6, WSP_CAPS_ALIASES = 7,
  WSP_NUM_CAPS
}

Functions

Capabilitywsp_cap_create (int id, Octstr *name, Octstr *data)
void wsp_cap_destroy (Capability *cap)
void wsp_cap_dump (Capability *cap)
void wsp_cap_dump_list (List *caps_list)
void wsp_cap_destroy_list (List *caps_list)
Listwsp_cap_duplicate_list (List *cap)
Capabilitywsp_cap_duplicate (Capability *cap)
Listwsp_cap_unpack_list (Octstr *caps)
Octstrwsp_cap_pack_list (List *caps_list)
int wsp_cap_count (List *caps_list, int id, Octstr *name)
int wsp_cap_get_client_sdu (List *caps_list, unsigned long *sdu)
int wsp_cap_get_server_sdu (List *caps_list, unsigned long *sdu)
int wsp_cap_get_method_mor (List *caps_list, unsigned long *mor)
int wsp_cap_get_push_mor (List *caps_list, unsigned long *mor)


Typedef Documentation

typedef struct capability Capability
 

Definition at line 83 of file wsp_caps.h.

Referenced by is_default_cap(), refuse_unreplied_capabilities(), reply_known_capabilities(), sanitize_capabilities(), strip_default_capabilities(), wsp_cap_create(), wsp_cap_destroy(), wsp_cap_dump(), wsp_cap_duplicate(), wsp_cap_duplicate_list(), wsp_cap_get_data(), and wsp_cap_pack_list().


Enumeration Type Documentation

enum known_caps
 

Enumeration values:
WSP_CAPS_CLIENT_SDU_SIZE 
WSP_CAPS_SERVER_SDU_SIZE 
WSP_CAPS_PROTOCOL_OPTIONS 
WSP_CAPS_METHOD_MOR 
WSP_CAPS_PUSH_MOR 
WSP_CAPS_EXTENDED_METHODS 
WSP_CAPS_HEADER_CODE_PAGES 
WSP_CAPS_ALIASES 
WSP_NUM_CAPS 

Definition at line 86 of file wsp_caps.h.


Function Documentation

int wsp_cap_count List caps_list,
int  id,
Octstr name
 

Definition at line 282 of file wsp_caps.c.

References data, name, and wsp_cap_get_data().

Referenced by refuse_unreplied_capabilities(), reply_known_capabilities(), and strip_default_capabilities().

00282                                                          {
00283     Octstr *data;
00284 
00285     return wsp_cap_get_data(caps_list, id, name, &data);
00286 }

Here is the call graph for this function:

Capability* wsp_cap_create int  id,
Octstr name,
Octstr data
 

Definition at line 71 of file wsp_caps.c.

References Capability, Octstr::data, capability::id, and capability::name.

Referenced by refuse_unreplied_capabilities(), reply_known_capabilities(), wsp_cap_duplicate(), and wsp_cap_unpack_list().

00071                                                                {
00072     Capability *new_cap;
00073 
00074     new_cap = gw_malloc(sizeof(*new_cap));
00075     new_cap->id = id;
00076     new_cap->name = name;
00077     new_cap->data = data;
00078     new_cap->accept = 0;
00079 
00080     return new_cap;
00081 }

void wsp_cap_destroy Capability cap  ) 
 

Definition at line 83 of file wsp_caps.c.

References Capability, capability::data, capability::name, and octstr_destroy().

Referenced by sanitize_capabilities(), strip_default_capabilities(), and wsp_cap_destroy_item().

00083                                       {
00084     if (cap == NULL)
00085         return;
00086 
00087     octstr_destroy(cap->name);
00088     octstr_destroy(cap->data);
00089     gw_free(cap);
00090 }

Here is the call graph for this function:

void wsp_cap_destroy_list List caps_list  ) 
 

Definition at line 121 of file wsp_caps.c.

References gwlist_destroy(), and wsp_cap_destroy_item().

Referenced by make_connectreply_pdu().

00121                                            {
00122     gwlist_destroy(caps_list, wsp_cap_destroy_item);
00123 }

Here is the call graph for this function:

void wsp_cap_dump Capability cap  ) 
 

Definition at line 92 of file wsp_caps.c.

References capability::accept, Capability, capability::data, debug(), capability::id, capability::name, and octstr_dump.

Referenced by sanitize_capabilities(), wsp_cap_dump_list(), and wsp_cap_pack_list().

00092                                    {
00093     debug("wsp", 0, "Dumping capability at %p:", cap);
00094     if (cap) {
00095         debug("wsp", 0, " id = %d", cap->id);
00096         debug("wsp", 0, " name:");
00097         octstr_dump(cap->name, 1);
00098         debug("wsp", 0, " data:");
00099         octstr_dump(cap->data, 1);
00100         if (cap->data == NULL)
00101             debug("wsp", 0, " accept: %d", cap->accept);
00102     }
00103     debug("wsp", 0, "Capability dump ends.");
00104 }

Here is the call graph for this function:

void wsp_cap_dump_list List caps_list  ) 
 

Definition at line 106 of file wsp_caps.c.

References debug(), gwlist_get(), gwlist_len(), and wsp_cap_dump().

00106                                         {
00107     long i;
00108 
00109     if (caps_list == NULL) {
00110         debug("wsp", 0, "NULL capability list");
00111         return;
00112     }
00113     debug("wsp", 0, "Dumping capability list at %p, length %ld",
00114         caps_list, gwlist_len(caps_list));
00115     for (i = 0; i < gwlist_len(caps_list); i++) {
00116         wsp_cap_dump(gwlist_get(caps_list, i));
00117     }
00118     debug("wsp", 0, "End of capability list dump");
00119 }

Here is the call graph for this function:

Capability* wsp_cap_duplicate Capability cap  ) 
 

Definition at line 142 of file wsp_caps.c.

References capability::accept, Capability, capability::data, capability::id, capability::name, octstr_duplicate, and wsp_cap_create().

Referenced by wsp_cap_duplicate_list().

00142                                                {
00143     Capability *new_cap;
00144 
00145     if (!cap)
00146         return NULL;
00147 
00148     new_cap = wsp_cap_create(cap->id,
00149                 octstr_duplicate(cap->name),
00150                 octstr_duplicate(cap->data));
00151     new_cap->accept = cap->accept;
00152     return new_cap;
00153 }

Here is the call graph for this function:

List* wsp_cap_duplicate_list List cap  ) 
 

Definition at line 125 of file wsp_caps.c.

References Capability, gwlist_append(), gwlist_create, gwlist_get(), gwlist_len(), and wsp_cap_duplicate().

Referenced by indicate_push_connection(), make_capabilities_reply(), response_push_connection(), session_machine_create(), and update_session_data().

00125                                               {
00126     Capability *cap;
00127     List *new_list;
00128     long i;
00129 
00130     new_list = gwlist_create();
00131 
00132     if (caps_list == NULL)
00133         return new_list;
00134 
00135     for (i = 0; i < gwlist_len(caps_list); i++) {
00136         cap = gwlist_get(caps_list, i);
00137         gwlist_append(new_list, wsp_cap_duplicate(cap));
00138     }
00139     return new_list;
00140 };

Here is the call graph for this function:

int wsp_cap_get_client_sdu List caps_list,
unsigned long *  sdu
 

Definition at line 288 of file wsp_caps.c.

References data, octstr_extract_uintvar(), wsp_cap_get_data(), and WSP_CAPS_CLIENT_SDU_SIZE.

Referenced by reply_known_capabilities().

00288                                                                 {
00289     Octstr *data;
00290     int found;
00291 
00292     found = wsp_cap_get_data(caps_list, WSP_CAPS_CLIENT_SDU_SIZE,
00293                     NULL, &data);
00294     if (found > 0 && octstr_extract_uintvar(data, sdu, 0) < 0)
00295         return -1;
00296 
00297     return found;
00298 }

Here is the call graph for this function:

int wsp_cap_get_method_mor List caps_list,
unsigned long *  mor
 

Definition at line 312 of file wsp_caps.c.

References data, octstr_get_char(), wsp_cap_get_data(), and WSP_CAPS_METHOD_MOR.

Referenced by reply_known_capabilities().

00312                                                                 {
00313     Octstr *data;
00314     int found;
00315     int c;
00316 
00317     found = wsp_cap_get_data(caps_list, WSP_CAPS_METHOD_MOR, NULL, &data);
00318     if (found > 0) {
00319         c = octstr_get_char(data, 0);
00320         if (c < 0)
00321             return -1;
00322         *mor = c;
00323     }
00324     
00325     return found;
00326 }

Here is the call graph for this function:

int wsp_cap_get_push_mor List caps_list,
unsigned long *  mor
 

Definition at line 328 of file wsp_caps.c.

References data, octstr_get_char(), wsp_cap_get_data(), and WSP_CAPS_PUSH_MOR.

Referenced by reply_known_capabilities().

00328                                                               {
00329     Octstr *data;
00330     int found;
00331     int c;
00332 
00333     found = wsp_cap_get_data(caps_list, WSP_CAPS_PUSH_MOR, NULL, &data);
00334     if (found > 0) {
00335         c = octstr_get_char(data, 0);
00336         if (c < 0)
00337             return -1;
00338         *mor = c;
00339     }
00340     
00341     return found;
00342 }

Here is the call graph for this function:

int wsp_cap_get_server_sdu List caps_list,
unsigned long *  sdu
 

Definition at line 300 of file wsp_caps.c.

References data, octstr_extract_uintvar(), wsp_cap_get_data(), and WSP_CAPS_SERVER_SDU_SIZE.

Referenced by reply_known_capabilities().

00300                                                                 {
00301     Octstr *data;
00302     int found;
00303 
00304     found = wsp_cap_get_data(caps_list, WSP_CAPS_SERVER_SDU_SIZE,
00305                     NULL, &data);
00306     if (found > 0 && octstr_extract_uintvar(data, sdu, 0) < 0)
00307         return -1;
00308 
00309     return found;
00310 }

Here is the call graph for this function:

Octstr* wsp_cap_pack_list List caps_list  ) 
 

Definition at line 207 of file wsp_caps.c.

References capability::accept, Capability, capability::data, error(), gwlist_get(), gwlist_len(), capability::id, capability::name, octstr_append(), octstr_append_char(), octstr_append_uintvar(), octstr_create, octstr_get_char(), octstr_len(), octstr_search_char(), result, and wsp_cap_dump().

Referenced by make_connectreply_pdu().

00207                                            {
00208     Octstr *result;
00209     Capability *cap;
00210     long i, len;
00211 
00212     result = octstr_create("");
00213     len = gwlist_len(caps_list);
00214     for (i = 0; i < len; i++) {
00215         long datalen;
00216 
00217         cap = gwlist_get(caps_list, i);
00218 
00219         datalen = 0;
00220         if (cap->data)
00221             datalen = octstr_len(cap->data);
00222 
00223         if (datalen == 0 && cap->accept)
00224             continue;
00225 
00226         if (cap->name) {
00227             if (octstr_get_char(cap->name, 0) >= 0x80 ||
00228                 octstr_search_char(cap->name, 0, 0) >= 0) {
00229                 error(0, "WSP: Bad capability.");
00230                 wsp_cap_dump(cap);
00231                 continue;
00232             }
00233             /* Add length */
00234             octstr_append_uintvar(result,
00235                 octstr_len(cap->name) + 1 + datalen);
00236             /* Add identifier */
00237             octstr_append(result, cap->name);
00238             octstr_append_char(result, 0);
00239         } else {
00240             if (cap->id >= 0x80 || cap->id < 0) {
00241                 error(0, "WSP: Bad capability.");
00242                 wsp_cap_dump(cap);
00243                 continue;
00244             }
00245             /* Add length */
00246             octstr_append_uintvar(result, 1 + datalen);
00247             /* Add identifier */
00248             octstr_append_char(result, 0x80 | cap->id);
00249         }
00250         /* Add payload, if any */
00251         if (cap->data) {
00252             octstr_append(result, cap->data);
00253         }
00254     }
00255 
00256     return result;
00257 }

Here is the call graph for this function:

List* wsp_cap_unpack_list Octstr caps  ) 
 

Definition at line 155 of file wsp_caps.c.

References data, error(), gwlist_append(), gwlist_create, name, octstr_copy, octstr_extract_uintvar(), octstr_get_char(), octstr_len(), octstr_search_char(), warning(), and wsp_cap_create().

00155                                         {
00156     List *caps_list;
00157     long pos, capslen;
00158 
00159     caps_list = gwlist_create();
00160     if (caps == NULL)
00161         return caps_list;
00162 
00163     capslen = octstr_len(caps);
00164     pos = 0;
00165     while (pos < capslen) {
00166         unsigned long length;
00167         int id;
00168         Octstr *name;
00169         Octstr *data;
00170 
00171         pos = octstr_extract_uintvar(caps, &length, pos);
00172         if (pos < 0 || length == 0)
00173             goto error;
00174 
00175         id = octstr_get_char(caps, pos);
00176         if (id >= 0x80) {
00177             id &= 0x7f; /* It's encoded as a short-integer */
00178             name = NULL;
00179             data = octstr_copy(caps, pos + 1, length - 1);
00180         } else {
00181             long nullpos;
00182             id = -1;  /* It's encoded as token-text */
00183             nullpos = octstr_search_char(caps, 0, pos);
00184             if (nullpos < 0)
00185                             goto error;
00186                         /* check length
00187                          * FIXME: If it's not allowed that data is empty then change check
00188                          *        to <= .
00189                          */
00190                         if (length < (nullpos + 1 - pos))
00191                             goto error;
00192             name = octstr_copy(caps, pos, nullpos - pos);
00193             data = octstr_copy(caps, nullpos + 1,
00194                 length - (nullpos + 1 - pos));
00195         }
00196         gwlist_append(caps_list, wsp_cap_create(id, name, data));
00197         pos += length;
00198     }
00199 
00200     return caps_list;
00201 
00202 error:
00203     warning(0, "WSP: Error unpacking capabilities");
00204     return caps_list;
00205 }

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.