Changes in libfdproto/messages.c [1001:d03f7e3805ad:995:2016a0c46bda] in freeDiameter
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libfdproto/messages.c
r1001 r995 303 303 static int bufferize_avp(unsigned char * buffer, size_t buflen, size_t * offset, struct avp * avp); 304 304 static int parsebuf_list(unsigned char * buf, size_t buflen, struct fd_list * head); 305 static int parsedict_do_chain(struct dictionary * dict, struct fd_list * head, int mandatory, struct fd_pei *error_info);306 307 305 308 306 /* Create answer from a request */ … … 368 366 if (! (flags & MSGFL_ANSW_NOPROXYINFO)) { 369 367 struct avp * avp; 370 struct fd_pei pei;371 struct fd_list avpcpylist = FD_LIST_INITIALIZER(avpcpylist);372 373 368 CHECK_FCT( fd_msg_browse(qry, MSG_BRW_FIRST_CHILD, &avp, NULL) ); 374 369 while (avp) { … … 381 376 size_t offset = 0; 382 377 383 /* Create a buffer with the content of the AVP. This is easier than going through the list */384 378 CHECK_FCT( fd_msg_update_length(avp) ); 385 379 CHECK_MALLOC( buf = malloc(avp->avp_public.avp_len) ); 386 380 CHECK_FCT( bufferize_avp(buf, avp->avp_public.avp_len, &offset, avp) ); 387 381 388 /* Now we parse this buffer to create a copy AVP */ 389 CHECK_FCT( parsebuf_list(buf, avp->avp_public.avp_len, &avpcpylist) ); 390 391 /* Parse dictionary objects now to remove the dependency on the buffer */ 392 CHECK_FCT( parsedict_do_chain(dict, &avpcpylist, 0, &pei) ); 382 /* Now we directly parse this buffer into the new message list */ 383 CHECK_FCT( parsebuf_list(buf, avp->avp_public.avp_len, &ans->msg_chain.children) ); 393 384 394 385 /* Done for this AVP */ 395 386 free(buf); 396 397 /* We move this AVP now so that we do not parse again in next loop */398 fd_list_move_end(&ans->msg_chain.children, &avpcpylist);399 387 } 400 388 /* move to next AVP in the message, we can have several Proxy-Info instances */ 401 389 CHECK_FCT( fd_msg_browse(avp, MSG_BRW_NEXT, &avp, NULL) ); 402 390 } 391 CHECK_FCT( fd_msg_parse_dict( ans, dict, NULL ) ); 403 392 } 404 393 … … 1569 1558 CHECK_PARAMS( avp->avp_source || avp->avp_rawdata ); 1570 1559 1571 if ( avp->avp_rawdata != NULL ) { 1572 /* the content was stored in rawdata */ 1573 memcpy(&buffer[*offset], avp->avp_rawdata, avp->avp_rawlen); 1574 *offset += PAD4(avp->avp_rawlen); 1575 } else { 1560 if ( avp->avp_source != NULL ) { 1576 1561 /* the message was not parsed completely */ 1577 1562 size_t datalen = avp->avp_public.avp_len - GETAVPHDRSZ(avp->avp_public.avp_flags); 1578 1563 memcpy(&buffer[*offset], avp->avp_source, datalen); 1579 1564 *offset += PAD4(datalen); 1565 } else { 1566 /* the content was stored in rawdata */ 1567 memcpy(&buffer[*offset], avp->avp_rawdata, avp->avp_rawlen); 1568 *offset += PAD4(avp->avp_rawlen); 1580 1569 } 1581 1570 … … 1824 1813 */ 1825 1814 1815 static int parsedict_do_chain(struct dictionary * dict, struct fd_list * head, int mandatory, struct fd_pei *error_info); 1816 1826 1817 static char error_message[256]; 1827 1818 … … 1830 1821 { 1831 1822 struct dict_avp_data dictdata; 1832 uint8_t * source;1833 1823 1834 1824 TRACE_ENTRY("%p %p %d %p", dict, avp, mandatory, error_info); … … 1923 1913 } 1924 1914 1925 source = avp->avp_source;1926 avp->avp_source = NULL;1927 1928 1915 /* Now get the value inside */ 1929 1916 switch (dictdata.avp_basetype) { … … 1932 1919 1933 1920 /* This is a grouped AVP, so let's parse the list of AVPs inside */ 1934 CHECK_FCT_DO( ret = parsebuf_list( source, avp->avp_public.avp_len - GETAVPHDRSZ( avp->avp_public.avp_flags ), &avp->avp_chain.children),1921 CHECK_FCT_DO( ret = parsebuf_list(avp->avp_source, avp->avp_public.avp_len - GETAVPHDRSZ( avp->avp_public.avp_flags ), &avp->avp_chain.children), 1935 1922 { 1936 1923 if ((ret == EBADMSG) && (error_info)) { … … 1940 1927 error_info->pei_message = error_message; 1941 1928 } 1942 avp->avp_source = source;1943 1929 return ret; 1944 1930 } ); … … 1955 1941 error_info->pei_avp = avp; 1956 1942 } 1957 avp->avp_source = source;1958 1943 return EBADMSG; 1959 1944 } ); 1960 1945 avp->avp_storage.os.len = avp->avp_public.avp_len - GETAVPHDRSZ( avp->avp_public.avp_flags ); 1961 CHECK_MALLOC( avp->avp_storage.os.data = os0dup( source, avp->avp_storage.os.len) );1946 CHECK_MALLOC( avp->avp_storage.os.data = os0dup(avp->avp_source, avp->avp_storage.os.len) ); 1962 1947 avp->avp_mustfreeos = 1; 1963 1948 break; 1964 1949 1965 1950 case AVP_TYPE_INTEGER32: 1966 avp->avp_storage.i32 = (int32_t)ntohl(*(uint32_t *) source);1951 avp->avp_storage.i32 = (int32_t)ntohl(*(uint32_t *)avp->avp_source); 1967 1952 break; 1968 1953 … … 1971 1956 { 1972 1957 uint64_t __stor; 1973 memcpy(&__stor, source, sizeof(__stor));1958 memcpy(&__stor, avp->avp_source, sizeof(__stor)); 1974 1959 avp->avp_storage.i64 = (int64_t)ntohll(__stor); 1975 1960 } … … 1978 1963 case AVP_TYPE_UNSIGNED32: 1979 1964 case AVP_TYPE_FLOAT32: /* For float, we must not cast, or the value is changed. Instead we use implicit cast by changing the member of the union */ 1980 avp->avp_storage.u32 = (uint32_t)ntohl(*(uint32_t *) source);1965 avp->avp_storage.u32 = (uint32_t)ntohl(*(uint32_t *)avp->avp_source); 1981 1966 break; 1982 1967 … … 1985 1970 { 1986 1971 uint64_t __stor; 1987 memcpy(&__stor, source, sizeof(__stor));1972 memcpy(&__stor, avp->avp_source, sizeof(__stor)); 1988 1973 avp->avp_storage.u64 = (uint64_t)ntohll(__stor); 1989 1974 }
Note: See TracChangeset
for help on using the changeset viewer.