s6a_common.c 2.59 KB
Newer Older
winckel's avatar
 
winckel committed
1
/*******************************************************************************
Lionel Gauthier's avatar
GPLv3  
Lionel Gauthier committed
2 3
    OpenAirInterface
    Copyright(c) 1999 - 2014 Eurecom
winckel's avatar
 
winckel committed
4

Lionel Gauthier's avatar
GPLv3  
Lionel Gauthier committed
5 6 7 8
    OpenAirInterface 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 3 of the License, or
    (at your option) any later version.
winckel's avatar
 
winckel committed
9 10


Lionel Gauthier's avatar
GPLv3  
Lionel Gauthier committed
11 12 13 14
    OpenAirInterface 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.
winckel's avatar
 
winckel committed
15

Lionel Gauthier's avatar
GPLv3  
Lionel Gauthier committed
16 17 18 19
    You should have received a copy of the GNU General Public License
    along with OpenAirInterface.The full GNU General Public License is
   included in this distribution in the file called "COPYING". If not,
   see <http://www.gnu.org/licenses/>.
winckel's avatar
 
winckel committed
20 21

  Contact Information
Lionel Gauthier's avatar
GPLv3  
Lionel Gauthier committed
22 23 24 25 26
  OpenAirInterface Admin: openair_admin@eurecom.fr
  OpenAirInterface Tech : openair_tech@eurecom.fr
  OpenAirInterface Dev  : openair4g-devel@eurecom.fr

  Address      : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France.
winckel's avatar
 
winckel committed
27

Lionel Gauthier's avatar
GPLv3  
Lionel Gauthier committed
28
 *******************************************************************************/
winckel's avatar
 
winckel committed
29 30 31 32 33 34 35

#include "hss_config.h"
#include "db_proto.h"
#include "s6a_proto.h"

int s6a_add_result_code(struct msg *ans, struct avp *failed_avp, int result_code, int experimental)
{
36 37
  struct avp *avp;
  union avp_value value;
winckel's avatar
 
winckel committed
38

39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
  if (DIAMETER_ERROR_IS_VENDOR(result_code) && experimental != 0) {
    struct avp *experimental_result;
    CHECK_FCT(fd_msg_avp_new(s6a_cnf.dataobj_s6a_experimental_result,
                             0, &experimental_result));
    CHECK_FCT(fd_msg_avp_new(s6a_cnf.dataobj_s6a_vendor_id,
                             0, &avp));
    value.u32 = VENDOR_3GPP;
    CHECK_FCT(fd_msg_avp_setvalue(avp, &value));
    CHECK_FCT(fd_msg_avp_add(experimental_result, MSG_BRW_LAST_CHILD, avp));
    CHECK_FCT(fd_msg_avp_new(s6a_cnf.dataobj_s6a_experimental_result_code,
                             0, &avp));
    value.u32 = result_code;
    CHECK_FCT(fd_msg_avp_setvalue(avp, &value));
    CHECK_FCT(fd_msg_avp_add(experimental_result, MSG_BRW_LAST_CHILD, avp));
    CHECK_FCT(fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, experimental_result));
winckel's avatar
 
winckel committed
54

55 56 57 58 59 60 61 62 63 64 65
    /* Add Origin_Host & Origin_Realm AVPs */
    CHECK_FCT(fd_msg_add_origin(ans, 0));
  } else {
    /* This is a code defined in the base protocol: result-code AVP should
     * be used.
     */
    CHECK_FCT(fd_msg_rescode_set(ans, retcode_2_string(result_code), NULL,
                                 failed_avp, 1));
  }

  return 0;
winckel's avatar
 
winckel committed
66
}