comparison libfreeDiameter/messages.c @ 35:6486e97f56ae

Added test for modified message parsing
author Sebastien Decugis <sdecugis@nict.go.jp>
date Mon, 02 Nov 2009 14:54:42 +0900
parents 0e2b57789361
children cc3c59fe98fe
comparison
equal deleted inserted replaced
34:0e2b57789361 35:6486e97f56ae
1862 }; 1862 };
1863 1863
1864 /* Create an empty AVP of a given model (to use in Failed-AVP) */ 1864 /* Create an empty AVP of a given model (to use in Failed-AVP) */
1865 static struct avp * empty_avp(struct dict_object * model_avp) 1865 static struct avp * empty_avp(struct dict_object * model_avp)
1866 { 1866 {
1867 TODO("Create the AVP instance and set a 0 value"); 1867 struct avp * avp = NULL;
1868 return NULL; 1868 struct dict_avp_data avp_info;
1869 union avp_value val;
1870 char os[1] = { '\0' };
1871
1872 /* Create an instance */
1873 CHECK_FCT_DO( fd_msg_avp_new(model_avp, 0, &avp ), return NULL );
1874
1875 /* Type of the AVP */
1876 CHECK_FCT_DO( fd_dict_getval(model_avp, &avp_info), return NULL );
1877
1878 /* Prepare the empty value */
1879 memset(&val, 0, sizeof(val));
1880 switch (avp_info.avp_basetype) {
1881 case AVP_TYPE_OCTETSTRING:
1882 val.os.data = os;
1883 val.os.len = sizeof(os);
1884 case AVP_TYPE_INTEGER32:
1885 case AVP_TYPE_INTEGER64:
1886 case AVP_TYPE_UNSIGNED32:
1887 case AVP_TYPE_UNSIGNED64:
1888 case AVP_TYPE_FLOAT32:
1889 case AVP_TYPE_FLOAT64:
1890 CHECK_FCT_DO( fd_msg_avp_setvalue(avp, &val), return NULL );
1891 /* For AVP_TYPE_GROUPED we don't do anything */
1892 }
1893
1894 return avp;
1869 } 1895 }
1870 1896
1871 /* Check that a list of AVPs is compliant with a given rule -- will be iterated on the list of rules */ 1897 /* Check that a list of AVPs is compliant with a given rule -- will be iterated on the list of rules */
1872 static int parserules_check_one_rule(void * data, struct dict_rule_data *rule) 1898 static int parserules_check_one_rule(void * data, struct dict_rule_data *rule)
1873 { 1899 {
2053 2079
2054 int fd_msg_parse_rules ( msg_or_avp * object, struct dictionary * dict, struct fd_pei *error_info) 2080 int fd_msg_parse_rules ( msg_or_avp * object, struct dictionary * dict, struct fd_pei *error_info)
2055 { 2081 {
2056 TRACE_ENTRY("%p %p %p", object, dict, error_info); 2082 TRACE_ENTRY("%p %p %p", object, dict, error_info);
2057 2083
2084 if (error_info)
2085 memset(error_info, 0, sizeof(struct fd_pei));
2086
2058 /* Resolve the dictionary objects when missing. This also validates the object. */ 2087 /* Resolve the dictionary objects when missing. This also validates the object. */
2059 CHECK_FCT( fd_msg_parse_dict ( object, dict ) ); 2088 CHECK_FCT( fd_msg_parse_dict ( object, dict ) );
2060
2061 if (error_info)
2062 memset(error_info, 0, sizeof(struct fd_pei));
2063 2089
2064 /* Call the recursive function */ 2090 /* Call the recursive function */
2065 return parserules_do ( dict, object, error_info, 1 ) ; 2091 return parserules_do ( dict, object, error_info, 1 ) ;
2066 } 2092 }
2067 2093
2184 CHECK_FCT_DO( ret = fd_dict_getdict( cmd, &dict ), goto error ); 2210 CHECK_FCT_DO( ret = fd_dict_getdict( cmd, &dict ), goto error );
2185 CHECK_FCT_DO( ret = fd_dict_search( dict, DICT_APPLICATION, APPLICATION_BY_ID, &(*msg)->msg_public.msg_appl, &app, 0 ), goto error ); 2211 CHECK_FCT_DO( ret = fd_dict_search( dict, DICT_APPLICATION, APPLICATION_BY_ID, &(*msg)->msg_public.msg_appl, &app, 0 ), goto error );
2186 2212
2187 if (app == NULL) { 2213 if (app == NULL) {
2188 /* In that case, maybe we should answer a DIAMETER_APPLICATION_UNSUPPORTED error ? Do we do this here ? */ 2214 /* In that case, maybe we should answer a DIAMETER_APPLICATION_UNSUPPORTED error ? Do we do this here ? */
2189 TRACE_DEBUG(NONE, "Reply DIAMETER_APPLICATION_UNSUPPORTED if it's a request ?"); 2215 TODO("Reply DIAMETER_APPLICATION_UNSUPPORTED if it's a request ?");
2190 } 2216 }
2191 2217
2192 /* So start browsing the message */ 2218 /* So start browsing the message */
2193 CHECK_FCT_DO( ret = fd_msg_browse( *msg, MSG_BRW_FIRST_CHILD, &avp, NULL ), goto error ); 2219 CHECK_FCT_DO( ret = fd_msg_browse( *msg, MSG_BRW_FIRST_CHILD, &avp, NULL ), goto error );
2194 while (avp != NULL) { 2220 while (avp != NULL) {
"Welcome to our mercurial repository"