Skip to content

Commit

Permalink
modules/ims_charging: added extra stat replies received for CCRs
Browse files Browse the repository at this point in the history
  • Loading branch information
jaybeepee committed Apr 14, 2015
1 parent 9ebf9a1 commit 90d0a99
Show file tree
Hide file tree
Showing 3 changed files with 184 additions and 0 deletions.
79 changes: 79 additions & 0 deletions parser/case_pani.h
@@ -0,0 +1,79 @@
/*
* P-Asserted-Network-Info Field Name Parsing Macros
*
* Copyright (C) 2001-2003 FhG Fokus
*
* This file is part of Kamailio, a free SIP server.
*
* Kamailio is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version
*
* Kamailio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

/*! \file
* \brief Parser :: P-Asserted-Network-Info Field Name Parsing Macros
*
* \ingroup parser
*/

#ifndef CASE_PANI_H
#define CASE_PANI_H

#include "keys.h"

#define fo_CASE \
if (LOWER_BYTE(*p) == 'o') { \
hdr->type = HDR_PANI_T; \
p++; \
goto dc_end; \
} \
goto other;

#define _INF_CASE \
val = READ(p); \
switch(LOWER_DWORD(val)) { \
case __inf_: \
p += 4; \
fo_CASE; \
} \

#define WORK_CASE \
val = READ(p); \
switch(LOWER_DWORD(val)) { \
case _work_: \
p += 4; \
_INF_CASE; \
} \

#define _NET_CASE \
val = READ(p); \
switch(LOWER_DWORD(val)) { \
case __net_: \
p += 4; \
WORK_CASE; \
} \

#define CESS_CASE \
val = READ(p); \
switch(LOWER_DWORD(val)) { \
case _cess_: \
p += 4; \
_NET_CASE; \
} \

#define p_ac_CASE \
p += 4; \
CESS_CASE; \
goto other;

#endif /* CASE_PANI_H */
72 changes: 72 additions & 0 deletions parser/parse_pani.c
@@ -0,0 +1,72 @@
#include "../mem/mem.h"
#include "parse_pani.h"

int parse_pani_header(struct sip_msg * const msg) {
pani_body_t* pani_body;
struct hdr_field *hdr;
char *p, *network_info = 0;
int network_info_len = 0;
int len;

/* maybe the header is already parsed! */
if (msg->pani && msg->pani->parsed)
return 0;

if (parse_headers(msg, HDR_EOH_F, 0) == -1 || !msg->pani) {
return -1;
}

hdr = msg->pani;
p = hdr->body.s;
p = strchr(p, ';');
if (p) {
network_info = p + 1;
network_info_len = hdr->body.len - (network_info - hdr->body.s) + 1/*nul*/;
}

len = sizeof(pani_body_t) + network_info_len;
pani_body = (pani_body_t*) pkg_malloc(len);
if (!pani_body) {
LM_ERR("no more pkg mem\n");
return -1;
}
memset(pani_body, 0, len);

if (network_info_len > 0) {
p = (char*) (pani_body + 1);
memcpy(p, network_info, network_info_len);
pani_body->access_info.s = p;
pani_body->access_info.len = network_info_len;
}

if (strncmp(hdr->body.s, "IEEE-802.11a", 12) == 0) {
pani_body->access_type = IEEE_80211a;
} else if (strncmp(hdr->body.s, "IEEE-802.11a", 12) == 0) {
pani_body->access_type = IEEE_80211b;
} else if (strncmp(hdr->body.s, "3GPP-GERAN", 10) == 0) {
pani_body->access_type = _3GPP_GERAN;
} else if (strncmp(hdr->body.s, "3GPP-UTRAN-FDD", 14) == 0) {
pani_body->access_type = _3GPP_UTRANFDD;
} else if (strncmp(hdr->body.s, "3GPP-UTRAN-TDD", 14) == 0) {
pani_body->access_type = _3GPP_EUTRANTDD;
} else if (strncmp(hdr->body.s, "3GPP-E-UTRAN-FDD", 16) == 0) {
pani_body->access_type = _3GPP_EUTRANFDD;
} else if (strncmp(hdr->body.s, "3GPP-E-UTRAN-TDD", 16) == 0) {
pani_body->access_type = _3GPP_UTRANTDD;
} else if (strncmp(hdr->body.s, "3GPP-CDMA2000", 13) == 0) {
pani_body->access_type = _3GPP_CDMA_2000;
} else {
LM_ERR("Unknown access type [%.*s]\n", hdr->body.len, hdr->body.s);
return -1;
}
hdr->parsed = (void*) pani_body;

return 0;
}

int free_pani_body(struct pani_body *body) {
if (body != NULL) {
pkg_free(body);
}
return 0;
}
33 changes: 33 additions & 0 deletions parser/parse_pani.h
@@ -0,0 +1,33 @@
/*
* File: parse_pani.h
* Author: jaybeepee
*
* Created on 25 February 2015, 2:51 PM
*/

#ifndef PARSE_PANI_H
#define PARSE_PANI_H

#include "../str.h"
#include "msg_parser.h"
#include "parse_to.h"

enum access_types { IEEE_80211a=0, IEEE_80211b, _3GPP_GERAN, _3GPP_UTRANFDD, _3GPP_UTRANTDD, _3GPP_EUTRANFDD, _3GPP_EUTRANTDD, _3GPP_CDMA_2000 };

typedef struct pani_body {
enum access_types access_type;
str access_info;
} pani_body_t;

int parse_pani_header(struct sip_msg* const msg);

///*! casting macro for accessing P-Asserted-Identity body */
//#define get_pani(p_msg) ((p_id_body_t*)(p_msg)->pai->parsed)
//
///*! casting macro for accessing P-Preferred-Identity body */
//#define get_pani(p_msg) ((p_id_body_t*)(p_msg)->ppi->parsed)

int free_pani_body(struct pani_body *pani_body);

#endif /* PARSE_PANI_H */

0 comments on commit 90d0a99

Please sign in to comment.