Changeset 764:f53e5b5fdfd3 in freeDiameter for libfdproto
- Timestamp:
- Oct 19, 2011, 6:00:51 AM (13 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libfdproto/dictionary.c
r740 r764 1837 1837 } 1838 1838 1839 /* Function to retrieve list of objects in the dictionary. Use with care (read only). 1840 1841 All returned list must be accessed like this: 1842 1843 for (li = sentinel->next; li=li->next; li != sentinel) { 1844 struct dict_object * obj = li->o; 1845 ... 1846 } 1847 1848 The following criteria are allowed, with corresponding parent. 1849 The parent is either struct dictionary * or struct dict_object * 1850 1851 VENDOR_BY_ID : (parent = dictionary) returns list of vendors ordered by ID 1852 APPLICATION_BY_ID : (parent = dictionary) returns list of applications ordered by ID 1853 ** for these two lists, the Vendor with id 0 and applciation with id 0 are excluded. 1854 You must resolve them separatly with dict_search. 1855 1856 TYPE_BY_NAME : (parent = dictionary) returns list of types ordered by name 1857 ENUMVAL_BY_NAME : (parent = type object) return list of constants for this type ordered by name 1858 ENUMVAL_BY_VALUE : (parent = type object) return list of constants for this type ordered by values 1859 AVP_BY_NAME : (parent = vendor object) return list of AVP for this vendor ordered by name 1860 AVP_BY_CODE : (parent = vendor object) return list of AVP for this vendor ordered by code 1861 CMD_BY_NAME : (parent = dictionary) returns list of commands ordered by name 1862 CMD_BY_CODE_R : (parent = dictionary) returns list of commands ordered by code 1863 RULE_BY_AVP_AND_PARENT: (parent = command or grouped AVP object) return list of rules for this object ordered by AVP vendor/code 1864 1865 All other criteria are rejected. 1866 */ 1867 int fd_dict_getlistof(int criteria, void * parent, struct fd_list * sentinel) 1868 { 1869 struct dictionary * dict = parent; 1870 struct dict_object * obj_parent = parent; 1871 1872 TRACE_ENTRY("%i %p %p", criteria, parent, sentinel); 1873 1874 CHECK_PARAMS(sentinel && parent); 1875 1876 switch(criteria) { 1877 case VENDOR_BY_ID: /* parent must be the dictionary */ 1878 CHECK_PARAMS(dict->dict_eyec == DICT_EYECATCHER); 1879 sentinel = &dict->dict_vendors.list[0]; 1880 break; 1881 1882 case APPLICATION_BY_ID: /* parent must be the dictionary */ 1883 CHECK_PARAMS(dict->dict_eyec == DICT_EYECATCHER); 1884 sentinel = &dict->dict_applications.list[0]; 1885 break; 1886 1887 case TYPE_BY_NAME: /* parent must be the dictionary */ 1888 CHECK_PARAMS(dict->dict_eyec == DICT_EYECATCHER); 1889 sentinel = &dict->dict_types; 1890 break; 1891 1892 case ENUMVAL_BY_NAME: /* parent must be a type object */ 1893 CHECK_PARAMS(verify_object(obj_parent) && (obj_parent->type == DICT_TYPE)); 1894 sentinel = &obj_parent->list[1]; 1895 break; 1896 1897 case ENUMVAL_BY_VALUE: /* parent must be a type object */ 1898 CHECK_PARAMS(verify_object(obj_parent) && (obj_parent->type == DICT_TYPE)); 1899 sentinel = &obj_parent->list[2]; 1900 break; 1901 1902 case AVP_BY_NAME: /* parent must be a AVP object */ 1903 CHECK_PARAMS(verify_object(obj_parent) && (obj_parent->type == DICT_AVP)); 1904 sentinel = &obj_parent->list[2]; 1905 break; 1906 1907 case AVP_BY_CODE: /* parent must be a AVP object */ 1908 CHECK_PARAMS(verify_object(obj_parent) && (obj_parent->type == DICT_AVP)); 1909 sentinel = &obj_parent->list[1]; 1910 break; 1911 1912 case CMD_BY_NAME: /* parent must be the dictionary */ 1913 CHECK_PARAMS(dict->dict_eyec == DICT_EYECATCHER); 1914 sentinel = &dict->dict_cmd_name; 1915 break; 1916 1917 case CMD_BY_CODE_R: /* parent must be the dictionary */ 1918 CHECK_PARAMS(dict->dict_eyec == DICT_EYECATCHER); 1919 sentinel = &dict->dict_cmd_code; 1920 break; 1921 1922 case RULE_BY_AVP_AND_PARENT: /* parent must be command or grouped AVP */ 1923 CHECK_PARAMS(verify_object(obj_parent)); 1924 CHECK_PARAMS( (obj_parent->type == DICT_COMMAND) || 1925 ((obj_parent->type == DICT_AVP) 1926 && (obj_parent->data.avp.avp_basetype == AVP_TYPE_GROUPED)) ); 1927 sentinel = &obj_parent->list[2]; 1928 break; 1929 1930 default: 1931 CHECK_PARAMS(0); 1932 } 1933 1934 return 0; 1935 } 1936 1839 1937 /*******************************************************************************************************/ 1840 1938 /*******************************************************************************************************/
Note: See TracChangeset
for help on using the changeset viewer.