Browse code

modules_s/osp: moved to obsolete folder

Daniel-Constantin Mierla authored on 07/12/2012 22:14:53
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,203 +0,0 @@
1
-/*
2
- * ser osp module. 
3
- *
4
- * This module enables ser to communicate with an Open Settlement 
5
- * Protocol (OSP) server.  The Open Settlement Protocol is an ETSI 
6
- * defined standard for Inter-Domain VoIP pricing, authorization
7
- * and usage exchange.  The technical specifications for OSP 
8
- * (ETSI TS 101 321 V4.1.1) are available at www.etsi.org.
9
- *
10
- * Uli Abend was the original contributor to this module.
11
- * 
12
- * Copyright (C) 2001-2005 Fhg Fokus
13
- *
14
- * This file is part of ser, a free SIP server.
15
- *
16
- * ser is free software; you can redistribute it and/or modify
17
- * it under the terms of the GNU General Public License as published by
18
- * the Free Software Foundation; either version 2 of the License, or
19
- * (at your option) any later version
20
- *
21
- * For a license to use the ser software under conditions
22
- * other than those described here, or to purchase support for this
23
- * software, please contact iptel.org by e-mail at the following addresses:
24
- *    info@iptel.org
25
- *
26
- * ser is distributed in the hope that it will be useful,
27
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
28
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29
- * GNU General Public License for more details.
30
- *
31
- * You should have received a copy of the GNU General Public License
32
- * along with this program; if not, write to the Free Software
33
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
34
- */
35
-
36
-#include "osp_mod.h"
37
-#include "term_transaction.h"
38
-#include "sipheader.h"
39
-#include "destination.h"
40
-#include "osptoolkit.h"
41
-#include "usage.h"
42
-
43
-extern char* _osp_device_ip;
44
-extern int _osp_token_format;
45
-extern int _osp_validate_callid;
46
-extern OSPTPROVHANDLE _osp_provider;
47
-
48
-/*
49
- * Get OSP token
50
- * param msg SIP message
51
- * param ignore1
52
- * param ignore2
53
- * return  MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure
54
- */
55
-int ospCheckHeader(
56
-    struct sip_msg* msg, 
57
-    char* ignore1, 
58
-    char* ignore2)
59
-{
60
-    unsigned char buffer[OSP_TOKENBUF_SIZE];
61
-    unsigned int  buffersize = sizeof(buffer);
62
-
63
-    LOG(L_DBG, "osp: ospCheckHeader\n");
64
-
65
-    if (ospGetOspHeader(msg, buffer, &buffersize) != 0) {
66
-        return MODULE_RETURNCODE_FALSE;
67
-    } else {
68
-        return MODULE_RETURNCODE_TRUE;
69
-    }
70
-}
71
-
72
-/*
73
- * Validate OSP token
74
- * param ignore1
75
- * param ignore2
76
- * return  MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure
77
- */
78
-int ospValidateHeader (
79
-    struct sip_msg* msg, 
80
-    char* ignore1, 
81
-    char* ignore2)
82
-{
83
-    int errorcode; 
84
-    OSPTTRANHANDLE transaction = -1;
85
-    unsigned int authorized = 0;
86
-    unsigned int timelimit = 0;
87
-    void* detaillog = NULL;
88
-    unsigned int logsize = 0;
89
-    unsigned char* callidval = (unsigned char*)"";
90
-    OSPTCALLID* callid = NULL;
91
-    unsigned callidsize = 0;
92
-    unsigned char token[OSP_TOKENBUF_SIZE];
93
-    unsigned int tokensize = sizeof(token);
94
-    osp_dest dest;
95
-    int result = MODULE_RETURNCODE_FALSE;
96
-
97
-    LOG(L_DBG, "osp: ospValidateHeader\n");
98
-
99
-    ospInitDestination(&dest);
100
-
101
-    if ((errorcode = OSPPTransactionNew(_osp_provider, &transaction) != OSPC_ERR_NO_ERROR)) {
102
-        LOG(L_ERR, "osp: ERROR: failed to create a new OSP transaction handle (%d)\n", errorcode);
103
-    } else if ((ospGetRpidUserpart(msg, dest.calling, sizeof(dest.calling)) != 0) && 
104
-        (ospGetFromUserpart(msg, dest.calling, sizeof(dest.calling)) != 0))
105
-    {
106
-        LOG(L_ERR, "osp: ERROR: failed to extract calling number\n");
107
-    } else if ((ospGetUriUserpart(msg, dest.called, sizeof(dest.called)) != 0) &&
108
-        (ospGetToUserpart(msg, dest.called, sizeof(dest.called)) != 0))
109
-    {
110
-        LOG(L_ERR, "osp: ERROR: failed to extract called number\n");
111
-    } else if (ospGetCallId(msg, &callid) != 0) {
112
-        LOG(L_ERR, "osp: ERROR: failed to extract call id\n");
113
-    } else if (ospGetSourceAddress(msg, dest.source, sizeof(dest.source)) != 0) {
114
-        LOG(L_ERR, "osp: ERROR: failed to extract source address\n");
115
-    } else if (ospGetOspHeader(msg, token, &tokensize) != 0) {
116
-        LOG(L_ERR, "osp: ERROR: failed to extract OSP authorization token\n");
117
-    } else {
118
-        LOG(L_INFO, 
119
-            "osp: validate token for: "
120
-            "transaction_handle '%i' "
121
-            "e164_source '%s' "
122
-            "e164_dest '%s' "
123
-            "validate_call_id '%s' "
124
-            "call_id '%.*s'\n",
125
-            transaction,
126
-            dest.calling,
127
-            dest.called,
128
-            _osp_validate_callid == 0 ? "No" : "Yes",
129
-            callid->ospmCallIdLen,
130
-            callid->ospmCallIdVal);
131
-
132
-        if (_osp_validate_callid != 0) {
133
-            callidsize = callid->ospmCallIdLen;
134
-            callidval = callid->ospmCallIdVal;
135
-        }
136
-
137
-        errorcode = OSPPTransactionValidateAuthorisation(
138
-            transaction,
139
-            "",
140
-            "",
141
-            "",
142
-            "",
143
-            dest.calling,
144
-            OSPC_E164,
145
-            dest.called,
146
-            OSPC_E164,
147
-            callidsize,
148
-            callidval,
149
-            tokensize,
150
-            token,
151
-            &authorized,
152
-            &timelimit,
153
-            &logsize,
154
-            detaillog,
155
-            _osp_token_format);
156
-    
157
-        if (callid->ospmCallIdLen > sizeof(dest.callid) - 1) {
158
-            dest.callidsize = sizeof(dest.callid) - 1;
159
-        } else {
160
-            dest.callidsize = callid->ospmCallIdLen;
161
-        }
162
-        memcpy(dest.callid, callid->ospmCallIdVal, dest.callidsize);
163
-        dest.callid[dest.callidsize] = 0;
164
-        dest.transid = ospGetTransactionId(transaction);
165
-        dest.type = OSPC_DESTINATION;
166
-        dest.authtime = time(NULL);
167
-        strncpy(dest.host, _osp_device_ip, sizeof(dest.host) - 1);
168
-
169
-        ospSaveTermDestination(&dest);
170
-
171
-        if ((errorcode == OSPC_ERR_NO_ERROR) && (authorized == 1)) {
172
-            LOG(L_DBG, 
173
-                "osp: call is authorized for %d seconds, call_id '%.*s' transaction_id '%llu'",
174
-                timelimit,
175
-                dest.callidsize,
176
-                dest.callid,
177
-                dest.transid);
178
-            ospRecordTermTransaction(msg, dest.transid, dest.source, dest.calling, dest.called, dest.authtime);
179
-            result = MODULE_RETURNCODE_TRUE;
180
-        } else {
181
-            LOG(L_ERR, "osp: ERROR: token is invalid (%i)\n", errorcode);
182
-
183
-            /* 
184
-             * Update terminating status code to 401 and report terminating setup usage.
185
-             * We may need to make 401 configurable, just in case a user decides to reply with
186
-             * a different code.  Other options - trigger call setup usage reporting from the cpl
187
-             * (after replying with an error code), or maybe use a different tm callback.
188
-             */
189
-            ospRecordEvent(0, 401);
190
-        }
191
-    }
192
-
193
-    if (transaction != -1) {
194
-        OSPPTransactionDelete(transaction);
195
-    }
196
-
197
-    if (callid != NULL) {
198
-        OSPPCallIdDelete(&callid);
199
-    }
200
-    
201
-    return result;
202
-}
203
-
Browse code

Revert "according to Di-Shi are K's and ser's osp module more or less the same, whereas Kamailio's osp module should be more up2date than ser's module. Thus, ser's osp module will be removed and K's osp module will be used as common OSP module."

This reverts commit 6bdbd8e2ab1ec15695cc156ff74f20af799a947b.

Klaus Darilion authored on 03/07/2009 12:40:57
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,203 @@
1
+/*
2
+ * ser osp module. 
3
+ *
4
+ * This module enables ser to communicate with an Open Settlement 
5
+ * Protocol (OSP) server.  The Open Settlement Protocol is an ETSI 
6
+ * defined standard for Inter-Domain VoIP pricing, authorization
7
+ * and usage exchange.  The technical specifications for OSP 
8
+ * (ETSI TS 101 321 V4.1.1) are available at www.etsi.org.
9
+ *
10
+ * Uli Abend was the original contributor to this module.
11
+ * 
12
+ * Copyright (C) 2001-2005 Fhg Fokus
13
+ *
14
+ * This file is part of ser, a free SIP server.
15
+ *
16
+ * ser is free software; you can redistribute it and/or modify
17
+ * it under the terms of the GNU General Public License as published by
18
+ * the Free Software Foundation; either version 2 of the License, or
19
+ * (at your option) any later version
20
+ *
21
+ * For a license to use the ser software under conditions
22
+ * other than those described here, or to purchase support for this
23
+ * software, please contact iptel.org by e-mail at the following addresses:
24
+ *    info@iptel.org
25
+ *
26
+ * ser is distributed in the hope that it will be useful,
27
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
28
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29
+ * GNU General Public License for more details.
30
+ *
31
+ * You should have received a copy of the GNU General Public License
32
+ * along with this program; if not, write to the Free Software
33
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
34
+ */
35
+
36
+#include "osp_mod.h"
37
+#include "term_transaction.h"
38
+#include "sipheader.h"
39
+#include "destination.h"
40
+#include "osptoolkit.h"
41
+#include "usage.h"
42
+
43
+extern char* _osp_device_ip;
44
+extern int _osp_token_format;
45
+extern int _osp_validate_callid;
46
+extern OSPTPROVHANDLE _osp_provider;
47
+
48
+/*
49
+ * Get OSP token
50
+ * param msg SIP message
51
+ * param ignore1
52
+ * param ignore2
53
+ * return  MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure
54
+ */
55
+int ospCheckHeader(
56
+    struct sip_msg* msg, 
57
+    char* ignore1, 
58
+    char* ignore2)
59
+{
60
+    unsigned char buffer[OSP_TOKENBUF_SIZE];
61
+    unsigned int  buffersize = sizeof(buffer);
62
+
63
+    LOG(L_DBG, "osp: ospCheckHeader\n");
64
+
65
+    if (ospGetOspHeader(msg, buffer, &buffersize) != 0) {
66
+        return MODULE_RETURNCODE_FALSE;
67
+    } else {
68
+        return MODULE_RETURNCODE_TRUE;
69
+    }
70
+}
71
+
72
+/*
73
+ * Validate OSP token
74
+ * param ignore1
75
+ * param ignore2
76
+ * return  MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure
77
+ */
78
+int ospValidateHeader (
79
+    struct sip_msg* msg, 
80
+    char* ignore1, 
81
+    char* ignore2)
82
+{
83
+    int errorcode; 
84
+    OSPTTRANHANDLE transaction = -1;
85
+    unsigned int authorized = 0;
86
+    unsigned int timelimit = 0;
87
+    void* detaillog = NULL;
88
+    unsigned int logsize = 0;
89
+    unsigned char* callidval = (unsigned char*)"";
90
+    OSPTCALLID* callid = NULL;
91
+    unsigned callidsize = 0;
92
+    unsigned char token[OSP_TOKENBUF_SIZE];
93
+    unsigned int tokensize = sizeof(token);
94
+    osp_dest dest;
95
+    int result = MODULE_RETURNCODE_FALSE;
96
+
97
+    LOG(L_DBG, "osp: ospValidateHeader\n");
98
+
99
+    ospInitDestination(&dest);
100
+
101
+    if ((errorcode = OSPPTransactionNew(_osp_provider, &transaction) != OSPC_ERR_NO_ERROR)) {
102
+        LOG(L_ERR, "osp: ERROR: failed to create a new OSP transaction handle (%d)\n", errorcode);
103
+    } else if ((ospGetRpidUserpart(msg, dest.calling, sizeof(dest.calling)) != 0) && 
104
+        (ospGetFromUserpart(msg, dest.calling, sizeof(dest.calling)) != 0))
105
+    {
106
+        LOG(L_ERR, "osp: ERROR: failed to extract calling number\n");
107
+    } else if ((ospGetUriUserpart(msg, dest.called, sizeof(dest.called)) != 0) &&
108
+        (ospGetToUserpart(msg, dest.called, sizeof(dest.called)) != 0))
109
+    {
110
+        LOG(L_ERR, "osp: ERROR: failed to extract called number\n");
111
+    } else if (ospGetCallId(msg, &callid) != 0) {
112
+        LOG(L_ERR, "osp: ERROR: failed to extract call id\n");
113
+    } else if (ospGetSourceAddress(msg, dest.source, sizeof(dest.source)) != 0) {
114
+        LOG(L_ERR, "osp: ERROR: failed to extract source address\n");
115
+    } else if (ospGetOspHeader(msg, token, &tokensize) != 0) {
116
+        LOG(L_ERR, "osp: ERROR: failed to extract OSP authorization token\n");
117
+    } else {
118
+        LOG(L_INFO, 
119
+            "osp: validate token for: "
120
+            "transaction_handle '%i' "
121
+            "e164_source '%s' "
122
+            "e164_dest '%s' "
123
+            "validate_call_id '%s' "
124
+            "call_id '%.*s'\n",
125
+            transaction,
126
+            dest.calling,
127
+            dest.called,
128
+            _osp_validate_callid == 0 ? "No" : "Yes",
129
+            callid->ospmCallIdLen,
130
+            callid->ospmCallIdVal);
131
+
132
+        if (_osp_validate_callid != 0) {
133
+            callidsize = callid->ospmCallIdLen;
134
+            callidval = callid->ospmCallIdVal;
135
+        }
136
+
137
+        errorcode = OSPPTransactionValidateAuthorisation(
138
+            transaction,
139
+            "",
140
+            "",
141
+            "",
142
+            "",
143
+            dest.calling,
144
+            OSPC_E164,
145
+            dest.called,
146
+            OSPC_E164,
147
+            callidsize,
148
+            callidval,
149
+            tokensize,
150
+            token,
151
+            &authorized,
152
+            &timelimit,
153
+            &logsize,
154
+            detaillog,
155
+            _osp_token_format);
156
+    
157
+        if (callid->ospmCallIdLen > sizeof(dest.callid) - 1) {
158
+            dest.callidsize = sizeof(dest.callid) - 1;
159
+        } else {
160
+            dest.callidsize = callid->ospmCallIdLen;
161
+        }
162
+        memcpy(dest.callid, callid->ospmCallIdVal, dest.callidsize);
163
+        dest.callid[dest.callidsize] = 0;
164
+        dest.transid = ospGetTransactionId(transaction);
165
+        dest.type = OSPC_DESTINATION;
166
+        dest.authtime = time(NULL);
167
+        strncpy(dest.host, _osp_device_ip, sizeof(dest.host) - 1);
168
+
169
+        ospSaveTermDestination(&dest);
170
+
171
+        if ((errorcode == OSPC_ERR_NO_ERROR) && (authorized == 1)) {
172
+            LOG(L_DBG, 
173
+                "osp: call is authorized for %d seconds, call_id '%.*s' transaction_id '%llu'",
174
+                timelimit,
175
+                dest.callidsize,
176
+                dest.callid,
177
+                dest.transid);
178
+            ospRecordTermTransaction(msg, dest.transid, dest.source, dest.calling, dest.called, dest.authtime);
179
+            result = MODULE_RETURNCODE_TRUE;
180
+        } else {
181
+            LOG(L_ERR, "osp: ERROR: token is invalid (%i)\n", errorcode);
182
+
183
+            /* 
184
+             * Update terminating status code to 401 and report terminating setup usage.
185
+             * We may need to make 401 configurable, just in case a user decides to reply with
186
+             * a different code.  Other options - trigger call setup usage reporting from the cpl
187
+             * (after replying with an error code), or maybe use a different tm callback.
188
+             */
189
+            ospRecordEvent(0, 401);
190
+        }
191
+    }
192
+
193
+    if (transaction != -1) {
194
+        OSPPTransactionDelete(transaction);
195
+    }
196
+
197
+    if (callid != NULL) {
198
+        OSPPCallIdDelete(&callid);
199
+    }
200
+    
201
+    return result;
202
+}
203
+
Browse code

according to Di-Shi are K's and ser's osp module more or less the same, whereas Kamailio's osp module should be more up2date than ser's module. Thus, ser's osp module will be removed and K's osp module will be used as common OSP module.

Klaus Darilion authored on 02/07/2009 08:34:13
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,203 +0,0 @@
1
-/*
2
- * ser osp module. 
3
- *
4
- * This module enables ser to communicate with an Open Settlement 
5
- * Protocol (OSP) server.  The Open Settlement Protocol is an ETSI 
6
- * defined standard for Inter-Domain VoIP pricing, authorization
7
- * and usage exchange.  The technical specifications for OSP 
8
- * (ETSI TS 101 321 V4.1.1) are available at www.etsi.org.
9
- *
10
- * Uli Abend was the original contributor to this module.
11
- * 
12
- * Copyright (C) 2001-2005 Fhg Fokus
13
- *
14
- * This file is part of ser, a free SIP server.
15
- *
16
- * ser is free software; you can redistribute it and/or modify
17
- * it under the terms of the GNU General Public License as published by
18
- * the Free Software Foundation; either version 2 of the License, or
19
- * (at your option) any later version
20
- *
21
- * For a license to use the ser software under conditions
22
- * other than those described here, or to purchase support for this
23
- * software, please contact iptel.org by e-mail at the following addresses:
24
- *    info@iptel.org
25
- *
26
- * ser is distributed in the hope that it will be useful,
27
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
28
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29
- * GNU General Public License for more details.
30
- *
31
- * You should have received a copy of the GNU General Public License
32
- * along with this program; if not, write to the Free Software
33
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
34
- */
35
-
36
-#include "osp_mod.h"
37
-#include "term_transaction.h"
38
-#include "sipheader.h"
39
-#include "destination.h"
40
-#include "osptoolkit.h"
41
-#include "usage.h"
42
-
43
-extern char* _osp_device_ip;
44
-extern int _osp_token_format;
45
-extern int _osp_validate_callid;
46
-extern OSPTPROVHANDLE _osp_provider;
47
-
48
-/*
49
- * Get OSP token
50
- * param msg SIP message
51
- * param ignore1
52
- * param ignore2
53
- * return  MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure
54
- */
55
-int ospCheckHeader(
56
-    struct sip_msg* msg, 
57
-    char* ignore1, 
58
-    char* ignore2)
59
-{
60
-    unsigned char buffer[OSP_TOKENBUF_SIZE];
61
-    unsigned int  buffersize = sizeof(buffer);
62
-
63
-    LOG(L_DBG, "osp: ospCheckHeader\n");
64
-
65
-    if (ospGetOspHeader(msg, buffer, &buffersize) != 0) {
66
-        return MODULE_RETURNCODE_FALSE;
67
-    } else {
68
-        return MODULE_RETURNCODE_TRUE;
69
-    }
70
-}
71
-
72
-/*
73
- * Validate OSP token
74
- * param ignore1
75
- * param ignore2
76
- * return  MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure
77
- */
78
-int ospValidateHeader (
79
-    struct sip_msg* msg, 
80
-    char* ignore1, 
81
-    char* ignore2)
82
-{
83
-    int errorcode; 
84
-    OSPTTRANHANDLE transaction = -1;
85
-    unsigned int authorized = 0;
86
-    unsigned int timelimit = 0;
87
-    void* detaillog = NULL;
88
-    unsigned int logsize = 0;
89
-    unsigned char* callidval = (unsigned char*)"";
90
-    OSPTCALLID* callid = NULL;
91
-    unsigned callidsize = 0;
92
-    unsigned char token[OSP_TOKENBUF_SIZE];
93
-    unsigned int tokensize = sizeof(token);
94
-    osp_dest dest;
95
-    int result = MODULE_RETURNCODE_FALSE;
96
-
97
-    LOG(L_DBG, "osp: ospValidateHeader\n");
98
-
99
-    ospInitDestination(&dest);
100
-
101
-    if ((errorcode = OSPPTransactionNew(_osp_provider, &transaction) != OSPC_ERR_NO_ERROR)) {
102
-        LOG(L_ERR, "osp: ERROR: failed to create a new OSP transaction handle (%d)\n", errorcode);
103
-    } else if ((ospGetRpidUserpart(msg, dest.calling, sizeof(dest.calling)) != 0) && 
104
-        (ospGetFromUserpart(msg, dest.calling, sizeof(dest.calling)) != 0))
105
-    {
106
-        LOG(L_ERR, "osp: ERROR: failed to extract calling number\n");
107
-    } else if ((ospGetUriUserpart(msg, dest.called, sizeof(dest.called)) != 0) &&
108
-        (ospGetToUserpart(msg, dest.called, sizeof(dest.called)) != 0))
109
-    {
110
-        LOG(L_ERR, "osp: ERROR: failed to extract called number\n");
111
-    } else if (ospGetCallId(msg, &callid) != 0) {
112
-        LOG(L_ERR, "osp: ERROR: failed to extract call id\n");
113
-    } else if (ospGetSourceAddress(msg, dest.source, sizeof(dest.source)) != 0) {
114
-        LOG(L_ERR, "osp: ERROR: failed to extract source address\n");
115
-    } else if (ospGetOspHeader(msg, token, &tokensize) != 0) {
116
-        LOG(L_ERR, "osp: ERROR: failed to extract OSP authorization token\n");
117
-    } else {
118
-        LOG(L_INFO, 
119
-            "osp: validate token for: "
120
-            "transaction_handle '%i' "
121
-            "e164_source '%s' "
122
-            "e164_dest '%s' "
123
-            "validate_call_id '%s' "
124
-            "call_id '%.*s'\n",
125
-            transaction,
126
-            dest.calling,
127
-            dest.called,
128
-            _osp_validate_callid == 0 ? "No" : "Yes",
129
-            callid->ospmCallIdLen,
130
-            callid->ospmCallIdVal);
131
-
132
-        if (_osp_validate_callid != 0) {
133
-            callidsize = callid->ospmCallIdLen;
134
-            callidval = callid->ospmCallIdVal;
135
-        }
136
-
137
-        errorcode = OSPPTransactionValidateAuthorisation(
138
-            transaction,
139
-            "",
140
-            "",
141
-            "",
142
-            "",
143
-            dest.calling,
144
-            OSPC_E164,
145
-            dest.called,
146
-            OSPC_E164,
147
-            callidsize,
148
-            callidval,
149
-            tokensize,
150
-            token,
151
-            &authorized,
152
-            &timelimit,
153
-            &logsize,
154
-            detaillog,
155
-            _osp_token_format);
156
-    
157
-        if (callid->ospmCallIdLen > sizeof(dest.callid) - 1) {
158
-            dest.callidsize = sizeof(dest.callid) - 1;
159
-        } else {
160
-            dest.callidsize = callid->ospmCallIdLen;
161
-        }
162
-        memcpy(dest.callid, callid->ospmCallIdVal, dest.callidsize);
163
-        dest.callid[dest.callidsize] = 0;
164
-        dest.transid = ospGetTransactionId(transaction);
165
-        dest.type = OSPC_DESTINATION;
166
-        dest.authtime = time(NULL);
167
-        strncpy(dest.host, _osp_device_ip, sizeof(dest.host) - 1);
168
-
169
-        ospSaveTermDestination(&dest);
170
-
171
-        if ((errorcode == OSPC_ERR_NO_ERROR) && (authorized == 1)) {
172
-            LOG(L_DBG, 
173
-                "osp: call is authorized for %d seconds, call_id '%.*s' transaction_id '%llu'",
174
-                timelimit,
175
-                dest.callidsize,
176
-                dest.callid,
177
-                dest.transid);
178
-            ospRecordTermTransaction(msg, dest.transid, dest.source, dest.calling, dest.called, dest.authtime);
179
-            result = MODULE_RETURNCODE_TRUE;
180
-        } else {
181
-            LOG(L_ERR, "osp: ERROR: token is invalid (%i)\n", errorcode);
182
-
183
-            /* 
184
-             * Update terminating status code to 401 and report terminating setup usage.
185
-             * We may need to make 401 configurable, just in case a user decides to reply with
186
-             * a different code.  Other options - trigger call setup usage reporting from the cpl
187
-             * (after replying with an error code), or maybe use a different tm callback.
188
-             */
189
-            ospRecordEvent(0, 401);
190
-        }
191
-    }
192
-
193
-    if (transaction != -1) {
194
-        OSPPTransactionDelete(transaction);
195
-    }
196
-
197
-    if (callid != NULL) {
198
-        OSPPCallIdDelete(&callid);
199
-    }
200
-    
201
-    return result;
202
-}
203
-
Browse code

1. Added support to new AuthRsp codes. 2. Modified response messages and log messages.

Di-Shi Sun authored on 31/12/2007 06:09:31
Showing 1 changed files
... ...
@@ -98,7 +98,7 @@ int ospValidateHeader (
98 98
 
99 99
     ospInitDestination(&dest);
100 100
 
101
-    if ((errorcode = OSPPTransactionNew(_osp_provider, &transaction) != 0)) {
101
+    if ((errorcode = OSPPTransactionNew(_osp_provider, &transaction) != OSPC_ERR_NO_ERROR)) {
102 102
         LOG(L_ERR, "osp: ERROR: failed to create a new OSP transaction handle (%d)\n", errorcode);
103 103
     } else if ((ospGetRpidUserpart(msg, dest.calling, sizeof(dest.calling)) != 0) && 
104 104
         (ospGetFromUserpart(msg, dest.calling, sizeof(dest.calling)) != 0))
... ...
@@ -168,7 +168,7 @@ int ospValidateHeader (
168 168
 
169 169
         ospSaveTermDestination(&dest);
170 170
 
171
-        if ((errorcode == 0) && (authorized == 1)) {
171
+        if ((errorcode == OSPC_ERR_NO_ERROR) && (authorized == 1)) {
172 172
             LOG(L_DBG, 
173 173
                 "osp: call is authorized for %d seconds, call_id '%.*s' transaction_id '%llu'",
174 174
                 timelimit,
Browse code

1. Changed OSP cookie tags to handle the destinations corrupting Record-Route/Route headers. (SER does not have this issue, just for code sync) 2. Fixed reporting wrong translated called numbers issue. 3. Replaced strcpy by strncpy.

Di-Shi Sun authored on 21/12/2007 07:19:49
Showing 1 changed files
... ...
@@ -40,7 +40,7 @@
40 40
 #include "osptoolkit.h"
41 41
 #include "usage.h"
42 42
 
43
-extern char *_osp_device_ip;
43
+extern char* _osp_device_ip;
44 44
 extern int _osp_token_format;
45 45
 extern int _osp_validate_callid;
46 46
 extern OSPTPROVHANDLE _osp_provider;
... ...
@@ -53,9 +53,9 @@ extern OSPTPROVHANDLE _osp_provider;
53 53
  * return  MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure
54 54
  */
55 55
 int ospCheckHeader(
56
-    struct sip_msg *msg, 
57
-    char *ignore1, 
58
-    char *ignore2)
56
+    struct sip_msg* msg, 
57
+    char* ignore1, 
58
+    char* ignore2)
59 59
 {
60 60
     unsigned char buffer[OSP_TOKENBUF_SIZE];
61 61
     unsigned int  buffersize = sizeof(buffer);
... ...
@@ -76,18 +76,18 @@ int ospCheckHeader(
76 76
  * return  MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure
77 77
  */
78 78
 int ospValidateHeader (
79
-    struct sip_msg *msg, 
80
-    char *ignore1, 
81
-    char *ignore2)
79
+    struct sip_msg* msg, 
80
+    char* ignore1, 
81
+    char* ignore2)
82 82
 {
83 83
     int errorcode; 
84 84
     OSPTTRANHANDLE transaction = -1;
85 85
     unsigned int authorized = 0;
86 86
     unsigned int timelimit = 0;
87
-    void *detaillog = NULL;
87
+    void* detaillog = NULL;
88 88
     unsigned int logsize = 0;
89
-    unsigned char *callidval = (unsigned char*)"";
90
-    OSPTCALLID *callid = NULL;
89
+    unsigned char* callidval = (unsigned char*)"";
90
+    OSPTCALLID* callid = NULL;
91 91
     unsigned callidsize = 0;
92 92
     unsigned char token[OSP_TOKENBUF_SIZE];
93 93
     unsigned int tokensize = sizeof(token);
... ...
@@ -164,7 +164,7 @@ int ospValidateHeader (
164 164
         dest.transid = ospGetTransactionId(transaction);
165 165
         dest.type = OSPC_DESTINATION;
166 166
         dest.authtime = time(NULL);
167
-        strcpy(dest.host, _osp_device_ip);
167
+        strncpy(dest.host, _osp_device_ip, sizeof(dest.host) - 1);
168 168
 
169 169
         ospSaveTermDestination(&dest);
170 170
 
Browse code

1. Added usage report for BYE without OSP info. 2. Added destination count code (does not work in this release). 3. Reformated code.

Di-Shi Sun authored on 22/10/2007 02:40:45
Showing 1 changed files
... ...
@@ -40,7 +40,7 @@
40 40
 #include "osptoolkit.h"
41 41
 #include "usage.h"
42 42
 
43
-extern char* _osp_device_ip;
43
+extern char *_osp_device_ip;
44 44
 extern int _osp_token_format;
45 45
 extern int _osp_validate_callid;
46 46
 extern OSPTPROVHANDLE _osp_provider;
... ...
@@ -53,9 +53,9 @@ extern OSPTPROVHANDLE _osp_provider;
53 53
  * return  MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure
54 54
  */
55 55
 int ospCheckHeader(
56
-    struct sip_msg* msg, 
57
-    char* ignore1, 
58
-    char* ignore2)
56
+    struct sip_msg *msg, 
57
+    char *ignore1, 
58
+    char *ignore2)
59 59
 {
60 60
     unsigned char buffer[OSP_TOKENBUF_SIZE];
61 61
     unsigned int  buffersize = sizeof(buffer);
... ...
@@ -76,18 +76,18 @@ int ospCheckHeader(
76 76
  * return  MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure
77 77
  */
78 78
 int ospValidateHeader (
79
-    struct sip_msg* msg, 
80
-    char* ignore1, 
81
-    char* ignore2)
79
+    struct sip_msg *msg, 
80
+    char *ignore1, 
81
+    char *ignore2)
82 82
 {
83 83
     int errorcode; 
84 84
     OSPTTRANHANDLE transaction = -1;
85 85
     unsigned int authorized = 0;
86 86
     unsigned int timelimit = 0;
87
-    void* detaillog = NULL;
87
+    void *detaillog = NULL;
88 88
     unsigned int logsize = 0;
89
-    unsigned char* callidval = (unsigned char*)"";
90
-    OSPTCALLID* callid = NULL;
89
+    unsigned char *callidval = (unsigned char*)"";
90
+    OSPTCALLID *callid = NULL;
91 91
     unsigned callidsize = 0;
92 92
     unsigned char token[OSP_TOKENBUF_SIZE];
93 93
     unsigned int tokensize = sizeof(token);
... ...
@@ -161,7 +161,7 @@ int ospValidateHeader (
161 161
         }
162 162
         memcpy(dest.callid, callid->ospmCallIdVal, dest.callidsize);
163 163
         dest.callid[dest.callidsize] = 0;
164
-        dest.tid = ospGetTransactionId(transaction);
164
+        dest.transid = ospGetTransactionId(transaction);
165 165
         dest.type = OSPC_DESTINATION;
166 166
         dest.authtime = time(NULL);
167 167
         strcpy(dest.host, _osp_device_ip);
... ...
@@ -170,12 +170,12 @@ int ospValidateHeader (
170 170
 
171 171
         if ((errorcode == 0) && (authorized == 1)) {
172 172
             LOG(L_DBG, 
173
-                "osp: call is authorized for %d seconds, call_id '%.*s' transaction_id '%lld'",
173
+                "osp: call is authorized for %d seconds, call_id '%.*s' transaction_id '%llu'",
174 174
                 timelimit,
175 175
                 dest.callidsize,
176 176
                 dest.callid,
177
-                dest.tid);
178
-            ospRecordTermTransaction(msg, transaction, dest.source, dest.calling, dest.called, dest.authtime);
177
+                dest.transid);
178
+            ospRecordTermTransaction(msg, dest.transid, dest.source, dest.calling, dest.called, dest.authtime);
179 179
             result = MODULE_RETURNCODE_TRUE;
180 180
         } else {
181 181
             LOG(L_ERR, "osp: ERROR: token is invalid (%i)\n", errorcode);
Browse code

merge code from experimental.

Di-Shi Sun authored on 26/04/2007 08:18:38
Showing 1 changed files
... ...
@@ -32,150 +32,172 @@
32 32
  * along with this program; if not, write to the Free Software
33 33
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
34 34
  */
35
+
35 36
 #include "osp_mod.h"
36
-#include "osptoolkit.h"
37 37
 #include "term_transaction.h"
38 38
 #include "sipheader.h"
39 39
 #include "destination.h"
40
+#include "osptoolkit.h"
40 41
 #include "usage.h"
41
-#include "osp/osp.h"
42
-#include "osp/ospb64.h"
43
-#include "../../sr_module.h"
44
-#include "../../locking.h"
45
-#include "../../mem/mem.h"
46
-
47
-extern OSPTPROVHANDLE _provider;
48
-extern int _token_format;
49
-extern int _validate_call_id;
50
-extern char* _device_ip;
51 42
 
43
+extern char* _osp_device_ip;
44
+extern int _osp_token_format;
45
+extern int _osp_validate_callid;
46
+extern OSPTPROVHANDLE _osp_provider;
52 47
 
53
-int checkospheader(struct sip_msg* msg, char* ignore1, char* ignore2) {
54
-	char temp[3000];
55
-	int  sizeoftemp = sizeof(temp);
56
-
57
-
58
-	if (getOspHeader(msg, temp, &sizeoftemp) != 0) {
59
-		return MODULE_RETURNCODE_FALSE;
60
-	} else {
61
-		return MODULE_RETURNCODE_TRUE;
62
-	}
48
+/*
49
+ * Get OSP token
50
+ * param msg SIP message
51
+ * param ignore1
52
+ * param ignore2
53
+ * return  MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure
54
+ */
55
+int ospCheckHeader(
56
+    struct sip_msg* msg, 
57
+    char* ignore1, 
58
+    char* ignore2)
59
+{
60
+    unsigned char buffer[OSP_TOKENBUF_SIZE];
61
+    unsigned int  buffersize = sizeof(buffer);
62
+
63
+    LOG(L_DBG, "osp: ospCheckHeader\n");
64
+
65
+    if (ospGetOspHeader(msg, buffer, &buffersize) != 0) {
66
+        return MODULE_RETURNCODE_FALSE;
67
+    } else {
68
+        return MODULE_RETURNCODE_TRUE;
69
+    }
63 70
 }
64 71
 
65
-
66
-
67
-
68
-/** validate OSP header */
69
-int validateospheader (struct sip_msg* msg, char* ignore1, char* ignore2) {
70
-	int res; 
71
-	int valid;
72
-
73
-	OSPTTRANHANDLE transaction = -1;
74
-	unsigned int authorized = 0;
75
-	unsigned int time_limit = 0;
76
-	unsigned int log_size = 0;
77
-	void *detail_log = NULL;
78
-	OSPTCALLID* call_id = NULL;
79
-	osp_dest  dest;
80
-
81
-	char token[3000];
82
-	int sizeoftoken = sizeof(token);
83
-
84
-	unsigned callIdLen = 0;
85
-	unsigned char* callIdVal = (unsigned char*)"";
86
-
87
-	
88
-
89
-	valid = MODULE_RETURNCODE_FALSE;
90
-
91
-	initDestination(&dest);
92
-
93
-	if (0!= (res=OSPPTransactionNew(_provider, &transaction))) {
94
-		ERR("osp: Failed to create a new OSP transaction id %d\n",res);
95
-	} else if (0 != getFromUserpart(msg, dest.callingnumber, sizeof(dest.callingnumber))) {
96
-		ERR("osp: Failed to extract calling number\n");
97
-	} else if (0 != getToUserpart(msg, dest.callednumber, sizeof(dest.callednumber))) {
98
-		ERR("osp: Failed to extract called number\n");
99
-	} else if (0 != getCallId(msg, &call_id)) {
100
-		ERR("osp: Failed to extract call id\n");
101
-	} else if (0 != getSourceAddress(msg,dest.source,sizeof(dest.source))) {
102
-		ERR("osp: Failed to extract source address\n");
103
-	} else if (0 != getOspHeader(msg, token, &sizeoftoken)) {
104
-		ERR("osp: Failed to extract OSP authorization token\n");
105
-	} else {
106
-		DBG("About to validate OSP token for:\n"
107
-			"transaction-handle = >%i< \n"
108
-			"e164_source = >%s< \n"
109
-			"e164_dest = >%s< \n"
110
-			"validate_call_id = >%s< \n"
111
-			"call-id = >%.*s< \n",
112
-			transaction,
113
-			dest.callingnumber,
114
-			dest.callednumber,
115
-			_validate_call_id==0?"No":"Yes",
116
-			call_id->ospmCallIdLen,
117
-			call_id->ospmCallIdVal);
118
-
119
-		if (_validate_call_id != 0) {
120
-			callIdLen = call_id->ospmCallIdLen;
121
-			callIdVal = call_id->ospmCallIdVal;
122
-		}
123
-
124
-		res = OSPPTransactionValidateAuthorisation(
125
-			transaction,
126
-			"",
127
-			"",
128
-			"",
129
-			"",
130
-			dest.callingnumber,
131
-			OSPC_E164,
132
-			dest.callednumber,
133
-			OSPC_E164,
134
-			callIdLen,
135
-			callIdVal,
136
-			sizeoftoken,
137
-			token,
138
-			&authorized,
139
-			&time_limit,
140
-			&log_size,
141