Kannel: Open Source WAP and SMS gateway  svn-r5335
wsp.c File Reference
#include <string.h>
#include "gwlib/gwlib.h"
#include "wsp.h"
#include "wsp_pdu.h"
#include "wsp_headers.h"
#include "wsp_strings.h"

Go to the source code of this file.

Functions

long wsp_convert_http_status_to_wsp_status (long http_status)
 

Function Documentation

◆ wsp_convert_http_status_to_wsp_status()

long wsp_convert_http_status_to_wsp_status ( long  http_status)

Definition at line 77 of file wsp.c.

References error().

Referenced by make_resume_reply_pdu(), and pack_into_result_datagram().

77  {
78  long hundreds, singles;
79 
80  /*
81  * The table is regular, and can be expected to stay regular in
82  * future versions of WSP. The status value is read as XYY,
83  * so that X is the first digit and Y is the value of the
84  * second two digits. This is encoded as a hex value 0xAB,
85  * where A == X and B == YY.
86  * This limits YY to the range 0-15, so an exception is made
87  * to allow larger YY values when X is 4. X value 5 is moved up
88  * to A value 6 to allow more room for YY when X is 4.
89  */
90 
91  hundreds = http_status / 100;
92  singles = http_status % 100;
93 
94  if ((hundreds == 4 && singles > 31) ||
95  (hundreds != 4 && singles > 15) ||
96  hundreds < 1 || hundreds > 5)
97  goto bad_status;
98 
99  if (hundreds > 4)
100  hundreds++;
101 
102  return hundreds * 16 + singles;
103 
104 bad_status:
105  error(0, "WSP: Unknown status code used internally. Oops.");
106  return 0x60; /* Status 500, or "Internal Server Error" */
107 }
void error(int err, const char *fmt,...)
Definition: log.c:648
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.