Changeset 706:4ffbc9f1e922 in freeDiameter for libfdcore/messages.c
- Timestamp:
- Feb 9, 2011, 3:26:58 PM (13 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libfdcore/messages.c
r688 r706 36 36 #include "fdcore-internal.h" 37 37 38 static struct dict_object * dict_avp_SI = NULL; /* Session-Id */ 38 39 static struct dict_object * dict_avp_OH = NULL; /* Origin-Host */ 39 40 static struct dict_object * dict_avp_OR = NULL; /* Origin-Realm */ … … 54 55 55 56 /* Initialize the dictionary objects that we may use frequently */ 57 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Session-Id", &dict_avp_SI , ENOENT) ); 56 58 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Origin-Host", &dict_avp_OH , ENOENT) ); 57 59 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Origin-Realm", &dict_avp_OR , ENOENT) ); … … 89 91 /* Set its value */ 90 92 memset(&val, 0, sizeof(val)); 91 val.os.data = ( unsigned char *)fd_g_config->cnf_diamid;93 val.os.data = (os0_t)fd_g_config->cnf_diamid; 92 94 val.os.len = fd_g_config->cnf_diamid_len; 93 95 CHECK_FCT( fd_msg_avp_setvalue( avp_OH, &val ) ); … … 102 104 /* Set its value */ 103 105 memset(&val, 0, sizeof(val)); 104 val.os.data = ( unsigned char *)fd_g_config->cnf_diamrlm;106 val.os.data = (os0_t)fd_g_config->cnf_diamrlm; 105 107 val.os.len = fd_g_config->cnf_diamrlm_len; 106 108 CHECK_FCT( fd_msg_avp_setvalue( avp_OR, &val ) ); … … 124 126 return 0; 125 127 } 128 129 /* Create a new Session-Id and add at the beginning of the message. */ 130 int fd_msg_new_session( struct msg * msg, os0_t opt, size_t optlen ) 131 { 132 union avp_value val; 133 struct avp * avp = NULL; 134 struct session * sess = NULL; 135 os0_t sid; 136 size_t sidlen; 137 138 TRACE_ENTRY("%p %p %zd", msg, opt, optlen); 139 CHECK_PARAMS( msg ); 140 141 /* Check there is not already a session in the message */ 142 CHECK_FCT( fd_msg_sess_get(fd_g_config->cnf_dict, msg, &sess, NULL) ); 143 CHECK_PARAMS( sess == NULL ); 144 145 /* Ok, now create the session */ 146 CHECK_FCT( fd_sess_new ( &sess, fd_g_config->cnf_diamid, fd_g_config->cnf_diamid_len, opt, optlen ) ); 147 CHECK_FCT( fd_sess_getsid( sess, &sid, &sidlen) ); 148 149 /* Create an AVP to hold it */ 150 CHECK_FCT( fd_msg_avp_new( dict_avp_SI, 0, &avp ) ); 151 152 /* Set its value */ 153 memset(&val, 0, sizeof(val)); 154 val.os.data = sid; 155 val.os.len = sidlen; 156 CHECK_FCT( fd_msg_avp_setvalue( avp, &val ) ); 157 158 /* Add it to the message */ 159 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_FIRST_CHILD, avp ) ); 160 161 /* Done! */ 162 return 0; 163 } 164 126 165 127 166 /* Add Result-Code and eventually Failed-AVP, Error-Message and Error-Reporting-Host AVPs */ … … 147 186 memset(&req, 0, sizeof(struct dict_enumval_request)); 148 187 149 /* First, get the enumerated type of the Result-Code AVP */188 /* First, get the enumerated type of the Result-Code AVP (this is fast, no need to cache the object) */ 150 189 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_TYPE, TYPE_OF_AVP, dict_avp_RC, &(req.type_obj), ENOENT ) ); 151 190 … … 184 223 /* Set its value */ 185 224 memset(&val, 0, sizeof(val)); 186 val.os.data = (u nsigned char*)fd_g_config->cnf_diamid;225 val.os.data = (uint8_t *)fd_g_config->cnf_diamid; 187 226 val.os.len = fd_g_config->cnf_diamid_len; 188 227 CHECK_FCT( fd_msg_avp_setvalue( avp_ERH, &val ) ); … … 246 285 247 286 if (errormsg) { 248 val.os.data = (u nsigned char*)errormsg;287 val.os.data = (uint8_t *)errormsg; 249 288 val.os.len = strlen(errormsg); 250 289 } else { 251 val.os.data = (u nsigned char*)rescode;290 val.os.data = (uint8_t *)rescode; 252 291 val.os.len = strlen(rescode); 253 292 } … … 311 350 if ((ret != EBADMSG) /* Parsing grouped AVP failed / Conflicting rule found */ 312 351 && (ret != ENOTSUP)) /* Command is not supported / Mandatory AVP is not supported */ 313 return ret; 352 return ret; /* 0 or another error */ 314 353 315 354 TRACE_DEBUG(INFO, "A message does not comply to the dictionary and/or rules (%s)", pei.pei_errcode);
Note: See TracChangeset
for help on using the changeset viewer.