mirror of https://gerrit.osmocom.org/asn1c
Compare commits
760 Commits
3G_2016_09
...
master
Author | SHA1 | Date |
---|---|---|
Johannes Lode | 9925dbbda8 | |
Johannes Lode | 35ad7e6daa | |
Tim Gates | 4195e8f961 | |
Lev Walkin | 00fa516f3c | |
Damir Franusic | 6db79fd18b | |
fei4xu | 878dc3b383 | |
Lev Walkin | 46b394dd3e | |
Rob Stradling | ca8145766c | |
Lev Walkin | c7abb8e9bb | |
Shad Ansari | fdb68ce278 | |
Jonathan D. Storm | b361194599 | |
Lev Walkin | 6495ca558e | |
Lev Walkin | 88ed3b5cf0 | |
Lev Walkin | ad7462c561 | |
Lev Walkin | 0d536ce2f1 | |
Lev Walkin | 117e72bc51 | |
Bi-Ruei, Chiu | 2eba107955 | |
Russ Kubik | d8fee36d2f | |
Russ Kubik | 3ce07b9e69 | |
Russ Kubik | 94d87940c8 | |
Lev Walkin | 47cb79f007 | |
Lev Walkin | 2e2cb79035 | |
Lev Walkin | ee50d8750f | |
Lev Walkin | 0906e58b81 | |
Lev Walkin | f8b6e73a05 | |
Dave Cridland | cffe1b112a | |
Lev Walkin | 6ccf7437af | |
Lev Walkin | ccfaf2ab89 | |
Lev Walkin | 8e1d7591ab | |
Lev Walkin | b47d1adac3 | |
Lev Walkin | 4cc779fd9b | |
Lev Walkin | 57cf20953e | |
Lev Walkin | 4bc278d043 | |
Lev Walkin | 3eb2703268 | |
Lev Walkin | bbe79251e7 | |
Lev Walkin | 840fb8e37b | |
Lev Walkin | 4215c51ca3 | |
Lev Walkin | da672c4130 | |
Lev Walkin | 4645db0707 | |
Lev Walkin | 34df4e5799 | |
Jon Ringle | 3aa33c032e | |
Jon Ringle | 1029a6ec9b | |
Jon Ringle | 3016fd59fe | |
Jon Ringle | f71745aa7a | |
Jon Ringle | 6431b1c969 | |
Jon Ringle | 7871abf7ef | |
Lev Walkin | 07f8c3eaf5 | |
Lev Walkin | 686f38bf94 | |
Lev Walkin | 37b579919d | |
Lev Walkin | d0ee2b1436 | |
Lev Walkin | 304a70e9ac | |
Bi-Ruei, Chiu | 288e95d5b1 | |
Lev Walkin | f9a94dfa1d | |
Lev Walkin | f09cf4888d | |
Lev Walkin | d3fd7a4bdf | |
Lev Walkin | e7bd48aa5e | |
Lev Walkin | 076bbbc7ab | |
Lev Walkin | 2a923864b9 | |
Bi-Ruei, Chiu | 0299037ed8 | |
Bi-Ruei, Chiu | 8ae074ce79 | |
Lev Walkin | 7d5d930393 | |
Lev Walkin | 30566d1310 | |
Lev Walkin | 227b944558 | |
Lev Walkin | d1c28aa809 | |
Lev Walkin | d5f6647fc5 | |
Lev Walkin | 3be4919d01 | |
Lev Walkin | 5f4dbb751a | |
Lev Walkin | 9ce64c13c7 | |
Lev Walkin | 933b950a80 | |
Lev Walkin | cf573ec13c | |
Lev Walkin | ec4b7af9ef | |
Lev Walkin | d5627a1f11 | |
Lev Walkin | f3334585a7 | |
Lev Walkin | 08661a6508 | |
Lev Walkin | 1fc5edb22d | |
Lev Walkin | cd8f1e0377 | |
Lev Walkin | 1a49ced90e | |
Lev Walkin | a67d11061e | |
Lev Walkin | adfcde29cd | |
Jon Ringle | 3bcab4ebfa | |
Lev Walkin | 8baaf6b0d2 | |
Lev Walkin | ce2068a507 | |
Lev Walkin | c9b2f28b98 | |
Lev Walkin | 3f52df00df | |
Lev Walkin | ee8482a55d | |
Lev Walkin | a53bdf16a0 | |
Lev Walkin | f22184d31c | |
Lev Walkin | 5e73c5058b | |
Lev Walkin | 1351752f8d | |
Vasil Velichkov | 24354e1cd0 | |
Vasil Velichkov | b623e8d701 | |
Vasil Velichkov | abb7133c23 | |
Vasil Velichkov | 5fcbb2868d | |
Lev Walkin | 6fd84337a5 | |
Lev Walkin | 3bbbd04155 | |
Bi-Ruei, Chiu | 2387ff39ae | |
Bi-Ruei, Chiu | 5bdb55552f | |
Lev Walkin | 7156898e45 | |
Lev Walkin | d8e6bbfa9a | |
Lev Walkin | 52b88e1b54 | |
Lev Walkin | e5f0d94aa9 | |
Lev Walkin | 9175a28a5a | |
Lev Walkin | 5615304c9a | |
Lev Walkin | cb59ce69a8 | |
Lev Walkin | 005f8799b1 | |
Lev Walkin | b2219ac657 | |
Lev Walkin | ddac40017f | |
Lev Walkin | 3ca48b9168 | |
Lev Walkin | b1d4102cd3 | |
Lev Walkin | 9f470d60fa | |
Lev Walkin | df2edbbd15 | |
Lev Walkin | d2a7360685 | |
Lev Walkin | 62155df04d | |
Lev Walkin | 3c37385d29 | |
Lev Walkin | 836686167d | |
Lev Walkin | 5de8274266 | |
Lev Walkin | ba2c5727d0 | |
Lev Walkin | 1418d985cb | |
Bi-Ruei, Chiu | bc6ef1f98a | |
Bi-Ruei, Chiu | e460c3b7a3 | |
Bi-Ruei, Chiu | 156b0feb5c | |
Bi-Ruei, Chiu | dcc822a090 | |
Bi-Ruei, Chiu | 3e2de6960b | |
Bi-Ruei, Chiu | 214c491951 | |
Bi-Ruei, Chiu | 89cde74d4a | |
Bi-Ruei, Chiu | b6bd8d788b | |
Bi-Ruei, Chiu | 742a196624 | |
Bi-Ruei, Chiu | 069c07657e | |
Bi-Ruei, Chiu | aeff717baf | |
Bi-Ruei, Chiu | 50934ba3d4 | |
Lev Walkin | 4e5edcf063 | |
Lev Walkin | 6bc5696f52 | |
Lev Walkin | d14802fa0f | |
Lev Walkin | 9d328eec0a | |
Lev Walkin | 42f6c88018 | |
Lev Walkin | a460cbd13e | |
Lev Walkin | 130cffe9a9 | |
Lev Walkin | 312e3e0f96 | |
Lev Walkin | 1d2a6e8b3f | |
Lev Walkin | 435469ec33 | |
Lev Walkin | c547661e3c | |
Lev Walkin | b1f4f33ae6 | |
Lev Walkin | 0afbd325f3 | |
Lev Walkin | 48e82d1f1f | |
Lev Walkin | b2d896e4d9 | |
Lev Walkin | bc09dd4845 | |
Lev Walkin | 4bd9eaf7e1 | |
Lev Walkin | 0a3bf61d0d | |
Lev Walkin | 1fef87a46f | |
Lev Walkin | 03531df897 | |
Vasil Velichkov | d346ffd810 | |
Vasil Velichkov | 72b104470e | |
Vasil Velichkov | 97656bdd11 | |
Vasil Velichkov | c8bc573f06 | |
Vasil Velichkov | 3d3af67a37 | |
Vasil Velichkov | 51612b2361 | |
Vasil Velichkov | 3875d507d9 | |
Vasil Velichkov | e56f4b24d4 | |
Vasil Velichkov | e60e6f225a | |
Vasil Velichkov | c3e0019b56 | |
Vasil Velichkov | 39ab82f36d | |
Vasil Velichkov | 6aac1c3c16 | |
Vasil Velichkov | 12e91c9d3f | |
Vasil Velichkov | 6cec1afb4e | |
Vasil Velichkov | d06dc0920b | |
Lev Walkin | b37ee63992 | |
Lev Walkin | 1bde6d4d7a | |
Lev Walkin | 1c0ce5e1d1 | |
Lev Walkin | 61b4be0e4c | |
Lev Walkin | 19e12b5597 | |
Lev Walkin | 249fd26063 | |
Lev Walkin | 0b56b22ca5 | |
Lev Walkin | 04ca1b5293 | |
Lev Walkin | af51eafe31 | |
Lev Walkin | 623986ac6a | |
Lev Walkin | 20696a4ff3 | |
Lev Walkin | 37231fb195 | |
Lev Walkin | f585ad62b5 | |
Lev Walkin | f918398e77 | |
Lev Walkin | 5754545305 | |
Lev Walkin | 312795a24c | |
Lev Walkin | 7193cf069f | |
Lev Walkin | 22cef6cb93 | |
Lev Walkin | e4a1625ad2 | |
Lev Walkin | 2d824a6976 | |
Lev Walkin | ace43a3fcc | |
Lev Walkin | dd01a5e54c | |
Lev Walkin | 2ed11835b7 | |
Lev Walkin | 349b340767 | |
Lev Walkin | 588bf0f7dc | |
Lev Walkin | 290e2c7f46 | |
Lev Walkin | b5b524b1d0 | |
Lev Walkin | 1ff89d3fa4 | |
Jon Ringle | 0770393d22 | |
Lev Walkin | f11ebf8a5b | |
Vasil Velichkov | 83170fc089 | |
Vasil Velichkov | aead8c5f68 | |
Vasil Velichkov | 84dd0fef6f | |
Vasil Velichkov | edd82a9686 | |
Vasil Velichkov | fc25d5e708 | |
Vasil Velichkov | cef21e07ac | |
Vasil Velichkov | 5532a1d6cc | |
Lev Walkin | d0d63928af | |
Lev Walkin | 490064f12a | |
Lev Walkin | ac6db177de | |
Lev Walkin | 294aebc7f2 | |
Lev Walkin | 8f5017645b | |
Lev Walkin | 758aeaddfb | |
Lev Walkin | e24bad1a56 | |
Lev Walkin | 42a94cbc30 | |
Lev Walkin | c346f90373 | |
Lev Walkin | ebeb401513 | |
Lev Walkin | 121ad66245 | |
Lev Walkin | 40bb23cbc3 | |
Lev Walkin | c143b7a26e | |
Lev Walkin | b98c77131b | |
Lev Walkin | ed93977dfa | |
Lev Walkin | d20f174624 | |
Lev Walkin | 40b8a7ae99 | |
Lev Walkin | 45bae08c71 | |
Lev Walkin | a4f8e94bc1 | |
Lev Walkin | e2bbbf8f1e | |
Lev Walkin | c36803785e | |
Lev Walkin | 226d107945 | |
Lev Walkin | 2225674d46 | |
Lev Walkin | 1f05facc8c | |
Lev Walkin | 09be69c010 | |
Lev Walkin | 8e71151267 | |
Lev Walkin | 68079d3861 | |
Lev Walkin | ab25f195ce | |
Lev Walkin | 7c470c7cb4 | |
Lev Walkin | 60d6267811 | |
Lev Walkin | 63a89da5ec | |
Lev Walkin | 6cbed3dd61 | |
Lev Walkin | cc6a76b2d6 | |
Lev Walkin | fa9a326d54 | |
Lev Walkin | fe37431038 | |
Lev Walkin | 9d6ba1c805 | |
Lev Walkin | b7c5899615 | |
Lev Walkin | 6bdd8c0ae1 | |
Lev Walkin | 85d7a1b3d8 | |
Bi-Ruei, Chiu | 3ed43b2539 | |
Lev Walkin | f58f1fccee | |
Lev Walkin | 39936ce6b9 | |
Lev Walkin | a06b1b4ddf | |
Lev Walkin | d28b45fd93 | |
Lev Walkin | 9cbf678474 | |
Lev Walkin | ad4c63dad3 | |
Lev Walkin | fb46912955 | |
Lev Walkin | d839785d25 | |
Lev Walkin | 945958e01e | |
Lev Walkin | 4329272a64 | |
Lev Walkin | afcc891c86 | |
Lev Walkin | cb5e1c7c87 | |
Lev Walkin | d2f9b36251 | |
Lev Walkin | 7ae067895d | |
Jon Ringle | 35c3f0d6fc | |
Lev Walkin | c44edc0df4 | |
Lev Walkin | 9854e66932 | |
Lev Walkin | b5450704fe | |
Lev Walkin | 026e21abe1 | |
Lev Walkin | 4ca4149c96 | |
Lev Walkin | ab1d1e1ea4 | |
Lev Walkin | 68619bf6ef | |
Lev Walkin | aa5838cb70 | |
Lev Walkin | 93f372b89c | |
Lev Walkin | cec390d510 | |
Lev Walkin | 324fb0b6ab | |
Lev Walkin | d84f603285 | |
Lev Walkin | aa067a9875 | |
Lev Walkin | 67afc36530 | |
Lev Walkin | fe8c6b7eac | |
Lev Walkin | 8cec5235c6 | |
Lev Walkin | b450ce9b92 | |
Lev Walkin | 5d947a879e | |
Lev Walkin | e0d9f2b71b | |
Lev Walkin | 791d3b7725 | |
Lev Walkin | ceae6ed514 | |
Lev Walkin | 793982a581 | |
Lev Walkin | f5e333e92d | |
Lev Walkin | be0e55dd9f | |
Lev Walkin | d597f0dda7 | |
Lev Walkin | 963ef133d2 | |
Lev Walkin | b458fc0afd | |
Lev Walkin | 233d14dbe3 | |
Lev Walkin | a5b0288ccf | |
Lev Walkin | d17cf888e5 | |
Lev Walkin | 9d1b45f8ac | |
Lev Walkin | ce6b0a66de | |
Lev Walkin | f2e12c391b | |
Lev Walkin | 360b20593d | |
Lev Walkin | 4d8b748417 | |
Lev Walkin | 3e3f61afb7 | |
Lev Walkin | d3cce46d77 | |
Lev Walkin | a25584bab7 | |
Lev Walkin | 18741a96a3 | |
Lev Walkin | 87998b83e4 | |
Lev Walkin | cb52391432 | |
Lev Walkin | d7a740c3f4 | |
Lev Walkin | 58b383e7c7 | |
Lev Walkin | b518668220 | |
Lev Walkin | 6527a43a5f | |
Lev Walkin | 15734f9a06 | |
Lev Walkin | bf09bf76eb | |
Lev Walkin | 0bfea56d08 | |
Lev Walkin | a5972bedae | |
Lev Walkin | 6d69204622 | |
Lev Walkin | 14e75ed755 | |
Lev Walkin | c7a2101a2e | |
Lev Walkin | 9059af457b | |
Lev Walkin | ff92aa3b9d | |
Lev Walkin | c8a0b9dded | |
Lev Walkin | 84556d50b2 | |
Lev Walkin | 15b26e6d50 | |
Lev Walkin | ad775916a7 | |
Lev Walkin | 8a85b36d93 | |
Lev Walkin | 478819d6eb | |
Lev Walkin | f3f7f9427c | |
Lev Walkin | 33897e2ee9 | |
Lev Walkin | 1900888569 | |
Lev Walkin | a4f689122f | |
Lev Walkin | 16555a1e17 | |
Lev Walkin | 0479e04dd7 | |
Lev Walkin | 1711a5dd0e | |
Lev Walkin | 6171cd02d4 | |
Lev Walkin | 2e93c223da | |
Lev Walkin | 3f99563146 | |
Lev Walkin | 09c8730753 | |
Lev Walkin | 5230c64b7c | |
Lev Walkin | 42457fe974 | |
Lev Walkin | ed409e2b75 | |
Lev Walkin | 47fc74ca76 | |
Bi-Ruei, Chiu | 59b1bc8e90 | |
Lev Walkin | ef8dd441fc | |
Lev Walkin | 3eeafe127e | |
Lev Walkin | 3b327a8e6f | |
Lev Walkin | 20e22eb33b | |
Lev Walkin | 229ad00835 | |
Lev Walkin | dcae9cea97 | |
Lev Walkin | c8c286ab11 | |
Lev Walkin | 4fe2882262 | |
Lev Walkin | 7489807aa7 | |
Lev Walkin | a75b247f72 | |
Lev Walkin | 0368c628ee | |
Lev Walkin | e835b3ad41 | |
Lev Walkin | 547973dc3a | |
Lev Walkin | 38a91df0fc | |
Lev Walkin | a9e63373e5 | |
Lev Walkin | 9318004694 | |
Lev Walkin | 0995f351ec | |
Lev Walkin | beedbdeb6e | |
Lev Walkin | 38306e1054 | |
Lev Walkin | 9c57f33a0b | |
Lev Walkin | 642b92f3fe | |
Lev Walkin | e0236da7cd | |
Lev Walkin | 7b04d79348 | |
Lev Walkin | 58dd8c868f | |
Lev Walkin | d5142d4cc3 | |
Lev Walkin | 9368263165 | |
Lev Walkin | 1a364656a6 | |
Lev Walkin | 07a50d8e3e | |
Lev Walkin | 387a8f01c9 | |
Lev Walkin | b5cdc5d2d9 | |
Lev Walkin | 5c600f4c16 | |
Lev Walkin | 24cf97dc1c | |
Lev Walkin | cb4eddbe1c | |
Denis Filatov | bbb631383a | |
Lev Walkin | e29a30e702 | |
Lev Walkin | 50bf4bac94 | |
Lev Walkin | 4084658614 | |
Lev Walkin | 0f5dd34dc3 | |
Lev Walkin | eff98a506c | |
Lev Walkin | dfbff614e3 | |
Denis Filatov | e1e42073b7 | |
Lev Walkin | 81d6c576cc | |
Lev Walkin | 6a0b36347c | |
Lev Walkin | 07906c7b6f | |
Lev Walkin | 2f186081a5 | |
Lev Walkin | 0f77cea7fe | |
Lev Walkin | 399f1cf764 | |
Lev Walkin | afbf2a9828 | |
Lev Walkin | 9dc9f67acd | |
Lev Walkin | 5626bc117a | |
Lev Walkin | f8627fa38f | |
Lev Walkin | e8bbe93ade | |
Lev Walkin | 625d4804d8 | |
Lev Walkin | 91da82f471 | |
Lev Walkin | 96d388c567 | |
Lev Walkin | b48bc2f309 | |
Lev Walkin | 0b59763768 | |
Lev Walkin | 6d46bc3da4 | |
Lev Walkin | ffb77b0811 | |
Lev Walkin | 286477433b | |
Lev Walkin | 0cfc865c49 | |
Lev Walkin | 9023deafc9 | |
Lev Walkin | c66ccbcae5 | |
Lev Walkin | f6e04b5522 | |
Lev Walkin | 59165cf2ae | |
Lev Walkin | 2701dc2a2d | |
Lev Walkin | 77f65c9759 | |
Lev Walkin | bf979156ac | |
Lev Walkin | 0c68645c5c | |
Lev Walkin | 2d0effcac2 | |
Lev Walkin | be518fac4c | |
Lev Walkin | 154519a3a7 | |
Lev Walkin | b7a202e567 | |
Lev Walkin | 86526e3fe6 | |
Lev Walkin | 4ef01a249d | |
Lev Walkin | d523ea454d | |
Lev Walkin | 8460940d54 | |
Lev Walkin | 55255f9c95 | |
Lev Walkin | 80c7de80ef | |
Lev Walkin | 61b660f541 | |
Lev Walkin | 774fbdc832 | |
Lev Walkin | 5efafc56b4 | |
Lev Walkin | c17e14e66b | |
Lev Walkin | b46156d9be | |
Lev Walkin | e4ea175004 | |
Lev Walkin | fe4e047ee7 | |
Lev Walkin | c280c80452 | |
Lev Walkin | 1a503896a5 | |
Lev Walkin | 28ba9db629 | |
Lev Walkin | 3b6cba5717 | |
Lev Walkin | 09bec4606c | |
Lev Walkin | 71191ba9f0 | |
Lev Walkin | fc89b9d2bc | |
Lev Walkin | f4e9943bc5 | |
Lev Walkin | e0f2a5b46b | |
Lev Walkin | 6713bcb012 | |
Lev Walkin | 5994072b98 | |
Lev Walkin | cfc16d354a | |
Lev Walkin | aa7c5a635a | |
Lev Walkin | c6bd359a08 | |
Lev Walkin | 96f9921b09 | |
Lev Walkin | 84382cc1f5 | |
Lev Walkin | dfc9314a6d | |
Lev Walkin | 290b4d6918 | |
Ryan Sleevi | a93d9971d2 | |
Ryan Sleevi | ae8a6e4de5 | |
Lev Walkin | 135d7dd4e1 | |
Lev Walkin | 0c54f3d05d | |
Lev Walkin | 94fc4186de | |
Lev Walkin | 20dc624722 | |
Lev Walkin | 9a1736da96 | |
Lev Walkin | 2535bd58f3 | |
Lev Walkin | aa7e94fe23 | |
Lev Walkin | f9f3e06e21 | |
Lev Walkin | 049a2d7da7 | |
Lev Walkin | 090262fd42 | |
Lev Walkin | a926fce4ce | |
Lev Walkin | 0c050a81d4 | |
Lev Walkin | d3fbff9552 | |
Lev Walkin | 878a521e2b | |
Lev Walkin | 14fd3e5a89 | |
Lev Walkin | 026055ff81 | |
Lev Walkin | a4db2afee3 | |
Lev Walkin | 53657ddc14 | |
Lev Walkin | 75b6fe4c8c | |
Lev Walkin | 4ccce3da61 | |
Lev Walkin | c10d30a30f | |
Lev Walkin | 2e5caa514c | |
Lev Walkin | 8ac82227d4 | |
Lev Walkin | 35ace19d51 | |
Lev Walkin | 7bb9d5b167 | |
Lev Walkin | a4a87215b5 | |
Lev Walkin | f59dac9887 | |
Lev Walkin | 5a0436c80a | |
Lev Walkin | ae0c3c27e9 | |
Lev Walkin | 9d2b0443b6 | |
Lev Walkin | 95d3ac9bd2 | |
Lev Walkin | 8c44dffec9 | |
Lev Walkin | 122002e3a7 | |
Lev Walkin | eb00dfabfc | |
Lev Walkin | 02bfad269c | |
Lev Walkin | 38a5a20de0 | |
Lev Walkin | 2481002575 | |
Lev Walkin | 6903380f0b | |
Lev Walkin | 6cd0d567f0 | |
Lev Walkin | 1f4ed23aa1 | |
Lev Walkin | 8d99d7b5c8 | |
Lev Walkin | 56d59b46c0 | |
Lev Walkin | ca0d40ba21 | |
Lev Walkin | 7765d4171a | |
Lev Walkin | 23a82d9d02 | |
Lev Walkin | 41d972b80f | |
Bi-Ruei, Chiu | 1f87ac0058 | |
Lev Walkin | fadb26aaf1 | |
Lev Walkin | a7d64001d6 | |
Lev Walkin | f04d4e42d7 | |
Lev Walkin | 53e5ae6524 | |
Lev Walkin | 8c060139a0 | |
Lev Walkin | e391708ff1 | |
Lev Walkin | ade508caed | |
Lev Walkin | bc407267bb | |
Lev Walkin | 53a28a26c4 | |
Lev Walkin | d8e07c5f08 | |
Lev Walkin | a45518f565 | |
Lev Walkin | f4b711a2a9 | |
Lev Walkin | e3204e7d23 | |
Lev Walkin | f75b874253 | |
Lev Walkin | 9ded96c6b2 | |
Lev Walkin | cf3f6ebb9f | |
Lev Walkin | 792641eed2 | |
Bi-Ruei, Chiu | e1bf21933e | |
Lev Walkin | e9050cc9c7 | |
Lev Walkin | d62a662d1f | |
Lev Walkin | c336c4ac8a | |
Lev Walkin | 36ddfc8e37 | |
Lev Walkin | c0e03b946e | |
Lev Walkin | 9772177803 | |
Lev Walkin | d9221847e5 | |
Lev Walkin | db33c8dbde | |
Lev Walkin | acdca41847 | |
Lev Walkin | bfdceaf238 | |
Denis Filatov | b298f2d210 | |
Denis Filatov | dbb8990a2b | |
Lev Walkin | 18660d26bb | |
Lev Walkin | 91ca273296 | |
Lev Walkin | 1dc754c529 | |
Lev Walkin | f6853ce38e | |
Lev Walkin | 63a35237b1 | |
Lev Walkin | 6aae7c62c1 | |
Lev Walkin | 24bf3f6af1 | |
Lev Walkin | d357f3d53f | |
Lev Walkin | 83d8b2f2a5 | |
Lev Walkin | 1ff29d9a72 | |
Lev Walkin | 5d929d87c7 | |
Lev Walkin | ec6f7d5a25 | |
Lev Walkin | 700df493dd | |
Lev Walkin | 7c87630180 | |
Lev Walkin | 67a30129f1 | |
Lev Walkin | 9de6cd89ca | |
Lev Walkin | 9ec239e7f7 | |
Lev Walkin | 8354f34bd9 | |
Lev Walkin | cd2f48eb5a | |
Lev Walkin | 086ee9a355 | |
Lev Walkin | ad0d637c90 | |
Lev Walkin | 4dcf8367d9 | |
Lev Walkin | 494fb707a7 | |
Lev Walkin | 6021ec0339 | |
Lev Walkin | d0f7b91eac | |
Lev Walkin | 02da2aab89 | |
Lev Walkin | d748bffbfc | |
Lev Walkin | 8077f93861 | |
Lev Walkin | 63099079dc | |
Lev Walkin | 62d95d2ef4 | |
Lev Walkin | 645d2de9c3 | |
Lev Walkin | ea6635bdae | |
Lev Walkin | e700b208bc | |
Lev Walkin | ecbb8ff34a | |
Lev Walkin | 7e5ea1d080 | |
Lev Walkin | 6bd4b29665 | |
Lev Walkin | 5d20588ef7 | |
Lev Walkin | 2888f6c886 | |
Lev Walkin | d3cc9de01a | |
Lev Walkin | 09ba88d58a | |
Lev Walkin | 62d7687e55 | |
Lev Walkin | a4f3d4670d | |
Lev Walkin | 7268f33f6a | |
Lev Walkin | ebdf02646d | |
Lev Walkin | 92fc0130ac | |
mattipee | e0b99abe50 | |
Lev Walkin | fb35e08884 | |
Lev Walkin | d19216f2f4 | |
Lev Walkin | e29e61270a | |
Lev Walkin | 752e9735d8 | |
Lev Walkin | 691ea048b5 | |
Lev Walkin | da997b1ea1 | |
Lev Walkin | 2b290bef16 | |
Lev Walkin | bc0b0c5062 | |
Bi-Ruei, Chiu | 1fa31c9e3e | |
Lev Walkin | 6bc7a11d9e | |
Lev Walkin | b9e98cbaed | |
Lev Walkin | 17a93cf955 | |
Lev Walkin | c78d04711d | |
Lev Walkin | 322e35e6ec | |
Lev Walkin | 8041fe87b5 | |
Lev Walkin | 4118ccf997 | |
Lev Walkin | 5861e8a08d | |
Lev Walkin | ed1ce785bb | |
Lev Walkin | a28cbb9f66 | |
Lev Walkin | fc4f37a5a2 | |
Lev Walkin | dbdc06725f | |
Lev Walkin | 8aed40c467 | |
Lev Walkin | 01582a7184 | |
Lev Walkin | 6f50a3f737 | |
Lev Walkin | 7e833b6ed4 | |
Lev Walkin | 7eac0df3e7 | |
Lev Walkin | 2d747bdda9 | |
Lev Walkin | e4589f9486 | |
Lev Walkin | b8933edbdc | |
Lev Walkin | 69353a320b | |
Lev Walkin | 1d76f3c4d3 | |
Lev Walkin | ca84c46db9 | |
Lev Walkin | 5f99257c19 | |
Lev Walkin | af4dfaa12a | |
Lev Walkin | 2d10756d75 | |
Lev Walkin | b4776ff2ee | |
Lev Walkin | 3ad1e32b63 | |
Lev Walkin | 1f820ba3c7 | |
Lev Walkin | 6db40f4c49 | |
Lev Walkin | 8b6a8005e0 | |
Lev Walkin | 963fd86536 | |
Lev Walkin | 6cea145da8 | |
Lev Walkin | 3c5d94164c | |
Lev Walkin | 890e6038cc | |
Lev Walkin | 602aacb5ea | |
Lev Walkin | 9ae018ee9c | |
Lev Walkin | 40fa826a49 | |
Lev Walkin | 3fd85d8ae4 | |
Lev Walkin | f573ebbd98 | |
Lev Walkin | a2abcaab2e | |
Lev Walkin | 4a06e6a8eb | |
Lev Walkin | 51a1f3f68b | |
Lev Walkin | 20ea852177 | |
Lev Walkin | 39837e6c26 | |
Lev Walkin | d88bea9b11 | |
Lev Walkin | 98eabc1c82 | |
Lev Walkin | b2284470f9 | |
Lev Walkin | b33425f16b | |
Lev Walkin | cc9b3aebdc | |
Lev Walkin | 527497f791 | |
Lev Walkin | 486fd5cbf5 | |
Lev Walkin | fcfe19b2ae | |
Lev Walkin | e4d8c92142 | |
Lev Walkin | 54f3451609 | |
Lev Walkin | 4558ad0629 | |
Lev Walkin | 099da6ffc1 | |
Lev Walkin | ed3a4ae4ac | |
Lev Walkin | a7a240e8a1 | |
Lev Walkin | 7678076f34 | |
Lev Walkin | e7b73c40da | |
Lev Walkin | cc1594746a | |
Lev Walkin | ba68c91b71 | |
Lev Walkin | a46ab9c15c | |
Lev Walkin | ea200d9be7 | |
Lev Walkin | 1d84ea9862 | |
Lev Walkin | 46ef3f339e | |
Lev Walkin | 80334ed5db | |
Lev Walkin | 38b3e23d9d | |
Lev Walkin | c56b566453 | |
Lev Walkin | 221ce93307 | |
Lev Walkin | ef72650489 | |
Lev Walkin | 233be53854 | |
Lev Walkin | 5d9e3c50b5 | |
Lev Walkin | 72ec909738 | |
Lev Walkin | 5c9c34261c | |
Bi-Ruei, Chiu | 94f0b645d4 | |
Lev Walkin | b02145b206 | |
Lev Walkin | 7e0ab8821d | |
Lev Walkin | 7461a1cf29 | |
Lev Walkin | 6da0272ba2 | |
Lev Walkin | c7b2edb6e4 | |
Lev Walkin | 39248ffb98 | |
Lev Walkin | 4087683d67 | |
Lev Walkin | 90024eeff1 | |
Lev Walkin | aadc1f9f59 | |
Lev Walkin | af8595ad09 | |
Lev Walkin | f4cbbe70e8 | |
Lev Walkin | 993eca8552 | |
Bi-Ruei, Chiu | e68cc22100 | |
johvik | e70c40724c | |
johvik | 28268d9bf2 | |
johvik | bd3dea9b7b | |
johvik | 5f619fb258 | |
Bi-Ruei, Chiu | f1e29c8a9c | |
Bi-Ruei, Chiu | c46137bddd | |
Bi-Ruei, Chiu | 2d6b8c0170 | |
Bi-Ruei, Chiu | 80fd3065f4 | |
Lev Walkin | 4021e4ba62 | |
Lev Walkin | bfa08659c9 | |
Lev Walkin | d3911dfd4d | |
Lev Walkin | 08637ac552 | |
Lev Walkin | 052f3b980d | |
Lev Walkin | 2bb6add14f | |
Bi-Ruei, Chiu | e86ebcff26 | |
Lev Walkin | 49c713b770 | |
Bi-Ruei, Chiu | 3dcf05bbb0 | |
Bi-Ruei, Chiu | 81ac21519b | |
johvik | 792216e97f | |
Lev Walkin | 0eca8c3227 | |
Lev Walkin | efded512e7 | |
Lev Walkin | fa40976f4a | |
Lev Walkin | fbbe4edc8e | |
Lev Walkin | 46fc2bd8c4 | |
Lev Walkin | b2ee65912f | |
Lev Walkin | 8d0585d80e | |
Lev Walkin | 88271a5d7a | |
Lev Walkin | 8a2fb9e110 | |
Lev Walkin | 9c1afcb9c4 | |
Lev Walkin | e0a303922e | |
Lev Walkin | 860de0bc14 | |
Lev Walkin | 04a1a615ce | |
Simo Sorce | 798bacfbbe | |
Simo Sorce | cd943c243d | |
Simo Sorce | e6b650a0d9 | |
Simo Sorce | 9cbd9b850e | |
Lev Walkin | 2bfb34cb9c | |
Lev Walkin | 419f674aff | |
Vasil Velichkov | adf6594053 | |
Vasil Velichkov | 9e935ae7d3 | |
Vasil Velichkov | d82f77b2d2 | |
Vasil Velichkov | 1144b350f3 | |
Vasil Velichkov | 3b434ca548 | |
Vasil Velichkov | e318759ef2 | |
Lev Walkin | b98b286d7b | |
Lev Walkin | 47c8e47506 | |
Lev Walkin | 06a37c85d9 | |
Lev Walkin | 110fc0d802 | |
Lev Walkin | 0ed483dbb6 | |
Lev Walkin | f3a100974d | |
Lev Walkin | e088a2b07a | |
Lev Walkin | 9e0bf1b87a | |
Lev Walkin | 2e8ee8d5be | |
Lev Walkin | 4aa1e96d44 | |
Lev Walkin | fc9687925f | |
Lev Walkin | 7e6775786d | |
Lev Walkin | d27d5b5e72 | |
Lev Walkin | a964e03306 | |
Lev Walkin | fa9bb6dcfd | |
Lev Walkin | 98c6b31eca | |
Lev Walkin | 792b22b912 | |
Lev Walkin | f43b5025ae | |
Lev Walkin | 997d4c78e6 | |
Lev Walkin | 9413414cdd | |
Bi-Ruei, Chiu | 9b87e5b095 | |
Vasil Velichkov | e5006dc658 | |
Vasil Velichkov | 89c49eeff8 | |
Lev Walkin | 73d449d49c | |
Lev Walkin | ba3a148eb1 | |
Lev Walkin | f95c499d33 | |
Lev Walkin | f3ecbcaaf2 | |
Erika Thorsen | 2aa10de1a8 | |
Bi-Ruei, Chiu | 385cbe03d6 | |
Erika Thorsen | afea72f494 | |
Erika Thorsen | 8723dc7337 | |
Bi-Ruei, Chiu | 419ac3a6ce | |
Bi-Ruei, Chiu | 4661dae415 | |
Bi-Ruei, Chiu | b9adfc5f91 | |
Bi-Ruei, Chiu | 0bfcefc368 | |
Bi-Ruei, Chiu | 6f34894ca3 | |
Bi-Ruei, Chiu | 64505efde4 | |
Bi-Ruei, Chiu | 9b78083824 | |
Bi-Ruei, Chiu | 12021b53b8 | |
Ozbolt Menegatti | 11a3d68be5 | |
Lev Walkin | d6a741287b | |
Lev Walkin | 4bf28a8e1b | |
Lev Walkin | 4af4112b9d | |
Lev Walkin | 657dbe7210 | |
Lev Walkin | 83b52d8fdb | |
Lev Walkin | 93ed494210 | |
theirix | b577d4d881 | |
theirix | 34ee7fbed9 | |
Vasil Velichkov | febd3d5a02 | |
Vasil Velichkov | b97d65a2b9 | |
Alexander Duryagin | bc6243e653 | |
Lev Walkin | e9b0fd77c9 | |
Markus Elfring | f3d1861b94 | |
Markus Elfring | 671eb9ad14 | |
devjoa | 878c8b7311 |
|
@ -19,6 +19,7 @@ Makefile
|
|||
Makefile.in
|
||||
ylwrap
|
||||
m4/*
|
||||
!m4/ax_*.m4
|
||||
|
||||
# Generated by `./configure`
|
||||
config.h
|
||||
|
@ -33,11 +34,33 @@ stamp-h*
|
|||
|
||||
# /asn1c/
|
||||
/asn1c/asn1c
|
||||
/asn1c/unber
|
||||
/asn1c/enber
|
||||
|
||||
# /asn1c/tests/
|
||||
/asn1c/tests/test-*
|
||||
# /asn1c-tools
|
||||
/asn1-tools/enber/enber
|
||||
/asn1-tools/unber/unber
|
||||
/asn1-tools/unber/check_unber
|
||||
|
||||
# /skeletons
|
||||
/skeletons/check-*
|
||||
|
||||
# /tests/
|
||||
/tests/tests-asn1c-smoke/Makefile.am.libasncodec
|
||||
/tests/tests-asn1c-smoke/Makefile.am.asn1convert
|
||||
/tests/tests-asn1c-smoke/converter-example.mk
|
||||
/tests/tests-asn1c-smoke/*.[acho]
|
||||
/tests/tests-asn1c-smoke/*.asn
|
||||
/tests/tests-asn1c-smoke/*.txt
|
||||
/tests/tests-asn1c-smoke/converter-example
|
||||
|
||||
# /tests/
|
||||
/tests/tests-c-compiler/test-*
|
||||
|
||||
# /tests/tests-skeletons
|
||||
/tests/tests-skeletons/check-*
|
||||
!/tests/tests-skeletons/check-*.c
|
||||
|
||||
# /tests/tests-randomized
|
||||
/tests/tests-randomized/test-param-helper
|
||||
|
||||
# /doc/docsrc
|
||||
doc/docsrc/*.aux
|
||||
|
@ -51,10 +74,16 @@ doc/docsrc/*.xdv
|
|||
/examples/*.asn1
|
||||
|
||||
# /examples/*/
|
||||
/examples/*/*.c
|
||||
/examples/*/*.h
|
||||
/examples/*/*dump
|
||||
/examples/*/.tmp.*
|
||||
/examples/sample.source.*/*.c
|
||||
/examples/sample.source.*/*.h
|
||||
/examples/sample.source.*/*dump
|
||||
/examples/sample.source.*/lib*.a
|
||||
/examples/sample.source.*/.tmp.*
|
||||
/examples/sample.source.*/Makefile.am.libasncodec
|
||||
/examples/sample.source.*/Makefile.am.asn1convert
|
||||
/examples/sample.source.*/converter-example.mk
|
||||
!/examples/sample.source.*/Makefile
|
||||
!/examples/sample.source.*/config.h
|
||||
|
||||
# /libasn1compiler/
|
||||
/libasn1compiler/check_compiler
|
||||
|
@ -63,8 +92,8 @@ doc/docsrc/*.xdv
|
|||
/libasn1fix/check_*
|
||||
|
||||
# /libasn1parser/
|
||||
/libasn1parser/check_parser
|
||||
|
||||
# /skeletons/tests/
|
||||
/skeletons/tests/check-*
|
||||
/libasn1parser/check_*
|
||||
|
||||
#code coverage
|
||||
*.gcno
|
||||
*.gcda
|
||||
|
|
18
.travis.yml
18
.travis.yml
|
@ -2,9 +2,17 @@ language: c
|
|||
compiler:
|
||||
- gcc
|
||||
- clang
|
||||
env:
|
||||
- TASK=check CONFIG_FLAGS="--enable-Werror --enable-test-Werror --enable-code-coverage"
|
||||
- TASK=distcheck
|
||||
before_install:
|
||||
- sudo apt-get install -y gcc-multilib lcov libasan*
|
||||
- gem install coveralls-lcov
|
||||
script:
|
||||
- autoreconf -iv
|
||||
- ./configure --enable-Werror
|
||||
- make -j8
|
||||
- make check
|
||||
- make distcheck
|
||||
- autoreconf -iv
|
||||
- ./configure $CONFIG_FLAGS
|
||||
- make $TASK
|
||||
after_success:
|
||||
- test "x$CC" = "xgcc" -o "x$CC" = "xclang" && make code-coverage-capture && coveralls-lcov asn1c-*-coverage.info
|
||||
after_failure:
|
||||
- find . -name test-suite.log -exec tail -v -n +1 {} +
|
||||
|
|
30
AUTHORS
30
AUTHORS
|
@ -1 +1,31 @@
|
|||
Full list of copyright holders:
|
||||
|
||||
Rob Stradling <rob@sectigo.com>
|
||||
Bartosz Marcinkiewicz <bma@megawatt.com.pl>
|
||||
Bent Nicolaisen <BN@JAI.com>
|
||||
Bi-Ruei, Chiu <biruei.chiu@gmail.com>
|
||||
Damir Franusic <damir.franusic@gmail.com>
|
||||
Daniele Varrazzo <daniele.varrazzo@gmail.com>
|
||||
Dave Cridland <dave@cridland.net>
|
||||
Denis Filatov (DanyaFilatov @ github)
|
||||
daa @ github
|
||||
Eric Sesterhenn <eric.sesterhenn@x41-dsec.de>
|
||||
Erika Thorsen (akire @ github)
|
||||
gareins @ github
|
||||
johvik @ github
|
||||
Jon Ringle (ringlej @ github)
|
||||
kuepe-sl @ github
|
||||
Lev Walkin <vlm@lionet.info>
|
||||
Max Khon (mkhon @ github)
|
||||
Maxim Kuzmin (AuthenticEshkinKot @ github)
|
||||
mouse07410 @ github
|
||||
Oskar Holmlund (ikarso @ github)
|
||||
Ray Zhang (zhanglei002 @ github)
|
||||
Russ Kubik <russkubik@gmail.com>
|
||||
Simo Sorce <simo@redhat.com>
|
||||
theirix @ github
|
||||
Uri Blumenthal
|
||||
Vasil Velichkov (velichkov @ github)
|
||||
Wim L <wiml@omnigroup.com>
|
||||
ymbirtt @ github
|
||||
Google Inc.
|
||||
|
|
47
ChangeLog
47
ChangeLog
|
@ -1,5 +1,52 @@
|
|||
|
||||
0.9.??:
|
||||
FEATURES:
|
||||
* Added support for basic Information Object Sets driven code generation.
|
||||
* Added OER support.
|
||||
* Added LTE RRC example (Bi-Ruei, Chiu).
|
||||
* Added IEEE 1609.2 example.
|
||||
* Added SAE J2735 example.
|
||||
|
||||
NOTABLE:
|
||||
* Converter example (included by default):
|
||||
* converter-sample.c renamed into converter-example.c
|
||||
* make converter-example.mk file for building that converter
|
||||
* asn1c -no-gen-example to stop generating converter-example.{c,mk}
|
||||
* asn1c -no-gen-example option to disable converter-example generation.
|
||||
* Added random value generation (-R option to converter-example).
|
||||
* Added LibFuzzer-based randomized tests for supported transfer syntaxes
|
||||
(DER, OER, UPER, XER) into tests/tests-randomized. See the following
|
||||
article to get the latest LibFuzzer-enabled clang on macOS:
|
||||
https://medium.com/@levwalkin/compile-llvm-clang-libfuzzer-b61e82718430
|
||||
then ensure the new clang is in the way:
|
||||
CC=clang CXX=clang++ ./configure --enable-Werror --enable-test-fuzzer
|
||||
* OBJECT IDENTIFIER and RELATIVE-OID API simplified.
|
||||
* uper_encode() API got new argument (breaks API compatibility).
|
||||
* asn1c -gen-XXX flags are deprecated. Use -no-gen-XXX to disable codecs.
|
||||
|
||||
FIXES IN COMPILER-GENERATED OUTPUT:
|
||||
* Fix incomplete (failed) CHOICE XER decoding memory leak.
|
||||
(Severity: medium; Security impact: medium)
|
||||
* Fix REAL type overwrite conversion memory leak.
|
||||
(Severity: low; Security impact: medium)
|
||||
* Fix UPER string decoding constrained only by lower bound > 0
|
||||
(Severity: low; Security impact: none)
|
||||
* Fix UPER decoding of large [bit-]strings of size a multiple of 16K
|
||||
(Severity: low; Security impact: none)
|
||||
* Fix XER decoder crash on maliciously constructed ENUMERATED input.
|
||||
(Severity: medium; Security impact: medium)
|
||||
* Fix XER decoder of INTEGER, OBJECT IDENTIFIER, and RELATIVE-OID.
|
||||
In some cases an INTEGER overflow during parsing is not detected
|
||||
and incorrect value is returned to the decoder instead of an error.
|
||||
Reported by Nika Pona <npona@digamma.ai>.
|
||||
(Severity: low; Security impact: medium).
|
||||
|
||||
FIXES IN TOOLING:
|
||||
* CVE-2017-12966 verified not present.
|
||||
* Fix `unber` buffer overrun. Reported by Eric Sesterhenn.
|
||||
(Severity: low; Security impact: high)
|
||||
|
||||
0.9.28: 2017-03-26
|
||||
* PER decoding: avoid memory leak on error. By github.com/simo5
|
||||
* Constness patch #46 by Wim L <wiml@omnigroup.com> (41bbf1c..78d604f).
|
||||
Build issues:
|
||||
|
|
15
FAQ
15
FAQ
|
@ -22,21 +22,6 @@
|
|||
./x509dump -h
|
||||
|
||||
|
||||
3.Q: Your compiler supplies a der_encode() procedure. How do I encode BER?
|
||||
3.A:
|
||||
The DER (and CER) are stricter subsets of a more generic BER encoding
|
||||
method. If you encode data with DER or CER, all BER-conformant decoders
|
||||
will easily understand that. Hence, to encode data in the BER format,
|
||||
simply use the DER encoder, der_encode().
|
||||
|
||||
See also: ISO/IEC 8825-1 / X.690:
|
||||
"ASN.1 encoding rules: Specification of
|
||||
Basic Encoding Rules (BER),
|
||||
Canonical Encoding Rules (CER) and
|
||||
Distinguished Encoding Rules (DER)"
|
||||
|
||||
|
||||
|
||||
--
|
||||
Lev Walkin
|
||||
vlm@lionet.info
|
||||
|
|
51
INSTALL
51
INSTALL
|
@ -1,51 +0,0 @@
|
|||
|
||||
QUICK START INSTALLATION
|
||||
========================
|
||||
|
||||
./configure
|
||||
|
||||
(or `autoreconf -iv && ./configure` if you've got asn1c
|
||||
straight from github).
|
||||
|
||||
Configure the build infrastructure for your platform
|
||||
asn1c specific ./configure options include:
|
||||
--enable-Werror
|
||||
--enable-ASN_DEBUG
|
||||
invoke `./configure --help` for details.
|
||||
|
||||
make
|
||||
|
||||
Build the libraries and the compiler.
|
||||
|
||||
make check
|
||||
|
||||
Ensure asn1c is still behaving well after compiling on your platform.
|
||||
PLEASE CONTACT ME IF THIS STEP FAILS! Lev Walkin <vlm@lionet.info>
|
||||
|
||||
make install
|
||||
|
||||
Install the compiler into a standard location.
|
||||
Use ./configure --prefix to override install location.
|
||||
|
||||
man asn1c
|
||||
|
||||
Display the asn1c manual page.
|
||||
|
||||
QUICK USAGE GUIDE
|
||||
=================
|
||||
|
||||
For usage guide and more information please refer to:
|
||||
|
||||
* the ./README.md file.
|
||||
* the asn1c manual page `man asn1c`
|
||||
* the included quick start PDF doc/asn1c-quick.pdf
|
||||
* the comprehensive usage documentation doc/asn1c-usage.pdf
|
||||
|
||||
In case of any difficulties with installing the compiler, consider using
|
||||
the Online ASN.1 Compiler at
|
||||
|
||||
http://lionet.info/asn1c
|
||||
|
||||
--
|
||||
Lev Walkin
|
||||
vlm@lionet.info
|
|
@ -0,0 +1,66 @@
|
|||
|
||||
## Compiling From Sources
|
||||
|
||||
### Configure
|
||||
|
||||
See [REQUIREMENTS.md](REQUIREMENTS.md) for the complete list of dependencies.
|
||||
|
||||
Configure with the default settings:
|
||||
|
||||
test -f configure || autoreconf -iv
|
||||
./configure
|
||||
make
|
||||
|
||||
Configure with non-standard settings:
|
||||
|
||||
asn1c-specific ./configure options include:
|
||||
|
||||
Option | Description
|
||||
------------------------ | ---------------------------------------------------
|
||||
--enable-ASN_DEBUG | produce debug log during `make check` testing
|
||||
--enable-code-coverage | whether to enable code coverage support
|
||||
--enable-Werror | abort compilation after any C compiler warning
|
||||
--enable-test-Werror | abort compiling tests after any C compiler warning
|
||||
--enable-test-32bit | enable tests for 32-bit compatibility
|
||||
--disable-test-ubsan | disable Undefined Behavior Sanitizer for tests
|
||||
--disable-test-asan | disable Address Sanitizer for tests
|
||||
--enable-test-fuzzer | enable LLVM LibFuzzer for randomized testing
|
||||
|
||||
invoke `./configure --help` for details.
|
||||
|
||||
### Build
|
||||
|
||||
Build the libraries and the compiler:
|
||||
|
||||
make
|
||||
|
||||
Ensure asn1c is still behaving well after compiling on your platform:
|
||||
|
||||
make check
|
||||
|
||||
### Install
|
||||
|
||||
Install the compiler into a standard location:
|
||||
|
||||
make install
|
||||
# Use ./configure --prefix to override install location.
|
||||
|
||||
Display the `asn1c` manual page:
|
||||
|
||||
man asn1c
|
||||
|
||||
## Quick Usage Guide
|
||||
|
||||
For a usage guide and more information please refer to:
|
||||
|
||||
* the [README.md](README.md) file
|
||||
* the asn1c manual page `man asn1c`
|
||||
* the included quick start PDF [doc/asn1c-quick.pdf](doc/asn1c-quick.pdf)
|
||||
* the comprehensive usage documentation [doc/asn1c-usage.pdf](doc/asn1c-usage.pdf)
|
||||
|
||||
In case of any difficulties with installing the compiler, consider using
|
||||
the Online ASN.1 Compiler at http://lionet.info/asn1c.
|
||||
|
||||
--
|
||||
Lev Walkin
|
||||
vlm@lionet.info
|
2
LICENSE
2
LICENSE
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2003-2016 Lev Walkin <vlm@lionet.info>
|
||||
Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info> and contributors.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
18
Makefile.am
18
Makefile.am
|
@ -1,14 +1,18 @@
|
|||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
SUBDIRS = \
|
||||
libasn1parser libasn1fix \
|
||||
libasn1print libasn1compiler \
|
||||
skeletons examples \
|
||||
doc tests asn1c
|
||||
@CODE_COVERAGE_RULES@
|
||||
CODE_COVERAGE_IGNORE_PATTERN="tests/*" "lex.yy.c" "y.tab.c" "asn1p_l.l" "asn1p_y.y"
|
||||
|
||||
SUBDIRS = \
|
||||
libasn1common libasn1parser \
|
||||
libasn1fix libasn1print \
|
||||
libasn1compiler \
|
||||
asn1-tools asn1c skeletons \
|
||||
tests examples doc
|
||||
|
||||
docsdir = $(datadir)/doc/asn1c
|
||||
|
||||
docs_DATA = README.md FAQ ChangeLog BUGS TODO
|
||||
docs_DATA = README.md INSTALL.md REQUIREMENTS.md FAQ ChangeLog BUGS
|
||||
|
||||
EXTRA_DIST = README.md FAQ LICENSE BUGS
|
||||
EXTRA_DIST = README.md INSTALL.md REQUIREMENTS.md FAQ LICENSE BUGS
|
||||
|
|
51
README.md
51
README.md
|
@ -2,22 +2,57 @@
|
|||
|
||||
ASN.1 to C compiler takes the ASN.1 module files (example) and generates
|
||||
the C++ compatible C source code. That code can be used to serialize
|
||||
the native C structures into compact and unambiguous BER/XER/PER-based
|
||||
the native C structures into compact and unambiguous BER/OER/PER/XER-based
|
||||
data files, and deserialize the files back.
|
||||
|
||||
Various ASN.1 based formats are widely used in the industry,
|
||||
such as to encode the X.509 certificates employed in the HTTPS handshake,
|
||||
to exchange control data between mobile phones and cellular networks,
|
||||
to car-to-car communication in intelligent transportation networks.
|
||||
to perform car-to-car communication in intelligent transportation networks.
|
||||
|
||||
The ASN.1 standard is large and complex and no open source compiler supports
|
||||
it in its entirety. The asn1c is arguably the most evolved open source
|
||||
ASN.1 compiler.
|
||||
The ASN.1 family of standards is large and complex, and no open source
|
||||
compiler supports it in its entirety.
|
||||
The asn1c is arguably the most evolved open source ASN.1 compiler.
|
||||
|
||||
# ASN.1 Transfer Syntaxes
|
||||
<details>
|
||||
<summary>ASN.1 encodings interoperability table</summary>
|
||||
|
||||
The ASN.1 family of standards define a number of ways to encode data,
|
||||
including byte-oriented (e.g., BER), bit-oriented (e.g., PER),
|
||||
and textual (e.g., XER). Some encoding variants (e.g., DER) are just stricter
|
||||
variants of the more general encodings (e.g., BER).
|
||||
|
||||
The interoperability table below specifies which API functions can be used
|
||||
to exchange data in a compatible manner. If you need to _produce_ data
|
||||
conforming to the standard specified in the column 1,
|
||||
use the API function in the column 2.
|
||||
If you need to _process_ data conforming to the standard(s) specified in the
|
||||
column 3, use the API function specified in column 4.
|
||||
See the [doc/asn1c-usage.pdf](doc/asn1c-usage.pdf) for details.
|
||||
|
||||
Encoding | API function | Understood by | API function
|
||||
-------------- | ------------------ | ------------- | -------------
|
||||
BER | der_encode() | BER | ber_decode()
|
||||
DER | der_encode() | DER, BER | ber_decode()
|
||||
CER | _not supported_ | CER, BER | ber_decode()
|
||||
BASIC-OER | oer_encode() | *-OER | oer_decode()
|
||||
CANONICAL-OER | oer_encode() | *-OER | oer_decode()
|
||||
BASIC-UPER | uper_encode() | *-UPER | uper_decode()
|
||||
CANONICAL-UPER | uper_encode() | *-UPER | uper_decode()
|
||||
*-APER | _not supported_ | *-APER | _not supported_
|
||||
BASIC-XER | xer_encode(XER_F_BASIC) | *-XER | xer_decode()
|
||||
CANONICAL-XER | xer_encode(XER_F_CANONICAL)| *-XER | xer_decode()
|
||||
|
||||
*) Asterisk means both BASIC and CANONICAL variants.
|
||||
</details>
|
||||
|
||||
# Build and Install
|
||||
|
||||
If you haven't installed the asn1c yet, read the [INSTALL](INSTALL) file for a
|
||||
short installation guide.
|
||||
If you haven't installed the asn1c yet, read the [INSTALL.md](INSTALL.md) file
|
||||
for a short installation guide.
|
||||
|
||||
[![Build Status](https://travis-ci.org/vlm/asn1c.svg?branch=master)](https://travis-ci.org/vlm/asn1c)
|
||||
|
||||
# Documentation
|
||||
|
||||
|
@ -34,7 +69,7 @@ An excellent book on ASN.1 is written by Olivier Dubuisson:
|
|||
|
||||
(also check out [doc/asn1c-quick.pdf](doc/asn1c-quick.pdf))
|
||||
|
||||
After installing the compiler (see [INSTALL](INSTALL)), you may use
|
||||
After installing the compiler (see [INSTALL.md](INSTALL.md)), you may use
|
||||
the asn1c command to compile the ASN.1 specification:
|
||||
|
||||
asn1c <module.asn1> # Compile module
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
## To compile asn1c compiler itself
|
||||
|
||||
A 64-bit build system is strongly recommended for asn1c operation.
|
||||
|
||||
A working C99 compiler is required to compile asn1c itself,
|
||||
such as gcc-4.x or clang-3.4. The asn1c compiler produces C90-compatible code,
|
||||
which is also upward compatible with C++.
|
||||
|
||||
### Packages
|
||||
|
||||
This notation specifies a minimum required package version (-ver)
|
||||
or an exact version (=ver). For example, bison=2.x requires the 2.x branch
|
||||
of bison, not 3.x.
|
||||
|
||||
* automake-1.15
|
||||
* libtool
|
||||
* bison=2.x
|
||||
* flex
|
||||
|
||||
## To compile asn1c-generated code
|
||||
|
||||
C:
|
||||
As a minimum, a compiler supporting the C90. Pretty much any modern C compiler
|
||||
will do, but gcc or clang is recommended. Note that MSVC++ is not a C compiler.
|
||||
|
||||
C++:
|
||||
A C++11 compliant compiler is recommended.
|
||||
|
11
TODO
11
TODO
|
@ -1,11 +0,0 @@
|
|||
1. MAJOR:
|
||||
|
||||
1.1 Support for Information Object Classes.
|
||||
Status: Support for parsing IOCs is mostly present.
|
||||
Support for slicing the IOCs to produce "views"
|
||||
is not yet designed.
|
||||
|
||||
2. MEDIUM:
|
||||
|
||||
2.1 Support for EXTERNAL, EMBEDDED-PDV and CHARACTER STRING types.
|
||||
Requires something from 1.2 (Information Object Classes).
|
|
@ -0,0 +1,11 @@
|
|||
@CODE_COVERAGE_RULES@
|
||||
|
||||
SUBDIRS=unber enber
|
||||
|
||||
AM_CFLAGS = @ADD_CFLAGS@
|
||||
AM_CPPFLAGS = -I${top_srcdir}/skeletons
|
||||
|
||||
dist_check_SCRIPTS = check-xxber.sh
|
||||
TESTS_ENVIRONMENT= builddir=${builddir}
|
||||
TESTS = $(dist_check_SCRIPTS)
|
||||
CLEANFILES = .check-xxber.*.tmp
|
|
@ -0,0 +1,2 @@
|
|||
unber - The ASN.1 BER Decoder
|
||||
enber - Reverse unber(1) output back into BER
|
|
@ -3,6 +3,10 @@
|
|||
ORIG="./.check-xxber.orig.$$.tmp"
|
||||
TEST="./.check-xxber.test.$$.tmp"
|
||||
|
||||
builddir=${builddir:-.}
|
||||
ENBER=${builddir}/enber/enber
|
||||
UNBER=${builddir}/unber/unber
|
||||
|
||||
# Test diff(1) capabilities
|
||||
diff -a . . 2>/dev/null && diffArgs="-a" # Assume text files
|
||||
diff -u . . 2>/dev/null && diffArgs="$diffArgs -u" # Unified diff output
|
||||
|
@ -23,8 +27,8 @@ cat<<EOM > $ORIG
|
|||
</I O="32" T="[UNIVERSAL 0]" TL="2" L="4">
|
||||
EOM
|
||||
|
||||
./enber $ORIG | ./unber -p -i 0 - > $TEST 2>&1
|
||||
diff $diffArgs $ORIG $TEST >/dev/null 2>&1
|
||||
${ENBER} $ORIG | ${UNBER} -p -i 0 - > $TEST 2>&1
|
||||
diff $diffArgs "$ORIG" "$TEST" >/dev/null 2>&1
|
||||
diffExitCode=$?
|
||||
|
||||
if [ "$diffExitCode" = "0" ]; then
|
||||
|
@ -36,9 +40,9 @@ fi
|
|||
echo '</I O="34" T="[UNIVERSAL 0]" TL="2" L="36">' >> $ORIG
|
||||
|
||||
# Try trancoding again
|
||||
./enber $ORIG | ./unber -p -i 0 - > $TEST 2>&1
|
||||
${ENBER} $ORIG | ${UNBER} -p -i 0 - > $TEST 2>&1
|
||||
|
||||
diff $diffArgs $ORIG $TEST
|
||||
diff $diffArgs "$ORIG" "$TEST"
|
||||
diffExitCode=$?
|
||||
|
||||
rm -f $ORIG $TEST
|
|
@ -0,0 +1,9 @@
|
|||
@CODE_COVERAGE_RULES@
|
||||
|
||||
AM_CFLAGS = @ADD_CFLAGS@
|
||||
AM_CPPFLAGS = \
|
||||
-I${top_srcdir}/libasn1common \
|
||||
-I${top_srcdir}/libasn1parser \
|
||||
-I${top_srcdir}/skeletons
|
||||
|
||||
bin_PROGRAMS = enber
|
|
@ -1,4 +1,4 @@
|
|||
/*-
|
||||
/*
|
||||
* Copyright (c) 2004, 2005 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -22,9 +22,8 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
#include "sys-common.h"
|
||||
#include "asn1_common.h"
|
||||
|
||||
#include <asn1parser.h> /* For static string tables */
|
||||
|
||||
|
@ -173,7 +172,6 @@ process_line(const char *fname, char *line, int lineno) {
|
|||
ber_tlv_len_t tlv_len;
|
||||
ber_tlv_len_t opt_tl_len; /* optional TL length */
|
||||
ssize_t ret;
|
||||
(void)fname;
|
||||
|
||||
/* Skip the whitespace */
|
||||
for(; *line == ' ' || *line == '\t'; line++)
|
||||
|
@ -184,11 +182,15 @@ process_line(const char *fname, char *line, int lineno) {
|
|||
switch(*op) {
|
||||
case '<': /* That's what we want! A tag opening */
|
||||
break;
|
||||
case '-': /* This is a comment (dash-dash) */
|
||||
if(op[1] == *op) case '\r':
|
||||
case '\r':
|
||||
case '\n':
|
||||
case '#': /* This is a comment */
|
||||
return 0;
|
||||
case '-': /* This is a comment (dash-dash) */
|
||||
if(op[1] == '-') {
|
||||
return 0;
|
||||
}
|
||||
/* Fall through */
|
||||
default:
|
||||
fprintf(stderr, "%s: Missing '<' after whitespace at line %d\n", fname,
|
||||
lineno);
|
|
@ -0,0 +1,31 @@
|
|||
@CODE_COVERAGE_RULES@
|
||||
|
||||
AM_CFLAGS = @ADD_CFLAGS@
|
||||
AM_CPPFLAGS = \
|
||||
-I${top_srcdir}/libasn1common \
|
||||
-I${top_srcdir}/libasn1parser \
|
||||
-I${top_srcdir}/skeletons
|
||||
|
||||
noinst_LTLIBRARIES = libasn1-unber-tool.la
|
||||
|
||||
libasn1_unber_tool_la_SOURCES = \
|
||||
libasn1_unber_tool.c libasn1_unber_tool.h
|
||||
|
||||
bin_PROGRAMS = unber
|
||||
|
||||
unber_LDADD = libasn1-unber-tool.la \
|
||||
$(top_builddir)/libasn1common/libasn1common.la
|
||||
|
||||
check_PROGRAMS = check_unber
|
||||
check_unber_CFLAGS = $(TESTSUITE_CFLAGS) $(LIBFUZZER_CFLAGS)
|
||||
check_unber_LDADD = libasn1-unber-tool.la \
|
||||
$(top_builddir)/libasn1common/libasn1common.la
|
||||
|
||||
dist_check_SCRIPTS=check_unber.sh
|
||||
|
||||
# This jump through the shell is needed to run ./check_unber binary with
|
||||
# proper fuzzing options.
|
||||
TESTS_ENVIRONMENT= \
|
||||
ASAN_ENV_FLAGS="@ASAN_ENV_FLAGS@" \
|
||||
builddir=${builddir}
|
||||
TESTS= check_unber.sh
|
|
@ -0,0 +1,65 @@
|
|||
#include "asn1_common.h"
|
||||
#include "libasn1_unber_tool.h"
|
||||
|
||||
// An abstraction for getting data from the in-memory buffer.
|
||||
struct memory_buffer_stream {
|
||||
input_stream_t istream;
|
||||
const uint8_t *data;
|
||||
size_t size;
|
||||
size_t offset;
|
||||
};
|
||||
|
||||
static int memory_buffer_stream_nextChar(input_stream_t *ibs) {
|
||||
struct memory_buffer_stream *bs = (struct memory_buffer_stream *)ibs;
|
||||
|
||||
if(bs->offset < bs->size) {
|
||||
return bs->data[bs->offset++];
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static off_t memory_buffer_stream_bytesRead(input_stream_t *ibs) {
|
||||
struct memory_buffer_stream *bs = (struct memory_buffer_stream *)ibs;
|
||||
|
||||
return (off_t)bs->offset;
|
||||
}
|
||||
|
||||
static int
|
||||
ignore_vprintf(output_stream_t *os, const char *fmt, va_list ap) {
|
||||
(void)os;
|
||||
(void)fmt;
|
||||
(void)ap;
|
||||
// Ignore all output.
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
|
||||
|
||||
int
|
||||
LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
||||
|
||||
// Read from a memory buffer.
|
||||
struct memory_buffer_stream mbs;
|
||||
mbs.istream.nextChar = memory_buffer_stream_nextChar;
|
||||
mbs.istream.bytesRead = memory_buffer_stream_bytesRead;
|
||||
mbs.data = Data;
|
||||
mbs.size = Size;
|
||||
mbs.offset = 0;
|
||||
|
||||
// Do not print anywhere.
|
||||
struct output_stream nullstream;
|
||||
nullstream.vprintf = ignore_vprintf;
|
||||
nullstream.vprintfError = ignore_vprintf;
|
||||
|
||||
(void)unber_stream("<fuzzed-input>", &mbs.istream, &nullstream);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef ENABLE_LIBFUZZER
|
||||
int main() {
|
||||
printf("libfuzzer is not compiled-in, pretend the test went OK.\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
FUZZ_TIME=${FUZZ_TIME:-10}
|
||||
builddir=${builddir:-.}
|
||||
|
||||
env ${ASAN_ENV_FLAGS:-} ${builddir}/check_unber \
|
||||
-timeout=3 \
|
||||
-max_total_time=${FUZZ_TIME} \
|
||||
-max_len=500
|
|
@ -1,4 +1,4 @@
|
|||
/*-
|
||||
/*
|
||||
* Copyright (c) 2004, 2005, 2006 Lev Walkin <vlm@lionet.info>.
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -23,11 +23,12 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
#include "sys-common.h"
|
||||
#include "asn1_common.h"
|
||||
#include "libasn1_unber_tool.h"
|
||||
|
||||
#define ASN_DISABLE_PER_SUPPORT 1
|
||||
#define ASN_DISABLE_OER_SUPPORT 1
|
||||
|
||||
#include <asn1parser.h> /* For static string tables */
|
||||
|
||||
|
@ -39,169 +40,78 @@
|
|||
#include <OBJECT_IDENTIFIER.c>
|
||||
#include <RELATIVE-OID.c>
|
||||
#include <asn_codecs_prim.c>
|
||||
|
||||
#undef COPYRIGHT
|
||||
#define COPYRIGHT "Copyright (c) 2004, 2005 Lev Walkin <vlm@lionet.info>\n"
|
||||
|
||||
static void usage(const char *av0); /* Print the Usage screen and exit */
|
||||
static int process(const char *fname); /* Perform the BER decoding */
|
||||
static int decode_tlv_from_string(const char *datastring);
|
||||
#include <asn1p_integer.c>
|
||||
#include <asn_internal.c>
|
||||
|
||||
static int single_type_decoding = 0; /* -1 enables that */
|
||||
static int minimalistic = 0; /* -m enables that */
|
||||
static int pretty_printing = 1; /* -p disables that */
|
||||
static int skip_bytes = 0; /* -s controls that */
|
||||
static long skip_bytes = 0; /* -s controls that */
|
||||
static char indent_bytes[16] = " "; /* -i controls that */
|
||||
|
||||
int
|
||||
main(int ac, char **av) {
|
||||
int ch; /* Command line character */
|
||||
int i; /* Index in some loops */
|
||||
|
||||
/*
|
||||
* Process command-line options.
|
||||
*/
|
||||
while((ch = getopt(ac, av, "1hi:mps:t:v")) != -1) switch(ch) {
|
||||
case '1':
|
||||
single_type_decoding = 1;
|
||||
break;
|
||||
case 'i':
|
||||
i = atoi(optarg);
|
||||
if(i >= 0 && i < (int)sizeof(indent_bytes)) {
|
||||
memset(indent_bytes, ' ', i);
|
||||
indent_bytes[i] = '\0';
|
||||
} else {
|
||||
fprintf(stderr, "-i %s: Invalid indent value\n", optarg);
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
break;
|
||||
case 'm':
|
||||
minimalistic = 1;
|
||||
break;
|
||||
case 'p':
|
||||
pretty_printing = 0;
|
||||
break;
|
||||
case 's':
|
||||
skip_bytes = atoi(optarg);
|
||||
if(skip_bytes < 0) {
|
||||
fprintf(stderr, "-s %s: positive value expected\n", optarg);
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
break;
|
||||
case 't':
|
||||
if(decode_tlv_from_string(optarg)) exit(EX_DATAERR);
|
||||
exit(0);
|
||||
case 'v':
|
||||
fprintf(stderr, "ASN.1 BER Decoder, v" VERSION "\n" COPYRIGHT);
|
||||
exit(0);
|
||||
break;
|
||||
case 'h':
|
||||
default:
|
||||
usage(av[0]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Ensure that there are some input files present.
|
||||
*/
|
||||
if(ac > optind) {
|
||||
ac -= optind;
|
||||
av += optind;
|
||||
} else {
|
||||
fprintf(stderr, "%s: No input files specified\n", av[0]);
|
||||
exit(1);
|
||||
void set_minimalistic_output(int v) { minimalistic = v; }
|
||||
void set_single_type_decoding(int v) { single_type_decoding = v; }
|
||||
void set_pretty_printing(int v) { pretty_printing = v; }
|
||||
int set_skip_bytes(long v) { if(v < 0) return -1; skip_bytes = v; return 0; }
|
||||
int set_indent_size(int indent_size) {
|
||||
if(indent_size < 0 || indent_size >= (int)sizeof(indent_bytes)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
setvbuf(stdout, 0, _IOLBF, 0);
|
||||
|
||||
/*
|
||||
* Iterate over input files and parse each.
|
||||
* All syntax trees from all files will be bundled together.
|
||||
*/
|
||||
for(i = 0; i < ac; i++) {
|
||||
if(process(av[i])) exit(EX_DATAERR);
|
||||
}
|
||||
|
||||
memset(indent_bytes, ' ', indent_size);
|
||||
indent_bytes[indent_size] = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Print the usage screen and exit(EX_USAGE).
|
||||
*/
|
||||
static void
|
||||
usage(const char *av0) {
|
||||
/* clang-format off */
|
||||
fprintf(stderr,
|
||||
"ASN.1 BER Decoder, v" VERSION "\n" COPYRIGHT
|
||||
"Usage: %s [options] [-] [file ...]\n"
|
||||
"Options:\n"
|
||||
" -1 Decode only the first BER structure (otherwise, until EOF)\n"
|
||||
" -i <indent> Amount of spaces for output indentation (default is 4)\n"
|
||||
" -m Minimalistic mode: print as little as possible\n"
|
||||
" -p Do not attempt pretty-printing of known ASN.1 types\n"
|
||||
" -s <skip> Ignore first <skip> bytes of input\n"
|
||||
" -t <hex-string> Decode the given tag[/length] sequence (e.g. -t \"bf20\")\n"
|
||||
"\n"
|
||||
"The XML opening tag format is as follows:\n"
|
||||
" <tform O=\"off\" T=\"tag\" TL=\"tl_len\" V=\"{Indefinite|v_len}\" [A=\"type\"] [F]>\n"
|
||||
"Where:\n"
|
||||
" tform Which form the value is in: constructed (\"C\", \"I\") or primitive (\"P\")\n"
|
||||
" off Offset of the encoded element in the unber input stream\n"
|
||||
" tag The tag class and value in human readable form\n"
|
||||
" tl_len The length of the TL (BER Tag and Length) encoding\n"
|
||||
" v_len The length of the value (V, encoded by the L), may be \"Indefinite\"\n"
|
||||
" type Likely name of the underlying ASN.1 type (for [UNIVERSAL n] tags)\n"
|
||||
" [F] Indicates that the value was reformatted (pretty-printed)\n"
|
||||
"See the manual page for details\n"
|
||||
, av0);
|
||||
/* clang-format on */
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
|
||||
typedef enum pd_code {
|
||||
PD_FAILED = -1,
|
||||
PD_FINISHED = 0,
|
||||
PD_EOF = 1,
|
||||
} pd_code_e;
|
||||
static pd_code_e process_deeper(const char *fname, FILE *fp,
|
||||
asn1c_integer_t *offset, int level,
|
||||
static pd_code_e process_deeper(const char *fname, input_stream_t *,
|
||||
output_stream_t *os, int level,
|
||||
ssize_t limit, ber_tlv_len_t *frame_size,
|
||||
ber_tlv_len_t effective_size, int expect_eoc);
|
||||
static void print_TL(int fin, asn1c_integer_t offset, int level, int constr,
|
||||
ssize_t tlen, ber_tlv_tag_t, ber_tlv_len_t,
|
||||
static void print_TL(output_stream_t *, int fin, off_t offset, int level,
|
||||
int constr, ssize_t tlen, ber_tlv_tag_t, ber_tlv_len_t,
|
||||
ber_tlv_len_t effective_frame_size);
|
||||
static int print_V(const char *fname, FILE *fp, ber_tlv_tag_t, ber_tlv_len_t);
|
||||
static int print_V(const char *fname, input_stream_t *, output_stream_t *,
|
||||
ber_tlv_tag_t, ber_tlv_len_t);
|
||||
|
||||
static int ibs_getc(input_stream_t *ibs) { return ibs->nextChar(ibs); }
|
||||
static int __attribute__((format(printf, 2, 3)))
|
||||
osprintf(output_stream_t *os, const char *fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
int ret = os->vprintf(os, fmt, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
static int __attribute__((format(printf, 2, 3)))
|
||||
osprintfError(output_stream_t *os, const char *fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
int ret = os->vprintfError(os, fmt, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Open the file and initiate recursive processing.
|
||||
*/
|
||||
static int
|
||||
process(const char *fname) {
|
||||
FILE *fp;
|
||||
int
|
||||
unber_stream(const char *fname, input_stream_t *ibs, output_stream_t *os) {
|
||||
pd_code_e pdc;
|
||||
asn1c_integer_t offset = 0; /* Stream decoding position */
|
||||
ber_tlv_len_t frame_size = 0; /* Single frame size */
|
||||
|
||||
if(strcmp(fname, "-")) {
|
||||
fp = fopen(fname, "rb");
|
||||
if(!fp) {
|
||||
perror(fname);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
fp = stdin;
|
||||
}
|
||||
|
||||
/*
|
||||
* Skip the requested amount of bytes.
|
||||
*/
|
||||
for(; offset < skip_bytes; offset++) {
|
||||
if(fgetc(fp) == -1) {
|
||||
fprintf(stderr, "%s: input source (%" PRIdASN
|
||||
" bytes) "
|
||||
"has less data than \"-s %d\" switch "
|
||||
"wants to skip\n",
|
||||
fname, offset, skip_bytes);
|
||||
if(fp != stdin) fclose(fp);
|
||||
for(size_t offset = 0; offset < (size_t)skip_bytes; offset++) {
|
||||
if(ibs_getc(ibs) == -1) {
|
||||
osprintfError(os,
|
||||
"%s: input source has less data "
|
||||
"than \"-s %ld\" switch wants to skip\n",
|
||||
fname, skip_bytes);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -210,11 +120,9 @@ process(const char *fname) {
|
|||
* Fetch out BER-encoded data until EOF or error.
|
||||
*/
|
||||
do {
|
||||
pdc = process_deeper(fname, fp, &offset, 0, -1, &frame_size, 0, 0);
|
||||
pdc = process_deeper(fname, ibs, os, 0, -1, &frame_size, 0, 0);
|
||||
} while(pdc == PD_FINISHED && !single_type_decoding);
|
||||
|
||||
if(fp != stdin) fclose(fp);
|
||||
|
||||
if(pdc == PD_FAILED) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
@ -223,8 +131,8 @@ process(const char *fname) {
|
|||
* Process the TLV recursively.
|
||||
*/
|
||||
static pd_code_e
|
||||
process_deeper(const char *fname, FILE *fp, asn1c_integer_t *offset, int level,
|
||||
ssize_t limit, ber_tlv_len_t *frame_size,
|
||||
process_deeper(const char *fname, input_stream_t *ibs, output_stream_t *os,
|
||||
int level, ssize_t limit, ber_tlv_len_t *frame_size,
|
||||
ber_tlv_len_t effective_size, int expect_eoc) {
|
||||
unsigned char tagbuf[32];
|
||||
ssize_t tblen = 0;
|
||||
|
@ -242,23 +150,29 @@ process_deeper(const char *fname, FILE *fp, asn1c_integer_t *offset, int level,
|
|||
if(limit == 0) return PD_FINISHED;
|
||||
|
||||
if(limit >= 0 && tblen >= limit) {
|
||||
fprintf(stderr,
|
||||
"%s: Too long TL sequence (%ld >= %ld)"
|
||||
" at %" PRIdASN
|
||||
". "
|
||||
"Broken or maliciously constructed file\n",
|
||||
fname, (long)tblen, (long)limit, *offset);
|
||||
osprintfError(os,
|
||||
"%s: Too long TL sequence (%zd >= %zd) at %lld. "
|
||||
"Broken or maliciously constructed file\n",
|
||||
fname, tblen, limit, (long long)ibs->bytesRead(ibs));
|
||||
return PD_FAILED;
|
||||
}
|
||||
|
||||
if(tblen >= (ssize_t)sizeof(tagbuf)) {
|
||||
osprintfError(os,
|
||||
"%s: Too long TL sequence (%zd bytes) at %lld. "
|
||||
"Broken or maliciously constructed file\n",
|
||||
fname, tblen, (long long)ibs->bytesRead(ibs));
|
||||
return PD_FAILED;
|
||||
}
|
||||
|
||||
/* Get the next byte from the input stream */
|
||||
ch = fgetc(fp);
|
||||
ch = ibs_getc(ibs);
|
||||
if(ch == -1) {
|
||||
if(limit > 0 || expect_eoc) {
|
||||
fprintf(stderr,
|
||||
"%s: Unexpected end of file (TL)"
|
||||
" at %" PRIdASN "\n",
|
||||
fname, *offset);
|
||||
osprintfError(os,
|
||||
"%s: Unexpected end of file (TL)"
|
||||
" at %lld\n",
|
||||
fname, (long long)ibs->bytesRead(ibs));
|
||||
return PD_FAILED;
|
||||
} else {
|
||||
return PD_EOF;
|
||||
|
@ -273,10 +187,10 @@ process_deeper(const char *fname, FILE *fp, asn1c_integer_t *offset, int level,
|
|||
t_len = ber_fetch_tag(tagbuf, tblen, &tlv_tag);
|
||||
switch(t_len) {
|
||||
case -1:
|
||||
fprintf(stderr,
|
||||
"%s: Fatal error decoding tag"
|
||||
" at %" PRIdASN "+%ld\n",
|
||||
fname, *offset, (long)tblen);
|
||||
osprintfError(os,
|
||||
"%s: Fatal error decoding tag"
|
||||
" at %lld\n",
|
||||
fname, (long long)ibs->bytesRead(ibs));
|
||||
return PD_FAILED;
|
||||
case 0:
|
||||
/* More data expected */
|
||||
|
@ -291,10 +205,10 @@ process_deeper(const char *fname, FILE *fp, asn1c_integer_t *offset, int level,
|
|||
ber_fetch_length(constr, tagbuf + t_len, tblen - t_len, &tlv_len);
|
||||
switch(l_len) {
|
||||
case -1:
|
||||
fprintf(stderr,
|
||||
"%s: Fatal error decoding value length"
|
||||
" at %" PRIdASN "\n",
|
||||
fname, *offset + t_len);
|
||||
osprintfError(os,
|
||||
"%s: Fatal error decoding value length"
|
||||
" at %lld\n",
|
||||
fname, (long long)ibs->bytesRead(ibs));
|
||||
return PD_FAILED;
|
||||
case 0:
|
||||
/* More data expected */
|
||||
|
@ -302,11 +216,17 @@ process_deeper(const char *fname, FILE *fp, asn1c_integer_t *offset, int level,
|
|||
}
|
||||
|
||||
/* Make sure the T & L decoders took exactly the whole buffer */
|
||||
assert((t_len + l_len) == tblen);
|
||||
if((t_len + l_len) != tblen) {
|
||||
osprintfError(os,
|
||||
"%s: Outer tag length doesn't match inner tag length"
|
||||
" at %lld\n",
|
||||
fname, (long long)ibs->bytesRead(ibs));
|
||||
return PD_FAILED;
|
||||
}
|
||||
|
||||
if(!expect_eoc || tagbuf[0] || tagbuf[1])
|
||||
print_TL(0, *offset, level, constr, tblen, tlv_tag, tlv_len,
|
||||
effective_size);
|
||||
print_TL(os, 0, ibs->bytesRead(ibs) - tblen, level, constr, tblen,
|
||||
tlv_tag, tlv_len, effective_size);
|
||||
|
||||
if(limit != -1) {
|
||||
/* If limit is set, account for the TL sequence */
|
||||
|
@ -314,22 +234,22 @@ process_deeper(const char *fname, FILE *fp, asn1c_integer_t *offset, int level,
|
|||
assert(limit >= 0);
|
||||
|
||||
if(tlv_len > limit) {
|
||||
fprintf(stderr,
|
||||
"%s: Structure advertizes length (%ld) "
|
||||
"greater than of a parent container (%ld)\n",
|
||||
fname, (long)tlv_len, (long)limit);
|
||||
osprintfError(os,
|
||||
"%s: Structure advertizes length (%ld) "
|
||||
"greater than of a parent container (%ld)\n",
|
||||
fname, (long)tlv_len, (long)limit);
|
||||
return PD_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
*offset += t_len + l_len;
|
||||
*frame_size += t_len + l_len;
|
||||
effective_size += t_len + l_len;
|
||||
local_esize += t_len + l_len;
|
||||
|
||||
if(expect_eoc && !tagbuf[0] && !tagbuf[1]) {
|
||||
/* End of content octets */
|
||||
print_TL(1, *offset - 2, level - 1, 1, 2, 0, -1, effective_size);
|
||||
print_TL(os, 1, ibs->bytesRead(ibs) - 2, level - 1, 1, 2, 0, -1,
|
||||
effective_size);
|
||||
return PD_FINISHED;
|
||||
}
|
||||
|
||||
|
@ -338,11 +258,11 @@ process_deeper(const char *fname, FILE *fp, asn1c_integer_t *offset, int level,
|
|||
/*
|
||||
* This is a constructed type. Process recursively.
|
||||
*/
|
||||
printf(">\n"); /* Close the opening tag */
|
||||
osprintf(os, ">\n"); /* Close the opening tag */
|
||||
if(tlv_len != -1 && limit != -1) {
|
||||
assert(limit >= tlv_len);
|
||||
}
|
||||
pdc = process_deeper(fname, fp, offset, level + 1,
|
||||
pdc = process_deeper(fname, ibs, os, level + 1,
|
||||
tlv_len == -1 ? limit : tlv_len, &dec,
|
||||
t_len + l_len, tlv_len == -1);
|
||||
if(pdc == PD_FAILED) return pdc;
|
||||
|
@ -360,20 +280,19 @@ process_deeper(const char *fname, FILE *fp, asn1c_integer_t *offset, int level,
|
|||
}
|
||||
} else {
|
||||
assert(tlv_len >= 0);
|
||||
if(print_V(fname, fp, tlv_tag, tlv_len)) return PD_FAILED;
|
||||
if(print_V(fname, ibs, os, tlv_tag, tlv_len)) return PD_FAILED;
|
||||
|
||||
if(limit != -1) {
|
||||
assert(limit >= tlv_len);
|
||||
limit -= tlv_len;
|
||||
}
|
||||
*offset += tlv_len;
|
||||
*frame_size += tlv_len;
|
||||
effective_size += tlv_len;
|
||||
local_esize += tlv_len;
|
||||
}
|
||||
|
||||
print_TL(1, *offset, level, constr, tblen, tlv_tag, tlv_len,
|
||||
local_esize);
|
||||
print_TL(os, 1, ibs->bytesRead(ibs), level, constr, tblen,
|
||||
tlv_tag, tlv_len, local_esize);
|
||||
|
||||
tblen = 0;
|
||||
|
||||
|
@ -385,45 +304,45 @@ process_deeper(const char *fname, FILE *fp, asn1c_integer_t *offset, int level,
|
|||
}
|
||||
|
||||
static void
|
||||
print_TL(int fin, asn1c_integer_t offset, int level, int constr, ssize_t tlen,
|
||||
ber_tlv_tag_t tlv_tag, ber_tlv_len_t tlv_len,
|
||||
print_TL(output_stream_t *os, int fin, off_t offset, int level, int constr,
|
||||
ssize_t tlen, ber_tlv_tag_t tlv_tag, ber_tlv_len_t tlv_len,
|
||||
ber_tlv_len_t effective_size) {
|
||||
if(fin && !constr) {
|
||||
printf("</P>\n");
|
||||
osprintf(os, "</P>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
while(level-- > 0) fputs(indent_bytes, stdout); /* Print indent */
|
||||
printf(fin ? "</" : "<");
|
||||
while(level-- > 0) osprintf(os, "%s", indent_bytes); /* Print indent */
|
||||
osprintf(os, fin ? "</" : "<");
|
||||
|
||||
printf(constr ? ((tlv_len == -1) ? "I" : "C") : "P");
|
||||
osprintf(os, constr ? ((tlv_len == -1) ? "I" : "C") : "P");
|
||||
|
||||
/* Print out the offset of this boundary, even if closing tag */
|
||||
if(!minimalistic) printf(" O=\"%" PRIdASN "\"", offset);
|
||||
if(!minimalistic) osprintf(os, " O=\"%lld\"", (long long)offset);
|
||||
|
||||
printf(" T=\"");
|
||||
ber_tlv_tag_fwrite(tlv_tag, stdout);
|
||||
printf("\"");
|
||||
osprintf(os, " T=\"%s\"", ber_tlv_tag_string(tlv_tag));
|
||||
|
||||
if(!fin || (tlv_len == -1 && !minimalistic))
|
||||
printf(" TL=\"%ld\"", (long)tlen);
|
||||
osprintf(os, " TL=\"%ld\"", (long)tlen);
|
||||
if(!fin) {
|
||||
if(tlv_len == -1)
|
||||
printf(" V=\"Indefinite\"");
|
||||
osprintf(os, " V=\"Indefinite\"");
|
||||
else
|
||||
printf(" V=\"%ld\"", (long)tlv_len);
|
||||
osprintf(os, " V=\"%ld\"", (long)tlv_len);
|
||||
}
|
||||
|
||||
if(!minimalistic && BER_TAG_CLASS(tlv_tag) == ASN_TAG_CLASS_UNIVERSAL) {
|
||||
const char *str;
|
||||
ber_tlv_tag_t tvalue = BER_TAG_VALUE(tlv_tag);
|
||||
str = ASN_UNIVERSAL_TAG2STR(tvalue);
|
||||
if(str) printf(" A=\"%s\"", str);
|
||||
if(str) osprintf(os, " A=\"%s\"", str);
|
||||
}
|
||||
|
||||
if(fin) {
|
||||
if(constr && !minimalistic) printf(" L=\"%ld\"", (long)effective_size);
|
||||
printf(">\n");
|
||||
if(constr && !minimalistic) {
|
||||
osprintf(os, " L=\"%ld\"", (long)effective_size);
|
||||
}
|
||||
osprintf(os, ">\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -431,9 +350,9 @@ print_TL(int fin, asn1c_integer_t offset, int level, int constr, ssize_t tlen,
|
|||
* Print the value in binary form, or reformat for pretty-printing.
|
||||
*/
|
||||
static int
|
||||
print_V(const char *fname, FILE *fp, ber_tlv_tag_t tlv_tag,
|
||||
ber_tlv_len_t tlv_len) {
|
||||
asn1c_integer_t *arcs = 0; /* Object identifier arcs */
|
||||
print_V(const char *fname, input_stream_t *ibs, output_stream_t *os,
|
||||
ber_tlv_tag_t tlv_tag, ber_tlv_len_t tlv_len) {
|
||||
asn_oid_arc_t *arcs = 0; /* Object identifier arcs */
|
||||
unsigned char *vbuf = 0;
|
||||
asn1p_expr_type_e etype = 0;
|
||||
asn1c_integer_t collector = 0;
|
||||
|
@ -504,16 +423,16 @@ print_V(const char *fname, FILE *fp, ber_tlv_tag_t tlv_tag,
|
|||
}
|
||||
|
||||
/* If collection vbuf is present, defer printing the F flag. */
|
||||
if(!vbuf) printf(special_format ? " F>" : ">");
|
||||
if(!vbuf) osprintf(os, special_format ? " F>" : ">");
|
||||
|
||||
/*
|
||||
* Print the value in binary or text form,
|
||||
* or collect the bytes into vbuf.
|
||||
*/
|
||||
for(i = 0; i < tlv_len; i++) {
|
||||
int ch = fgetc(fp);
|
||||
int ch = ibs_getc(ibs);
|
||||
if(ch == -1) {
|
||||
fprintf(stderr, "%s: Unexpected end of file (V)\n", fname);
|
||||
osprintfError(os, "%s: Unexpected end of file (V)\n", fname);
|
||||
if(vbuf) FREEMEM(vbuf);
|
||||
if(arcs) FREEMEM(arcs);
|
||||
return -1;
|
||||
|
@ -530,26 +449,26 @@ print_V(const char *fname, FILE *fp, ber_tlv_tag_t tlv_tag,
|
|||
default:
|
||||
if(((etype == ASN_STRING_UTF8String) || !(ch & 0x80))
|
||||
&& (ch >= 0x20)) {
|
||||
printf("%c", ch);
|
||||
osprintf(os, "%c", ch);
|
||||
break;
|
||||
}
|
||||
/* Fall through */
|
||||
case 0x3c:
|
||||
case 0x3e:
|
||||
case 0x26:
|
||||
printf("&#x%02x;", ch);
|
||||
osprintf(os, "&#x%02x;", ch);
|
||||
}
|
||||
break;
|
||||
case ASN_BASIC_BOOLEAN:
|
||||
switch(ch) {
|
||||
case 0:
|
||||
printf("<false/>");
|
||||
osprintf(os, "<false/>");
|
||||
break;
|
||||
case 0xff:
|
||||
printf("<true/>");
|
||||
osprintf(os, "<true/>");
|
||||
break;
|
||||
default:
|
||||
printf("<true value=\"&#x%02x\"/>", ch);
|
||||
osprintf(os, "<true value=\"&#x%02x\"/>", ch);
|
||||
}
|
||||
break;
|
||||
case ASN_BASIC_INTEGER:
|
||||
|
@ -563,7 +482,7 @@ print_V(const char *fname, FILE *fp, ber_tlv_tag_t tlv_tag,
|
|||
if(vbuf) {
|
||||
vbuf[i] = ch;
|
||||
} else {
|
||||
printf("&#x%02x;", ch);
|
||||
osprintf(os, "&#x%02x;", ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -572,24 +491,23 @@ print_V(const char *fname, FILE *fp, ber_tlv_tag_t tlv_tag,
|
|||
switch(etype) {
|
||||
case ASN_BASIC_INTEGER:
|
||||
case ASN_BASIC_ENUMERATED:
|
||||
printf("%" PRIdASN, collector);
|
||||
osprintf(os, "%s", asn1p_itoa(collector));
|
||||
break;
|
||||
case ASN_BASIC_OBJECT_IDENTIFIER:
|
||||
if(vbuf) {
|
||||
OBJECT_IDENTIFIER_t oid;
|
||||
int arcno;
|
||||
OBJECT_IDENTIFIER_t oid = {0, 0};
|
||||
ssize_t arcno;
|
||||
|
||||
oid.buf = vbuf;
|
||||
oid.size = tlv_len;
|
||||
|
||||
arcno = OBJECT_IDENTIFIER_get_arcs(&oid, arcs, sizeof(*arcs),
|
||||
tlv_len + 1);
|
||||
arcno = OBJECT_IDENTIFIER_get_arcs(&oid, arcs, tlv_len + 1);
|
||||
if(arcno >= 0) {
|
||||
assert(arcno <= (tlv_len + 1));
|
||||
printf(" F>");
|
||||
osprintf(os, " F>");
|
||||
for(i = 0; i < arcno; i++) {
|
||||
if(i) printf(".");
|
||||
printf("%" PRIuASN, arcs[i]);
|
||||
if(i) osprintf(os, ".");
|
||||
osprintf(os, "%" PRIu32, arcs[i]);
|
||||
}
|
||||
FREEMEM(vbuf);
|
||||
vbuf = 0;
|
||||
|
@ -604,13 +522,13 @@ print_V(const char *fname, FILE *fp, ber_tlv_tag_t tlv_tag,
|
|||
oid.buf = vbuf;
|
||||
oid.size = tlv_len;
|
||||
|
||||
arcno = RELATIVE_OID_get_arcs(&oid, arcs, sizeof(*arcs), tlv_len);
|
||||
arcno = RELATIVE_OID_get_arcs(&oid, arcs, tlv_len);
|
||||
if(arcno >= 0) {
|
||||
assert(arcno <= (tlv_len + 1));
|
||||
printf(" F>");
|
||||
assert(arcno <= tlv_len);
|
||||
osprintf(os, " F>");
|
||||
for(i = 0; i < arcno; i++) {
|
||||
if(i) printf(".");
|
||||
printf("%" PRIuASN, arcs[i]);
|
||||
if(i) osprintf(os, ".");
|
||||
osprintf(os, "%" PRIu32, arcs[i]);
|
||||
}
|
||||
FREEMEM(vbuf);
|
||||
vbuf = 0;
|
||||
|
@ -650,16 +568,16 @@ print_V(const char *fname, FILE *fp, ber_tlv_tag_t tlv_tag,
|
|||
}
|
||||
break;
|
||||
}
|
||||
printf(">");
|
||||
osprintf(os, ">");
|
||||
for(i = 0; i < tlv_len; i++) {
|
||||
if(binary > 0 || vbuf[i] < 0x20 || vbuf[i] >= 0x7f
|
||||
|| vbuf[i] == 0x26 /* '&' */
|
||||
|| vbuf[i] == 0x3c /* '<' */
|
||||
|| vbuf[i] == 0x3e /* '>' */
|
||||
)
|
||||
printf("&#x%02x;", vbuf[i]);
|
||||
osprintf(os, "&#x%02x;", vbuf[i]);
|
||||
else
|
||||
printf("%c", vbuf[i]);
|
||||
osprintf(os, "%c", vbuf[i]);
|
||||
}
|
||||
FREEMEM(vbuf);
|
||||
}
|
||||
|
@ -668,9 +586,79 @@ print_V(const char *fname, FILE *fp, ber_tlv_tag_t tlv_tag,
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct file_input_stream {
|
||||
input_stream_t istream;
|
||||
FILE *fp;
|
||||
off_t offset;
|
||||
};
|
||||
|
||||
static int file_input_stream_nextChar(input_stream_t *ibs) {
|
||||
struct file_input_stream *fs = (struct file_input_stream *)ibs;
|
||||
int ret = fgetc(fs->fp);
|
||||
if(ret != -1) {
|
||||
fs->offset++;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static off_t file_input_stream_bytesRead(input_stream_t *ibs) {
|
||||
struct file_input_stream *fs = (struct file_input_stream *)ibs;
|
||||
return fs->offset;
|
||||
}
|
||||
|
||||
struct file_output_stream {
|
||||
output_stream_t ostream;
|
||||
FILE *outputFile;
|
||||
FILE *errorFile;
|
||||
};
|
||||
|
||||
static int
|
||||
decode_tlv_from_string(const char *datastring) {
|
||||
file_output_stream_vprintf(output_stream_t *os, const char *fmt, va_list ap) {
|
||||
struct file_output_stream *fos = (struct file_output_stream *)os;
|
||||
return vfprintf(fos->outputFile, fmt, ap);
|
||||
}
|
||||
|
||||
static int
|
||||
file_output_stream_vprintfError(output_stream_t *os, const char *fmt, va_list ap) {
|
||||
struct file_output_stream *fos = (struct file_output_stream *)os;
|
||||
return vfprintf(fos->errorFile, fmt, ap);
|
||||
}
|
||||
|
||||
int
|
||||
unber_file(const char *fname) {
|
||||
FILE *fp;
|
||||
|
||||
if(strcmp(fname, "-")) {
|
||||
fp = fopen(fname, "rb");
|
||||
if(!fp) {
|
||||
perror(fname);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
fp = stdin;
|
||||
}
|
||||
|
||||
struct file_input_stream ifs;
|
||||
ifs.istream.nextChar = file_input_stream_nextChar;
|
||||
ifs.istream.bytesRead = file_input_stream_bytesRead;
|
||||
ifs.fp = fp;
|
||||
ifs.offset = 0;
|
||||
|
||||
struct file_output_stream ofs;
|
||||
ofs.ostream.vprintf = file_output_stream_vprintf;
|
||||
ofs.ostream.vprintfError = file_output_stream_vprintfError;
|
||||
ofs.outputFile = stdout;
|
||||
ofs.errorFile = stderr;
|
||||
|
||||
int ret = unber_stream(fname, &ifs.istream, &ofs.ostream);
|
||||
|
||||
if(fp != stdin) fclose(fp);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
decode_tlv_from_hex_string(const char *datastring) {
|
||||
unsigned char *data, *dp;
|
||||
size_t dsize; /* Data size */
|
||||
ssize_t len;
|
||||
|
@ -771,10 +759,10 @@ decode_tlv_from_string(const char *datastring) {
|
|||
* Dummy functions.
|
||||
*/
|
||||
asn_dec_rval_t
|
||||
ber_check_tags(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
asn_struct_ctx_t *opt_ctx, const void *ptr, size_t size,
|
||||
int tag_mode, int last_tag_form, ber_tlv_len_t *last_length,
|
||||
int *opt_tlv_form) {
|
||||
ber_check_tags(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
const asn_TYPE_descriptor_t *td, asn_struct_ctx_t *opt_ctx,
|
||||
const void *ptr, size_t size, int tag_mode, int last_tag_form,
|
||||
ber_tlv_len_t *last_length, int *opt_tlv_form) {
|
||||
asn_dec_rval_t rv = {0, 0};
|
||||
(void)opt_codec_ctx;
|
||||
(void)td;
|
||||
|
@ -789,7 +777,7 @@ ber_check_tags(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
|||
}
|
||||
|
||||
ssize_t
|
||||
der_write_tags(asn_TYPE_descriptor_t *td, size_t slen, int tag_mode,
|
||||
der_write_tags(const asn_TYPE_descriptor_t *td, size_t slen, int tag_mode,
|
||||
int last_tag_form, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
(void)td;
|
||||
|
@ -803,7 +791,7 @@ der_write_tags(asn_TYPE_descriptor_t *td, size_t slen, int tag_mode,
|
|||
}
|
||||
|
||||
asn_dec_rval_t
|
||||
xer_decode_general(asn_codec_ctx_t *opt_codec_ctx, asn_struct_ctx_t *ctx,
|
||||
xer_decode_general(const asn_codec_ctx_t *opt_codec_ctx, asn_struct_ctx_t *ctx,
|
||||
void *struct_key, const char *xml_tag, const void *buf_ptr,
|
||||
size_t size,
|
||||
int (*otd)(void *struct_key, const void *chunk_buf,
|
||||
|
@ -822,33 +810,25 @@ xer_decode_general(asn_codec_ctx_t *opt_codec_ctx, asn_struct_ctx_t *ctx,
|
|||
return rv;
|
||||
}
|
||||
|
||||
asn_dec_rval_t
|
||||
OCTET_STRING_decode_uper(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td,
|
||||
asn_per_constraints_t *cts, void **sptr,
|
||||
asn_per_data_t *pd) {
|
||||
asn_dec_rval_t rv = {0, 0};
|
||||
(void)ctx;
|
||||
(void)td;
|
||||
(void)cts;
|
||||
(void)sptr;
|
||||
(void)pd;
|
||||
return rv;
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, asn_per_constraints_t *cts,
|
||||
void *sptr, asn_per_outp_t *po) {
|
||||
asn_enc_rval_t er = {0, 0, 0};
|
||||
(void)td;
|
||||
(void)cts;
|
||||
(void)sptr;
|
||||
(void)po;
|
||||
return er;
|
||||
}
|
||||
|
||||
size_t
|
||||
xer_whitespace_span(const void *chunk_buf, size_t chunk_size) {
|
||||
(void)chunk_buf;
|
||||
(void)chunk_size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
OCTET_STRING_compare(const asn_TYPE_descriptor_t *td, const void *a,
|
||||
const void *b) {
|
||||
(void)td;
|
||||
(void)a;
|
||||
(void)b;
|
||||
return 0;
|
||||
}
|
||||
|
||||
intmax_t
|
||||
asn_random_between(intmax_t a, intmax_t b) {
|
||||
(void)b;
|
||||
return a;
|
||||
};
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2019 Lev Walkin <vlm@lionet.info>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Set global options. */
|
||||
void set_minimalistic_output(int v);
|
||||
void set_single_type_decoding(int v);
|
||||
void set_pretty_printing(int v);
|
||||
int set_skip_bytes(long v);
|
||||
int set_indent_size(int indent_size);
|
||||
|
||||
/*
|
||||
* Convert BER-encoded file into the low level non-standard XML-like structure.
|
||||
* Primarily used for manual debugging.
|
||||
*/
|
||||
int unber_file(const char *fname);
|
||||
|
||||
typedef struct input_stream {
|
||||
/*
|
||||
* Return the next character as if it were an unsigned int converted to
|
||||
* an int. Returns -1 on EOF or error.
|
||||
*/
|
||||
int (*nextChar)(struct input_stream *);
|
||||
/*
|
||||
* Return the number of bytes consumed from the stream so far.
|
||||
*/
|
||||
off_t (*bytesRead)(struct input_stream *);
|
||||
} input_stream_t;
|
||||
|
||||
typedef struct output_stream {
|
||||
/*
|
||||
* Return the next character as if it were an unsigned int converted to
|
||||
* an int. Returns -1 on EOF or error.
|
||||
*/
|
||||
int (*vprintf)(struct output_stream *, const char *fmt, va_list);
|
||||
int (*vprintfError)(struct output_stream *, const char *fmt, va_list);
|
||||
} output_stream_t;
|
||||
|
||||
/*
|
||||
* Lower level converter.
|
||||
*/
|
||||
int unber_stream(const char *fname, input_stream_t *, output_stream_t *);
|
||||
|
||||
/*
|
||||
* Decode the TLV given by the given string.
|
||||
*/
|
||||
int decode_tlv_from_hex_string(const char *datastring);
|
||||
|
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
* Copyright (c) 2004, 2005, 2006 Lev Walkin <vlm@lionet.info>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#include "asn1_common.h"
|
||||
#include "libasn1_unber_tool.h"
|
||||
|
||||
#undef COPYRIGHT
|
||||
#define COPYRIGHT "Copyright (c) 2004-2019 Lev Walkin <vlm@lionet.info>\n"
|
||||
|
||||
static void usage(const char *av0); /* Print the Usage screen and exit */
|
||||
|
||||
int
|
||||
main(int ac, char **av) {
|
||||
int ch; /* Command line character */
|
||||
|
||||
/*
|
||||
* Process command-line options.
|
||||
*/
|
||||
while((ch = getopt(ac, av, "1hi:mps:t:v")) != -1) {
|
||||
switch(ch) {
|
||||
case '1':
|
||||
set_single_type_decoding(1);
|
||||
break;
|
||||
case 'i':
|
||||
if(set_indent_size(atoi(optarg)) != 0) {
|
||||
fprintf(stderr, "-i %s: Invalid indent value\n", optarg);
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
break;
|
||||
case 'm':
|
||||
set_minimalistic_output(1);
|
||||
break;
|
||||
case 'p':
|
||||
set_pretty_printing(0);
|
||||
break;
|
||||
case 's':
|
||||
if(set_skip_bytes(atol(optarg)) != 0) {
|
||||
fprintf(stderr, "-s %s: positive value expected\n", optarg);
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
break;
|
||||
case 't':
|
||||
if(decode_tlv_from_hex_string(optarg)) exit(EX_DATAERR);
|
||||
exit(0);
|
||||
case 'v':
|
||||
fprintf(stderr, "ASN.1 BER Decoder, v" VERSION "\n" COPYRIGHT);
|
||||
exit(0);
|
||||
break;
|
||||
case 'h':
|
||||
default:
|
||||
usage(av[0]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Ensure that there are some input files present.
|
||||
*/
|
||||
if(ac > optind) {
|
||||
ac -= optind;
|
||||
av += optind;
|
||||
} else {
|
||||
fprintf(stderr, "%s: No input files specified\n", av[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
setvbuf(stdout, 0, _IOLBF, 0);
|
||||
|
||||
/*
|
||||
* Iterate over input files and parse each.
|
||||
* All syntax trees from all files will be bundled together.
|
||||
*/
|
||||
for(int i = 0; i < ac; i++) {
|
||||
if(unber_file(av[i])) exit(EX_DATAERR);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Print the usage screen and exit(EX_USAGE).
|
||||
*/
|
||||
static void
|
||||
usage(const char *av0) {
|
||||
/* clang-format off */
|
||||
fprintf(stderr,
|
||||
"ASN.1 BER Decoder, v" VERSION "\n" COPYRIGHT
|
||||
"Usage: %s [options] [-] [file ...]\n"
|
||||
"Options:\n"
|
||||
" -1 Decode only the first BER structure (otherwise, until EOF)\n"
|
||||
" -i <indent> Amount of spaces for output indentation (default is 4)\n"
|
||||
" -m Minimalistic mode: print as little as possible\n"
|
||||
" -p Do not attempt pretty-printing of known ASN.1 types\n"
|
||||
" -s <skip> Ignore first <skip> bytes of input\n"
|
||||
" -t <hex-string> Decode the given tag[/length] sequence (e.g. -t \"bf20\")\n"
|
||||
"\n"
|
||||
"The XML opening tag format is as follows:\n"
|
||||
" <tform O=\"off\" T=\"tag\" TL=\"tl_len\" V=\"{Indefinite|v_len}\" [A=\"type\"] [F]>\n"
|
||||
"Where:\n"
|
||||
" tform Which form the value is in: constructed (\"C\", \"I\") or primitive (\"P\")\n"
|
||||
" off Offset of the encoded element in the unber input stream\n"
|
||||
" tag The tag class and value in human readable form\n"
|
||||
" tl_len The length of the TL (BER Tag and Length) encoding\n"
|
||||
" v_len The length of the value (V, encoded by the L), may be \"Indefinite\"\n"
|
||||
" type Likely name of the underlying ASN.1 type (for [UNIVERSAL n] tags)\n"
|
||||
" [F] Indicates that the value was reformatted (pretty-printed)\n"
|
||||
"See the manual page for details\n"
|
||||
, av0);
|
||||
/* clang-format on */
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
|
|
@ -1,26 +1,20 @@
|
|||
|
||||
SUBDIRS = . tests
|
||||
@CODE_COVERAGE_RULES@
|
||||
|
||||
AM_CFLAGS = @ADD_CFLAGS@
|
||||
AM_CPPFLAGS = \
|
||||
-I${top_srcdir}/libasn1compiler \
|
||||
-I${top_srcdir}/libasn1parser \
|
||||
-I${top_srcdir}/libasn1print \
|
||||
-I${top_srcdir}/libasn1fix \
|
||||
-I${top_srcdir}/skeletons \
|
||||
-DDATADIR=\"$(pkgdatadir)\"
|
||||
AM_CPPFLAGS = \
|
||||
-I${top_srcdir}/libasn1compiler \
|
||||
-I${top_srcdir}/libasn1common \
|
||||
-I${top_srcdir}/libasn1parser \
|
||||
-I${top_srcdir}/libasn1print \
|
||||
-I${top_srcdir}/libasn1fix \
|
||||
-I${top_srcdir}/skeletons \
|
||||
-DDATADIR=\"$(pkgdatadir)\"
|
||||
|
||||
asn1c_LDADD = \
|
||||
$(top_builddir)/libasn1parser/libasn1parser.la \
|
||||
$(top_builddir)/libasn1print/libasn1print.la \
|
||||
$(top_builddir)/libasn1fix/libasn1fix.la \
|
||||
$(top_builddir)/libasn1compiler/libasn1compiler.la
|
||||
asn1c_LDADD = \
|
||||
$(top_builddir)/libasn1common/libasn1common.la \
|
||||
$(top_builddir)/libasn1parser/libasn1parser.la \
|
||||
$(top_builddir)/libasn1print/libasn1print.la \
|
||||
$(top_builddir)/libasn1fix/libasn1fix.la \
|
||||
$(top_builddir)/libasn1compiler/libasn1compiler.la
|
||||
|
||||
bin_PROGRAMS = asn1c unber enber
|
||||
|
||||
noinst_HEADERS = sys-common.h
|
||||
|
||||
dist_check_SCRIPTS = check-xxber.sh check-parsing.sh
|
||||
TESTS_ENVIRONMENT= top_srcdir=${top_srcdir}
|
||||
TESTS = $(dist_check_SCRIPTS)
|
||||
CLEANFILES = .check-xxber.*.tmp .check-parsing.*.tmp
|
||||
bin_PROGRAMS = asn1c
|
||||
|
|
|
@ -1,3 +1 @@
|
|||
asn1c - The ASN.1 Compiler
|
||||
unber - The ASN.1 BER Decoder
|
||||
enber - Reverse unber(1) output back into BER
|
||||
|
|
167
asn1c/asn1c.c
167
asn1c/asn1c.c
|
@ -1,6 +1,6 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2016
|
||||
* Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
/*
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info> and contributors.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -23,21 +23,21 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
/*
|
||||
* This is the program that connects the libasn1* libraries together.
|
||||
* It uses them in turn to parse, fix and then compile or print the ASN.1 tree.
|
||||
*/
|
||||
#include "sys-common.h"
|
||||
#include "asn1_common.h"
|
||||
|
||||
#undef COPYRIGHT
|
||||
#define COPYRIGHT "Copyright (c) 2003-2016 Lev Walkin <vlm@lionet.info>\n"
|
||||
#define COPYRIGHT "Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info> and contributors.\n"
|
||||
|
||||
#include <asn1parser.h> /* Parse the ASN.1 file and build a tree */
|
||||
#include <asn1fix.h> /* Fix the ASN.1 tree */
|
||||
#include <asn1print.h> /* Print the ASN.1 tree */
|
||||
#include <asn1compiler.h> /* Compile the ASN.1 tree */
|
||||
#include <asn1fix_export.h>
|
||||
|
||||
#include <asn1c_compat.h> /* Portable basename(3) and dirname(3) */
|
||||
|
||||
|
@ -55,21 +55,56 @@ int
|
|||
main(int ac, char **av) {
|
||||
enum asn1p_flags asn1_parser_flags = A1P_NOFLAGS;
|
||||
enum asn1f_flags asn1_fixer_flags = A1F_NOFLAGS;
|
||||
enum asn1c_flags asn1_compiler_flags = A1C_NO_C99;
|
||||
enum asn1c_flags asn1_compiler_flags =
|
||||
A1C_NO_C99 | A1C_GEN_OER | A1C_GEN_PER | A1C_GEN_EXAMPLE;
|
||||
enum asn1print_flags asn1_printer_flags = APF_NOFLAGS;
|
||||
int print_arg__print_out = 0; /* Don't compile, just print parsed */
|
||||
int print_arg__fix_n_print = 0; /* Fix and print */
|
||||
int warnings_as_errors = 0; /* Treat warnings as errors */
|
||||
char *skeletons_dir = NULL; /* Directory with supplementary stuff */
|
||||
char *destdir = NULL; /* Destination for generated files */
|
||||
char **debug_type_names = 0; /* Debug stuff */
|
||||
size_t debug_type_names_count = 0;
|
||||
asn1p_t *asn = 0; /* An ASN.1 parsed tree */
|
||||
int ret; /* Return value from misc functions */
|
||||
int ch; /* Command line character */
|
||||
int i; /* Index in some loops */
|
||||
int exit_code = 0; /* Exit code */
|
||||
|
||||
/*
|
||||
* Process command-line options.
|
||||
*/
|
||||
while((ch = getopt(ac, av, "EFf:g:hLPp:RS:vW:X")) != -1) switch(ch) {
|
||||
while((ch = getopt(ac, av, "D:d:EFf:g:hn:LPp:RS:vW:X")) != -1) switch(ch) {
|
||||
case 'D':
|
||||
if(optarg && *optarg) {
|
||||
size_t optarg_len = strlen(optarg);
|
||||
free(destdir);
|
||||
destdir = calloc(1, optarg_len + 2); /* + "/\0" */
|
||||
assert(destdir);
|
||||
strcpy(destdir, optarg);
|
||||
if(destdir[optarg_len - 1] != '/') {
|
||||
destdir[optarg_len] = '/';
|
||||
}
|
||||
} else {
|
||||
free(destdir);
|
||||
destdir = NULL;
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
if(strncmp(optarg, "ebug-type-naming=", 17) == 0) {
|
||||
char **p = realloc(debug_type_names,
|
||||
(debug_type_names_count + 2) * sizeof(*p));
|
||||
assert(p);
|
||||
debug_type_names = p;
|
||||
debug_type_names[debug_type_names_count++] =
|
||||
strdup(optarg + 17);
|
||||
debug_type_names[debug_type_names_count] = NULL;
|
||||
break;
|
||||
} else if(strcmp(optarg, "ebug-output-origin-lines") == 0) {
|
||||
asn1_compiler_flags |= A1C_DEBUG_OUTPUT_ORIGIN_LINES;
|
||||
break;
|
||||
}
|
||||
usage(av[0]);
|
||||
case 'E':
|
||||
print_arg__print_out = 1;
|
||||
break;
|
||||
|
@ -117,6 +152,12 @@ main(int ac, char **av) {
|
|||
case 'g':
|
||||
if(strcmp(optarg, "en-PER") == 0) {
|
||||
asn1_compiler_flags |= A1C_GEN_PER;
|
||||
} else if(strcmp(optarg, "en-OER") == 0) {
|
||||
asn1_compiler_flags |= A1C_GEN_OER;
|
||||
} else if(strcmp(optarg, "en-example") == 0) {
|
||||
asn1_compiler_flags |= A1C_GEN_EXAMPLE;
|
||||
} else if(strcmp(optarg, "en-autotools") == 0) {
|
||||
asn1_compiler_flags |= A1C_GEN_AUTOTOOLS_EXAMPLE;
|
||||
} else {
|
||||
fprintf(stderr, "-g%s: Invalid argument\n", optarg);
|
||||
exit(EX_USAGE);
|
||||
|
@ -124,6 +165,20 @@ main(int ac, char **av) {
|
|||
break;
|
||||
case 'h':
|
||||
usage(av[0]);
|
||||
case 'n':
|
||||
if(strcmp(optarg, "o-gen-PER") == 0) {
|
||||
asn1_compiler_flags &= ~A1C_GEN_PER;
|
||||
} else if(strcmp(optarg, "o-gen-OER") == 0) {
|
||||
asn1_compiler_flags &= ~A1C_GEN_OER;
|
||||
} else if(strcmp(optarg, "o-gen-example") == 0) {
|
||||
asn1_compiler_flags &= ~A1C_GEN_EXAMPLE;
|
||||
} else if(strcmp(optarg, "o-gen-autotools") == 0) {
|
||||
asn1_compiler_flags &= ~A1C_GEN_AUTOTOOLS_EXAMPLE;
|
||||
} else {
|
||||
fprintf(stderr, "-n%s: Invalid argument\n", optarg);
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
break;
|
||||
case 'P':
|
||||
asn1_compiler_flags |= A1C_PRINT_COMPILED;
|
||||
asn1_compiler_flags &= ~A1C_NO_C99;
|
||||
|
@ -169,7 +224,10 @@ main(int ac, char **av) {
|
|||
warnings_as_errors = 1;
|
||||
break;
|
||||
} else if(strcmp(optarg, "debug-lexer") == 0) {
|
||||
asn1_parser_flags |= A1P_LEXER_DEBUG;
|
||||
asn1_parser_flags |= A1P_DEBUG_LEXER;
|
||||
break;
|
||||
} else if(strcmp(optarg, "debug-parser") == 0) {
|
||||
asn1_parser_flags |= A1P_DEBUG_PARSER;
|
||||
break;
|
||||
} else if(strcmp(optarg, "debug-fixer") == 0) {
|
||||
asn1_fixer_flags |= A1F_DEBUG;
|
||||
|
@ -194,7 +252,14 @@ main(int ac, char **av) {
|
|||
/*
|
||||
* Validate the options combination.
|
||||
*/
|
||||
if(!print_arg__print_out) {
|
||||
if(print_arg__print_out) {
|
||||
if((asn1_printer_flags & APF_PRINT_CONSTRAINTS)
|
||||
&& !print_arg__fix_n_print) {
|
||||
fprintf(stderr,
|
||||
"Error: -print-constraints argument requires -E -F\n");
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
} else {
|
||||
if(print_arg__fix_n_print) {
|
||||
fprintf(stderr, "Error: -F requires -E\n");
|
||||
exit(EX_USAGE);
|
||||
|
@ -212,7 +277,7 @@ main(int ac, char **av) {
|
|||
ac -= optind;
|
||||
av += optind;
|
||||
} else {
|
||||
char *bin_name = a1c_basename(av[0]);
|
||||
const char *bin_name = a1c_basename(av[0], NULL);
|
||||
fprintf(stderr,
|
||||
"%s: No input files specified. "
|
||||
"Try '%s -h' for more information\n",
|
||||
|
@ -233,15 +298,15 @@ main(int ac, char **av) {
|
|||
* compute it from my file name:
|
||||
* ./asn1c/asn1c -> ./skeletons
|
||||
*/
|
||||
char *p;
|
||||
const char *skel_dir;
|
||||
size_t len;
|
||||
|
||||
p = a1c_dirname(av[-optind]);
|
||||
skel_dir = a1c_dirname(av[-optind]);
|
||||
|
||||
len = strlen(p) + sizeof("/../skeletons");
|
||||
len = strlen(skel_dir) + sizeof("/../skeletons");
|
||||
skeletons_dir = malloc(len);
|
||||
assert(skeletons_dir);
|
||||
snprintf(skeletons_dir, len, "%s/../skeletons", p);
|
||||
snprintf(skeletons_dir, len, "%s/../skeletons", skel_dir);
|
||||
if(stat(skeletons_dir, &sb)) {
|
||||
fprintf(stderr,
|
||||
"WARNING: skeletons are neither in "
|
||||
|
@ -262,7 +327,8 @@ main(int ac, char **av) {
|
|||
new_asn = asn1p_parse_file(av[i], asn1_parser_flags);
|
||||
if(new_asn == NULL) {
|
||||
fprintf(stderr, "Cannot parse \"%s\"\n", av[i]);
|
||||
exit(EX_DATAERR);
|
||||
exit_code = EX_DATAERR;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -286,7 +352,10 @@ main(int ac, char **av) {
|
|||
* Dump the parsed ASN.1 tree if -E specified and -F is NOT given.
|
||||
*/
|
||||
if(print_arg__print_out && !print_arg__fix_n_print) {
|
||||
if(asn1print(asn, asn1_printer_flags)) exit(EX_SOFTWARE);
|
||||
if(asn1print(asn, asn1_printer_flags)) {
|
||||
exit_code = EX_SOFTWARE;
|
||||
goto cleanup;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -294,7 +363,12 @@ main(int ac, char **av) {
|
|||
* Read in the files from skeletons/standard-modules
|
||||
*/
|
||||
if(importStandardModules(asn, skeletons_dir)) {
|
||||
if(warnings_as_errors) exit(EX_DATAERR);
|
||||
if(warnings_as_errors) {
|
||||
exit_code = EX_DATAERR;
|
||||
goto cleanup;
|
||||
}
|
||||
} else {
|
||||
asn1f_use_standard_namespaces(asn);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -305,19 +379,34 @@ main(int ac, char **av) {
|
|||
ret = asn1f_process(asn, asn1_fixer_flags,
|
||||
NULL /* default fprintf(stderr) */);
|
||||
switch(ret) {
|
||||
case 1:
|
||||
if(!warnings_as_errors) /* Fall through */
|
||||
case 0:
|
||||
case 0:
|
||||
break; /* All clear */
|
||||
case 1:
|
||||
if(!warnings_as_errors) {
|
||||
break;
|
||||
}
|
||||
/* Fall through */
|
||||
case -1:
|
||||
exit(EX_DATAERR); /* Fatal failure */
|
||||
exit_code = EX_DATAERR; /* Fatal failure */
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/*
|
||||
* Dump the parsed ASN.1 tree if -E specified and -F is given.
|
||||
*/
|
||||
if(print_arg__print_out && print_arg__fix_n_print) {
|
||||
if(asn1print(asn, asn1_printer_flags)) exit(EX_SOFTWARE);
|
||||
if(asn1print(asn, asn1_printer_flags)) {
|
||||
exit_code = EX_SOFTWARE;
|
||||
goto cleanup;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* -debug-type-naming=Type
|
||||
*/
|
||||
if(debug_type_names) {
|
||||
asn1c_debug_type_naming(asn, asn1_compiler_flags, debug_type_names);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -325,11 +414,16 @@ main(int ac, char **av) {
|
|||
* Compile the ASN.1 tree into a set of source files
|
||||
* of another language.
|
||||
*/
|
||||
if(asn1_compile(asn, skeletons_dir, asn1_compiler_flags, ac + optind,
|
||||
optind - 1, av - optind)) {
|
||||
exit(EX_SOFTWARE);
|
||||
if(asn1_compile(asn, skeletons_dir, destdir ? destdir : "",
|
||||
asn1_compiler_flags, ac + optind, optind, av - optind)) {
|
||||
exit_code = EX_SOFTWARE;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
asn1p_delete(asn);
|
||||
asn1p_lex_destroy();
|
||||
if (exit_code) exit(exit_code);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -413,6 +507,7 @@ importStandardModules(asn1p_t *asn, const char *skeletons_dir) {
|
|||
TQ_ADD(&(asn->modules), mod, mod_next);
|
||||
}
|
||||
asn1p_delete(new_asn);
|
||||
asn1p_lex_destroy();
|
||||
|
||||
#ifdef _WIN32
|
||||
} while(_findnext(dir, &c_file) == 0);
|
||||
|
@ -423,13 +518,18 @@ importStandardModules(asn1p_t *asn, const char *skeletons_dir) {
|
|||
closedir(dir);
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
free(pattern);
|
||||
#endif
|
||||
free(target_dir);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Print the usage screen and exit(EX_USAGE).
|
||||
*/
|
||||
static void
|
||||
static void __attribute__((noreturn))
|
||||
usage(const char *av0) {
|
||||
/* clang-format off */
|
||||
fprintf(stderr,
|
||||
|
@ -443,11 +543,13 @@ usage(const char *av0) {
|
|||
" -R Restrict output (tables only, no support code)\n"
|
||||
" -S <dir> Directory with support (skeleton?) files\n"
|
||||
" (Default is \"%s\")\n"
|
||||
" -D <dir> Destination directory for generated files (default current dir)\n"
|
||||
" -X Generate and print the XML DTD\n"
|
||||
"\n"
|
||||
|
||||
" -Werror Treat warnings as errors; abort if any warning\n"
|
||||
" -Wdebug-lexer Enable verbose debugging output from lexer\n"
|
||||
" -Wdebug-parser Enable verbose debugging output from parser\n"
|
||||
" -Wdebug-fixer --//-- semantics processor\n"
|
||||
" -Wdebug-compiler --//-- compiler\n"
|
||||
"\n"
|
||||
|
@ -458,13 +560,16 @@ usage(const char *av0) {
|
|||
" -fincludes-quoted Generate #includes in \"double\" instead of <angle> quotes\n"
|
||||
" -fknown-extern-type=<name> Pretend the specified type is known\n"
|
||||
" -fline-refs Include ASN.1 module's line numbers in comments\n"
|
||||
" -fno-constraints Do not generate constraint checking code\n"
|
||||
" -fno-include-deps Do not generate courtesy #includes for dependencies\n"
|
||||
" -fno-constraints Do not generate the constraint checking code\n"
|
||||
" -fno-include-deps Do not generate the courtesy #includes for dependencies\n"
|
||||
" -funnamed-unions Enable unnamed unions in structures\n"
|
||||
" -fwide-types Use INTEGER_t instead of \"long\" by default, etc.\n"
|
||||
"\n"
|
||||
|
||||
" -gen-PER Generate PER support code\n"
|
||||
" -no-gen-OER Do not generate the OER (X.696) support code\n"
|
||||
" -no-gen-PER Do not generate the PER (X.691) support code\n"
|
||||
" -no-gen-example Do not generate the ASN.1 format converter example\n"
|
||||
" -gen-autotools Generate example top-level configure.ac and Makefile.am\n"
|
||||
" -pdu={all|auto|Type} Generate PDU table (discover PDUs automatically)\n"
|
||||
"\n"
|
||||
|
||||
|
@ -473,7 +578,7 @@ usage(const char *av0) {
|
|||
" -print-lines Generate \"-- #line\" comments in -E output\n"
|
||||
|
||||
,
|
||||
a1c_basename(av0), DATADIR);
|
||||
a1c_basename(av0, NULL), DATADIR);
|
||||
/* clang-format on */
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Test diff(1) capabilities
|
||||
diff -a . . 2>/dev/null && diffArgs="-a" # Assume text files
|
||||
diff -u . . 2>/dev/null && diffArgs="$diffArgs -u" # Unified diff output
|
||||
|
||||
ec=0
|
||||
|
||||
set -e
|
||||
|
||||
PROCESSING=""
|
||||
print_status() {
|
||||
echo "Error while processing $PROCESSING"
|
||||
}
|
||||
|
||||
trap print_status EXIT
|
||||
|
||||
if [ "x${top_srcdir}" = "x" ]; then
|
||||
top_srcdir=".."
|
||||
fi
|
||||
|
||||
for ref in ${top_srcdir}/tests/*.asn1.-*; do
|
||||
# Figure out the initial source file used to generate this output.
|
||||
src=`echo "$ref" | sed -e 's/\.-[-a-zA-Z0-9=]*$//'`
|
||||
# Figure out compiler flags used to create the file.
|
||||
flags=`echo "$ref" | sed -e 's/.*\.-//'`
|
||||
echo "Checking $src against $ref"
|
||||
template=.tmp.check-parsing.$$
|
||||
oldversion=${template}.old
|
||||
newversion=${template}.new
|
||||
PROCESSING="$ref (from $src)"
|
||||
cat "$ref" | LANG=C sed -e 's/^found in .*/found in .../' > $oldversion
|
||||
(./asn1c -S ${top_srcdir}/skeletons "-$flags" "$src" | LANG=C sed -e 's/^found in .*/found in .../' > "$newversion") || ec=$?
|
||||
if [ $? = 0 ]; then
|
||||
diff $diffArgs "$oldversion" "$newversion" || ec=$?
|
||||
fi
|
||||
rm -f $oldversion $newversion
|
||||
if [ "$1" = "regenerate" ]; then
|
||||
./asn1c -S ${top_srcdir}/skeletons "-$flags" "$src" > "$ref"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $ec = 0 ]; then
|
||||
trap '' EXIT
|
||||
fi
|
||||
|
||||
exit $ec
|
|
@ -1,92 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
#
|
||||
# This script is designed to quickly create lots of files in underlying
|
||||
# test-* directories, do lots of other magic stuff and exit cleanly.
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
if [ "x$1" = "x" ]; then
|
||||
echo "Usage: $0 <check-NN.c>"
|
||||
exit
|
||||
fi
|
||||
|
||||
srcdir="${srcdir:-.}"
|
||||
abs_top_srcdir="${abs_top_srcdir:-$(pwd)/../../}"
|
||||
abs_top_builddir="${abs_top_builddir:-$(pwd)/../../}"
|
||||
|
||||
if echo "$*" | grep -q -- -- ; then
|
||||
TEST_DRIVER=$(echo "$*" | sed -e 's/ -- .*/--/g')
|
||||
source_full=$(echo "$*" | sed -e 's/.* //g')
|
||||
else
|
||||
TEST_DRIVER=""
|
||||
source_full="$1"
|
||||
fi
|
||||
|
||||
# Compute the .asn1 spec name by the given file name.
|
||||
source_short=$(echo "$source_full" | sed -e 's/.*\///')
|
||||
testno=$(echo "$source_short" | cut -f2 -d'-' | cut -f1 -d'.')
|
||||
|
||||
args=$(echo "$source_short" | sed -e 's/\.c[c]*$//')
|
||||
|
||||
OFS=$IFS
|
||||
IFS="."
|
||||
set $args
|
||||
shift
|
||||
IFS=$OFS
|
||||
AFLAGS="$*"
|
||||
|
||||
# Assume the test fails. Will be removed when it passes well.
|
||||
testdir=test-${args}
|
||||
if [ -f "${testdir}-FAILED" ]; then
|
||||
rm -rf "${testdir}"
|
||||
fi
|
||||
touch "${testdir}-FAILED"
|
||||
|
||||
mkdir -p "${testdir}"
|
||||
ln -fns "../${source_full}" "${testdir}"
|
||||
|
||||
asn_module=$(echo "${abs_top_srcdir}/tests/${testno}"-*.asn1)
|
||||
|
||||
# Create a Makefile for the project.
|
||||
cat > "$testdir/Makefile" <<EOM
|
||||
# This file is autogenerated by ../$0
|
||||
|
||||
COMMON_FLAGS= -I.
|
||||
CFLAGS = \${COMMON_FLAGS} ${CFLAGS:-} -g -O0
|
||||
CPPFLAGS = -DSRCDIR=../${srcdir}
|
||||
CXXFLAGS = \${COMMON_FLAGS} ${CXXFLAGS}
|
||||
|
||||
CC ?= ${CC}
|
||||
|
||||
all: check-executable
|
||||
check-executable: compiled-module *.c*
|
||||
@rm -f *.core
|
||||
\$(CC) \$(CPPFLAGS) \$(CFLAGS) -o check-executable *.c* -lm
|
||||
|
||||
# Compile the corresponding .asn1 spec.
|
||||
compiled-module: ${asn_module} ${abs_top_builddir}/asn1c/asn1c
|
||||
${abs_top_builddir}/asn1c/asn1c \\
|
||||
-S ${abs_top_srcdir}/skeletons \\
|
||||
-Wdebug-compiler \\
|
||||
${AFLAGS} ${asn_module}
|
||||
rm -f converter-sample.c
|
||||
@touch compiled-module
|
||||
|
||||
check-succeeded: check-executable
|
||||
@rm -f check-succeeded
|
||||
./check-executable
|
||||
@touch check-succeeded
|
||||
|
||||
check: check-succeeded
|
||||
|
||||
clean:
|
||||
@rm -f *.o check-executable
|
||||
EOM
|
||||
|
||||
# Perform building and checking
|
||||
${TEST_DRIVER} make -C "$testdir" check
|
||||
|
||||
# Make sure the test is not marked as failed any longer.
|
||||
rm -f "${testdir}-FAILED"
|
File diff suppressed because it is too large
Load Diff
275
configure.ac
275
configure.ac
|
@ -1,12 +1,10 @@
|
|||
AC_INIT([asn1c],[0.9.28],[vlm@lionet.info])
|
||||
AC_INIT([asn1c],[0.9.29],[vlm@lionet.info])
|
||||
|
||||
AC_CONFIG_AUX_DIR(config)
|
||||
AC_CONFIG_HEADER([config.h])
|
||||
AM_INIT_AUTOMAKE([foreign])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
LT_INIT
|
||||
|
||||
dnl Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_PROG_CPP
|
||||
|
@ -15,7 +13,15 @@ AC_PROG_LN_S
|
|||
AC_PROG_MAKE_SET
|
||||
AC_PROG_YACC
|
||||
AM_PROG_LEX
|
||||
AC_PATH_PROG(AR, ar, ar, $PATH:/usr/ucb:/usr/ccs/bin) dnl for Solaris
|
||||
dnl locate ar using standard macro (old automake 1.11 does not know about AM_PROG_AR)
|
||||
m4_ifdef([AM_PROG_AR],
|
||||
[AM_PROG_AR],
|
||||
[AC_PATH_PROG(AR, ar, ar, $PATH:/usr/ucb:/usr/ccs/bin)])
|
||||
|
||||
AC_PROG_CXX
|
||||
CXXFLAGS="-std=c++11"
|
||||
|
||||
LT_INIT
|
||||
|
||||
dnl If you need to see the details, just run make V=1.
|
||||
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||
|
@ -34,8 +40,8 @@ AC_ARG_ENABLE([ASN_DEBUG],
|
|||
[produce debug log during `make check` testing])],
|
||||
[enable_asn_debug=$enableval], [enable_asn_debug=no])
|
||||
AS_IF([test x$enable_asn_debug != xno], [
|
||||
TESTSUITE_CFLAGS="-DEMIT_ASN_DEBUG"
|
||||
SKELETONS_CFLAGS="-DEMIT_ASN_DEBUG"
|
||||
TESTSUITE_CFLAGS="-DASN_EMIT_DEBUG"
|
||||
SKELETONS_CFLAGS="-DASN_EMIT_DEBUG"
|
||||
])
|
||||
|
||||
AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="$CFLAGS -Wall"])
|
||||
|
@ -48,6 +54,8 @@ AX_CHECK_COMPILE_FLAG([-Wmissing-declarations],
|
|||
[CFLAGS="$CFLAGS -Wmissing-declarations"])
|
||||
|
||||
dnl There are legitimate uses for these features, disable warnings/errors.
|
||||
AX_CHECK_COMPILE_FLAG([-Wno-error=attributes],
|
||||
[CFLAGS="$CFLAGS -Wno-error=attributes"])
|
||||
AX_CHECK_COMPILE_FLAG([-Wno-error=cast-align],
|
||||
[CFLAGS="$CFLAGS -Wno-error=cast-align"])
|
||||
AX_CHECK_COMPILE_FLAG([-Wno-error=visibility],
|
||||
|
@ -55,28 +63,30 @@ AX_CHECK_COMPILE_FLAG([-Wno-error=visibility],
|
|||
AX_CHECK_COMPILE_FLAG([-Wno-error=parentheses-equality],
|
||||
[CFLAGS="$CFLAGS -Wno-error=parentheses-equality"])
|
||||
AX_CHECK_COMPILE_FLAG([-std=gnu99],
|
||||
[TESTSUITE_CFLAGS="$TESTSUITE_CFLAGS -std=gnu99"])
|
||||
[CFLAGS="$CFLAGS -std=gnu99"
|
||||
TESTSUITE_CFLAGS="${TESTSUITE_CFLAGS} -std=gnu99"])
|
||||
AX_CHECK_COMPILE_FLAG([-Wno-error=unused-variable],
|
||||
[TESTSUITE_CFLAGS="$TESTSUITE_CFLAGS -Wno-error=unused-variable"])
|
||||
[TESTSUITE_CFLAGS="${TESTSUITE_CFLAGS} -Wno-error=unused-variable"])
|
||||
|
||||
AC_ARG_ENABLE(Werror,
|
||||
[AS_HELP_STRING([--enable-Werror],
|
||||
[abort compilation after any C compiler warning])],
|
||||
[enable_werror=$enableval], [enable_werror=no])
|
||||
AS_IF([test x$enable_werror != xno], [
|
||||
ADD_CFLAGS="-Werror -W -Wpointer-arith"
|
||||
])
|
||||
dnl Lower the optimization level in tests to aid debugging.
|
||||
dnl AX_CHECK_COMPILE_FLAG([-O1],
|
||||
dnl [TESTSUITE_CFLAGS="${TESTSUITE_CFLAGS} -O1"])
|
||||
dnl AX_CHECK_COMPILE_FLAG([-fno-inline],
|
||||
dnl [TESTSUITE_CFLAGS="${TESTSUITE_CFLAGS} -fno-inline"])
|
||||
|
||||
AC_ARG_ENABLE(test-Werror,
|
||||
[AS_HELP_STRING([--enable-test-Werror],
|
||||
[abort compiling tests after any C compiler warning])],
|
||||
[enable_test_werror=$enableval], [enable_test_werror=no])
|
||||
AS_IF([test x$enable_test_werror != xno], [
|
||||
TESTSUITE_CFLAGS="-Werror -W -Wpointer-arith"
|
||||
])
|
||||
|
||||
AC_SUBST(ADD_CFLAGS)
|
||||
AC_SUBST(TESTSUITE_CFLAGS)
|
||||
AX_CODE_COVERAGE
|
||||
AS_IF([test x$enable_code_coverage != xno], [
|
||||
CFLAGS="$CFLAGS $CODE_COVERAGE_CFLAGS"
|
||||
# The CODE_COVERAGE_CPPFLAGS contains -DNDEBUG flag
|
||||
# which removes assert(...) macros from code coverage and improves the
|
||||
# branches score. But when it is defined it results in few
|
||||
# unsed-but-set-variable warnings that are treated as errors in the travis-ci
|
||||
# build because these variables are only used inside assert macros.
|
||||
# error: variable ‘ret’ set but not used [-Werror=unused-but-set-variable]
|
||||
#CPPFLAGS="$CPPFLAGS $CODE_COVERAGE_CPPFLAGS"
|
||||
CXXFLAGS="$CXXFLAGS $CODE_COVERAGE_CXXFLAGS"
|
||||
AC_SEARCH_LIBS(gcov_open, gcov, [LDFLAGS="$LDFLAGS $CODE_COVERAGE_LDFLAGS"])
|
||||
])
|
||||
|
||||
dnl Skeletons should be very compatible with most of the compilers, hence
|
||||
dnl very strict backward compatibility flags.
|
||||
|
@ -84,32 +94,181 @@ SKELETONS_CFLAGS="${ADD_CFLAGS} ${SKELETONS_CFLAGS}"
|
|||
AX_CHECK_COMPILE_FLAG([-std=c89],
|
||||
[SKELETONS_CFLAGS="$SKELETONS_CFLAGS -std=c89"])
|
||||
AX_CHECK_COMPILE_FLAG([-Wpedantic],
|
||||
[SKELETONS_CFLAGS="$SKELETONS_CFLAGS -Wpedantic"])
|
||||
AX_CHECK_COMPILE_FLAG([-Wno-duplicate-decl-specifier],
|
||||
[SKELETONS_CFLAGS="$SKELETONS_CFLAGS -Wno-duplicate-decl-specifier"])
|
||||
[SKELETONS_CFLAGS="$SKELETONS_CFLAGS -Wpedantic"],
|
||||
[
|
||||
dnl When -Wpedantic is not supported try the -pedantic instead. (gcc-4.7)
|
||||
dnl See https://gcc.gnu.org/gcc-4.8/changes.html
|
||||
AX_CHECK_COMPILE_FLAG([-pedantic],
|
||||
[SKELETONS_CFLAGS="$SKELETONS_CFLAGS -pedantic"], [], [-Werror])
|
||||
],
|
||||
[-Werror]) #clang 3.0 prints warning when the flag is not supported
|
||||
|
||||
AC_ARG_ENABLE(Werror,
|
||||
[AS_HELP_STRING([--enable-Werror],
|
||||
[abort compilation after any C compiler warning])],
|
||||
[enable_werror=$enableval], [enable_werror=no])
|
||||
AS_IF([test x$enable_werror != xno], [
|
||||
ADD_CFLAGS="${ADD_CFLAGS} -Werror -W -Wall -Wpointer-arith"
|
||||
SKELETONS_CFLAGS="${SKELETONS_CFLAGS} -Werror -W -Wall -Wpointer-arith"
|
||||
AX_CHECK_COMPILE_FLAG([-Wgnu],
|
||||
[SKELETONS_CFLAGS="${SKELETONS_CFLAGS} -Wgnu"])
|
||||
])
|
||||
|
||||
AX_CHECK_COMPILE_FLAG([-Wno-long-long],
|
||||
[SKELETONS_CFLAGS="${SKELETONS_CFLAGS} -Wno-long-long"])
|
||||
|
||||
AC_ARG_ENABLE(test-Werror,
|
||||
[AS_HELP_STRING([--enable-test-Werror],
|
||||
[abort compiling tests after any C compiler warning])],
|
||||
[enable_test_werror=$enableval], [enable_test_werror=no])
|
||||
AS_IF([test x$enable_test_werror != xno], [
|
||||
TESTSUITE_CFLAGS="${TESTSUITE_CFLAGS} -Werror -W -Wpointer-arith"
|
||||
])
|
||||
|
||||
dnl If requested and -m32 is available to create 32-bit code,
|
||||
dnl treat it like a special case to be checked.
|
||||
AC_ARG_ENABLE([test-32bit],
|
||||
[AS_HELP_STRING([--enable-test-32bit],
|
||||
[enable tests for 32-bit compatibility])],
|
||||
[enable_test_32bit=$enableval], [enable_test_32bit=no])
|
||||
AS_IF([test "x$enable_test_32bit" != xno], [
|
||||
AX_CHECK_COMPILE_FLAG([-m32], [CFLAGS_M32="-m32 -DEXPLICIT_32BIT"],
|
||||
[
|
||||
CFLAGS_M32=""
|
||||
AC_MSG_FAILURE([--enable-test-32bit=$enable_test_32bit is requested but not supported by the _AC_LANG compiler])
|
||||
])
|
||||
])
|
||||
AC_SUBST(CFLAGS_M32)
|
||||
AM_CONDITIONAL([EXPLICIT_M32], [test "x${CFLAGS_M32}" != "x"])
|
||||
|
||||
SANITIZER_CFLAGS=""
|
||||
|
||||
dnl Enable Undefined Behavior Sanitizer, if supported.
|
||||
AC_ARG_ENABLE([test-ubsan],
|
||||
[AS_HELP_STRING([--disable-test-ubsan],
|
||||
[disable Undefined Behavior Sanitizer for tests])],
|
||||
[disable_test_ubsan=$enableval], [disable_test_ubsan=maybe])
|
||||
AS_IF([test "x$disable_test_ubsan" != xno], [
|
||||
AX_CHECK_COMPILE_AND_LINK_FLAG([-fsanitize=undefined],
|
||||
[SANITIZER_CFLAGS="${SANITIZER_CFLAGS} -fsanitize=undefined"],
|
||||
[
|
||||
AS_IF([test "x$disable_test_ubsan" != xmaybe], [
|
||||
AC_MSG_FAILURE(
|
||||
[--disable-test-ubsan=$disable_test_ubsan is not supported on a target system.
|
||||
https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#how-to-build])])
|
||||
],
|
||||
[],
|
||||
[AC_LANG_PROGRAM([void test(int *);void test(int *n) { *n = 0; }])]
|
||||
)
|
||||
AX_CHECK_COMPILE_FLAG([-fno-sanitize-recover=undefined],
|
||||
[SANITIZER_CFLAGS="${SANITIZER_CFLAGS} -fno-sanitize-recover=undefined"])
|
||||
|
||||
dnl Unsigned integer overflow is enabled separately.
|
||||
AX_CHECK_COMPILE_AND_LINK_FLAG([-fsanitize=unsigned-integer-overflow],
|
||||
[SANITIZER_CFLAGS="${SANITIZER_CFLAGS} -fsanitize=unsigned-integer-overflow"], [], [], [AC_LANG_PROGRAM([int test(unsigned); int test(unsigned n) { return n + 1; }])])
|
||||
AX_CHECK_COMPILE_FLAG([-fno-sanitize-recover=unsigned-integer-overflow],
|
||||
[SANITIZER_CFLAGS="${SANITIZER_CFLAGS} -fno-sanitize-recover=unsigned-integer-overflow"])
|
||||
|
||||
dnl Nullability is enabled separately.
|
||||
AX_CHECK_COMPILE_AND_LINK_FLAG([-fsanitize=nullability],
|
||||
[SANITIZER_CFLAGS="${SANITIZER_CFLAGS} -fsanitize=nullability"])
|
||||
AX_CHECK_COMPILE_FLAG([-fno-sanitize-recover=nullability],
|
||||
[SANITIZER_CFLAGS="${SANITIZER_CFLAGS} -fno-sanitize-recover=nullability"])
|
||||
|
||||
dnl Keep error messages nice. Also consider:
|
||||
dnl export ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer
|
||||
dnl export UBSAN_OPTIONS=print_stacktrace=1
|
||||
AX_CHECK_COMPILE_FLAG([-fno-omit-frame-pointer],
|
||||
[SANITIZER_CFLAGS="${SANITIZER_CFLAGS} -fno-omit-frame-pointer"])
|
||||
])
|
||||
|
||||
dnl Enable Address Sanitizer, if supported by gcc (4.8+) or clang.
|
||||
dnl http://clang.llvm.org/docs/AddressSanitizer.html
|
||||
ASAN_ENV_FLAGS=""
|
||||
AC_ARG_ENABLE([test-asan],
|
||||
[AS_HELP_STRING([--disable-test-asan],
|
||||
[disable Address Sanitizer for tests])],
|
||||
[disable_test_asan=$enableval], [disable_test_asan=maybe])
|
||||
AS_IF([test "x$disable_test_asan" != xno], [
|
||||
AX_CHECK_COMPILE_AND_LINK_FLAG([-fsanitize=address],
|
||||
[SANITIZER_CFLAGS="${SANITIZER_CFLAGS} -fsanitize=address"],
|
||||
[
|
||||
AS_IF([test "x$disable_test_asan" != xmaybe], [
|
||||
AC_MSG_FAILURE(
|
||||
[--disable-test-asan=$disable_test_asan is not supported on a target system.
|
||||
Check out https://clang.llvm.org/docs/AddressSanitizer.html#how-to-build])])
|
||||
])
|
||||
|
||||
dnl Address sanitizer sometimes is equipped with the leak sanitizer.
|
||||
dnl If address sanitizer is not equipped with a leak sanitizer,
|
||||
dnl invoking programs with ASAN_OPTIONS=detect_leaks=1 will break them.
|
||||
ASAN_OPTIONS="detect_leaks=1"
|
||||
export ASAN_OPTIONS
|
||||
save_cflags="${CFLAGS}"
|
||||
CFLAGS="${CFLAGS} ${SANITIZER_CFLAGS}"
|
||||
AC_RUN_IFELSE([AC_LANG_PROGRAM()], [
|
||||
ASAN_ENV_FLAGS="${ASAN_ENV_FLAGS} ASAN_OPTIONS=detect_leaks=1"
|
||||
])
|
||||
CFLAGS="${save_cflags}"
|
||||
unset ASAN_OPTIONS
|
||||
|
||||
dnl Keep error messages nice. Also consider:
|
||||
dnl export ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer
|
||||
dnl export ASAN_OPTIONS=symbolize=1
|
||||
AX_CHECK_COMPILE_FLAG([-fno-omit-frame-pointer],
|
||||
[SANITIZER_CFLAGS="${SANITIZER_CFLAGS} -fno-omit-frame-pointer"])
|
||||
])
|
||||
|
||||
dnl Enable LibFuzzer, if supported.
|
||||
LIBFUZZER_CFLAGS=""
|
||||
AC_ARG_ENABLE([test-fuzzer],
|
||||
[AS_HELP_STRING([--enable-test-fuzzer],
|
||||
[enable LLVM LibFuzzer for randomized testing])],
|
||||
[enable_test_fuzzer=$enableval], [enable_test_fuzzer=no])
|
||||
AS_IF([test "x$enable_test_fuzzer" != xno], [
|
||||
AX_CHECK_COMPILE_AND_LINK_FLAG([-fsanitize=fuzzer],
|
||||
[LIBFUZZER_CFLAGS="-fsanitize=fuzzer -DENABLE_LIBFUZZER"],
|
||||
[AC_MSG_FAILURE(
|
||||
[--enable-test-fuzzer=$enable_test_fuzzer is not supported on a target system.
|
||||
Check out http://llvm.org/docs/LibFuzzer.html])],
|
||||
[],
|
||||
[AC_LANG_SOURCE([[
|
||||
#include <sys/types.h>
|
||||
int LLVMFuzzerTestOneInput(const unsigned char *Data, size_t Size);
|
||||
int LLVMFuzzerTestOneInput(const unsigned char *Data, size_t Size) {
|
||||
(void)Data;
|
||||
(void)Size;
|
||||
return 0;
|
||||
}
|
||||
]])])
|
||||
])
|
||||
|
||||
TESTSUITE_CFLAGS="${TESTSUITE_CFLAGS} ${SANITIZER_CFLAGS}"
|
||||
SKELETONS_CFLAGS="${SKELETONS_CFLAGS} ${SANITIZER_CFLAGS}"
|
||||
|
||||
AC_SUBST(ADD_CFLAGS)
|
||||
AC_SUBST(LIBFUZZER_CFLAGS)
|
||||
AC_SUBST(SANITIZER_CFLAGS)
|
||||
AC_SUBST(TESTSUITE_CFLAGS)
|
||||
AC_SUBST(SKELETONS_CFLAGS)
|
||||
AC_SUBST(ASAN_ENV_FLAGS)
|
||||
|
||||
dnl Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(sys/param.h)
|
||||
AC_CHECK_HEADERS(alloca.h)
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_BIGENDIAN
|
||||
AC_TYPE_OFF_T
|
||||
AC_TYPE_SIZE_T
|
||||
AC_STRUCT_TM
|
||||
AC_CHECK_TYPE([__int128],
|
||||
[AC_DEFINE(HAVE_128_BIT_INT, 1, [Have 128-bit integer])])
|
||||
AC_CHECK_TYPE(intmax_t, int64_t)
|
||||
|
||||
dnl Test if we should check features that depend on 64-bitness.
|
||||
AC_MSG_CHECKING(size of long is longer than 32 bit)
|
||||
AS_VAR_PUSHDEF([WIDE_LONG], [WIDE_LONG])
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include "confdefs.h"
|
||||
#include <sys/types.h>
|
||||
]], [[switch (0) case 0: case (sizeof ($1) >= 8):;]])],[WIDE_LONG=yes],[WIDE_LONG=no])
|
||||
AC_MSG_RESULT($WIDE_LONG)
|
||||
AM_CONDITIONAL([TEST_64BIT], [test x$WIDE_LONG = xyes])
|
||||
AS_VAR_POPDEF([WIDE_LONG])
|
||||
dnl Test if we should test features that depend on 64-bitness.
|
||||
AC_CHECK_SIZEOF([void *])
|
||||
AM_CONDITIONAL([TEST_64BIT], [test "$ac_cv_sizeof_void_p" -eq 8])
|
||||
|
||||
dnl For mingw
|
||||
AC_SEARCH_LIBS(getopt, iberty)
|
||||
|
@ -118,7 +277,8 @@ AC_CHECK_FUNCS(strtoimax strtoll)
|
|||
AC_CHECK_FUNCS(mergesort)
|
||||
AC_CHECK_FUNCS(mkstemps)
|
||||
AC_CHECK_FUNCS(timegm)
|
||||
AC_CHECK_DECLS(alloca strcasecmp)
|
||||
AC_CHECK_DECLS(strcasecmp)
|
||||
AC_CHECK_DECLS(vasprintf)
|
||||
AC_TRY_LINK_FUNC([symlink],[AC_DEFINE([HAVE_SYMLINK], 1, [Define to 1 if you have the symlink function.])])
|
||||
|
||||
dnl Use pandoc to generate manual pages.
|
||||
|
@ -126,21 +286,28 @@ AC_PATH_PROG([PANDOC], pandoc)
|
|||
AM_CONDITIONAL([HAVE_PANDOC], [test -n "$PANDOC"])
|
||||
|
||||
AC_CONFIG_FILES([\
|
||||
asn1c/tests/check-src/Makefile \
|
||||
skeletons/tests/Makefile \
|
||||
libasn1compiler/Makefile \
|
||||
libasn1parser/Makefile \
|
||||
libasn1print/Makefile \
|
||||
asn1c/tests/Makefile \
|
||||
libasn1fix/Makefile \
|
||||
doc/docsrc/Makefile \
|
||||
skeletons/Makefile \
|
||||
examples/Makefile \
|
||||
doc/man/Makefile \
|
||||
tests/Makefile \
|
||||
asn1c/Makefile \
|
||||
doc/Makefile \
|
||||
Makefile \
|
||||
tests/tests-c-compiler/check-src/Makefile \
|
||||
tests/tests-asn1c-compiler/Makefile \
|
||||
tests/tests-asn1c-smoke/Makefile \
|
||||
tests/tests-randomized/Makefile \
|
||||
tests/tests-c-compiler/Makefile \
|
||||
tests/tests-skeletons/Makefile \
|
||||
asn1-tools/enber/Makefile \
|
||||
asn1-tools/unber/Makefile \
|
||||
asn1-tools/Makefile \
|
||||
libasn1compiler/Makefile \
|
||||
libasn1common/Makefile \
|
||||
libasn1parser/Makefile \
|
||||
libasn1print/Makefile \
|
||||
libasn1fix/Makefile \
|
||||
doc/docsrc/Makefile \
|
||||
skeletons/Makefile \
|
||||
examples/Makefile \
|
||||
doc/man/Makefile \
|
||||
tests/Makefile \
|
||||
asn1c/Makefile \
|
||||
doc/Makefile \
|
||||
Makefile \
|
||||
])
|
||||
AC_OUTPUT
|
||||
|
||||
|
|
584
depcomp
584
depcomp
|
@ -1,584 +0,0 @@
|
|||
#! /bin/sh
|
||||
# depcomp - compile a program generating dependencies as side-effects
|
||||
|
||||
scriptversion=2006-10-15.18
|
||||
|
||||
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software
|
||||
# Foundation, Inc.
|
||||
|
||||
# This program 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 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program 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.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Run PROGRAMS ARGS to compile a file, generating dependencies
|
||||
as side-effects.
|
||||
|
||||
Environment variables:
|
||||
depmode Dependency tracking mode.
|
||||
source Source file read by `PROGRAMS ARGS'.
|
||||
object Object file output by `PROGRAMS ARGS'.
|
||||
DEPDIR directory where to store dependencies.
|
||||
depfile Dependency file to output.
|
||||
tmpdepfile Temporary file to use when outputing dependencies.
|
||||
libtool Whether libtool is used (yes/no).
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "depcomp $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
|
||||
echo "depcomp: Variables source, object and depmode must be set" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
|
||||
depfile=${depfile-`echo "$object" |
|
||||
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
|
||||
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
|
||||
|
||||
rm -f "$tmpdepfile"
|
||||
|
||||
# Some modes work just like other modes, but use different flags. We
|
||||
# parameterize here, but still list the modes in the big case below,
|
||||
# to make depend.m4 easier to write. Note that we *cannot* use a case
|
||||
# here, because this file can only contain one case statement.
|
||||
if test "$depmode" = hp; then
|
||||
# HP compiler uses -M and no extra arg.
|
||||
gccflag=-M
|
||||
depmode=gcc
|
||||
fi
|
||||
|
||||
if test "$depmode" = dashXmstdout; then
|
||||
# This is just like dashmstdout with a different argument.
|
||||
dashmflag=-xM
|
||||
depmode=dashmstdout
|
||||
fi
|
||||
|
||||
case "$depmode" in
|
||||
gcc3)
|
||||
## gcc 3 implements dependency tracking that does exactly what
|
||||
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
|
||||
## it if -MD -MP comes after the -MF stuff. Hmm.
|
||||
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
|
||||
## the command line argument order; so add the flags where they
|
||||
## appear in depend2.am. Note that the slowdown incurred here
|
||||
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
|
||||
*) set fnord "$@" "$arg" ;;
|
||||
esac
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
done
|
||||
"$@"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
mv "$tmpdepfile" "$depfile"
|
||||
;;
|
||||
|
||||
gcc)
|
||||
## There are various ways to get dependency output from gcc. Here's
|
||||
## why we pick this rather obscure method:
|
||||
## - Don't want to use -MD because we'd like the dependencies to end
|
||||
## up in a subdir. Having to rename by hand is ugly.
|
||||
## (We might end up doing this anyway to support other compilers.)
|
||||
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
|
||||
## -MM, not -M (despite what the docs say).
|
||||
## - Using -M directly means running the compiler twice (even worse
|
||||
## than renaming).
|
||||
if test -z "$gccflag"; then
|
||||
gccflag=-MD,
|
||||
fi
|
||||
"$@" -Wp,"$gccflag$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
|
||||
## The second -e expression handles DOS-style file names with drive letters.
|
||||
sed -e 's/^[^:]*: / /' \
|
||||
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
|
||||
## This next piece of magic avoids the `deleted header file' problem.
|
||||
## The problem is that when a header file which appears in a .P file
|
||||
## is deleted, the dependency causes make to die (because there is
|
||||
## typically no way to rebuild the header). We avoid this by adding
|
||||
## dummy dependencies for each header file. Too bad gcc doesn't do
|
||||
## this for us directly.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" |
|
||||
## Some versions of gcc put a space before the `:'. On the theory
|
||||
## that the space means something, we add a space to the output as
|
||||
## well.
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
sgi)
|
||||
if test "$libtool" = yes; then
|
||||
"$@" "-Wp,-MDupdate,$tmpdepfile"
|
||||
else
|
||||
"$@" -MDupdate "$tmpdepfile"
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
|
||||
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
|
||||
echo "$object : \\" > "$depfile"
|
||||
|
||||
# Clip off the initial element (the dependent). Don't try to be
|
||||
# clever and replace this with sed code, as IRIX sed won't handle
|
||||
# lines with more than a fixed number of characters (4096 in
|
||||
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
|
||||
# the IRIX cc adds comments like `#:fec' to the end of the
|
||||
# dependency line.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
|
||||
tr '
|
||||
' ' ' >> $depfile
|
||||
echo >> $depfile
|
||||
|
||||
# The second pass generates a dummy entry for each header file.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
|
||||
>> $depfile
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
# "include basename.Plo" scheme.
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
aix)
|
||||
# The C for AIX Compiler uses -M and outputs the dependencies
|
||||
# in a .u file. In older versions, this file always lives in the
|
||||
# current directory. Also, the AIX compiler puts `$object:' at the
|
||||
# start of each line; $object doesn't have directory information.
|
||||
# Version 6 uses the directory in both cases.
|
||||
stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
|
||||
tmpdepfile="$stripped.u"
|
||||
if test "$libtool" = yes; then
|
||||
"$@" -Wc,-M
|
||||
else
|
||||
"$@" -M
|
||||
fi
|
||||
stat=$?
|
||||
|
||||
if test -f "$tmpdepfile"; then :
|
||||
else
|
||||
stripped=`echo "$stripped" | sed 's,^.*/,,'`
|
||||
tmpdepfile="$stripped.u"
|
||||
fi
|
||||
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
if test -f "$tmpdepfile"; then
|
||||
outname="$stripped.o"
|
||||
# Each line is of the form `foo.o: dependent.h'.
|
||||
# Do two passes, one to just change these to
|
||||
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
|
||||
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
# "include basename.Plo" scheme.
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
icc)
|
||||
# Intel's C compiler understands `-MD -MF file'. However on
|
||||
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
|
||||
# ICC 7.0 will fill foo.d with something like
|
||||
# foo.o: sub/foo.c
|
||||
# foo.o: sub/foo.h
|
||||
# which is wrong. We want:
|
||||
# sub/foo.o: sub/foo.c
|
||||
# sub/foo.o: sub/foo.h
|
||||
# sub/foo.c:
|
||||
# sub/foo.h:
|
||||
# ICC 7.1 will output
|
||||
# foo.o: sub/foo.c sub/foo.h
|
||||
# and will wrap long lines using \ :
|
||||
# foo.o: sub/foo.c ... \
|
||||
# sub/foo.h ... \
|
||||
# ...
|
||||
|
||||
"$@" -MD -MF "$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
# Each line is of the form `foo.o: dependent.h',
|
||||
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
|
||||
# Do two passes, one to just change these to
|
||||
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
|
||||
sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp2)
|
||||
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
|
||||
# compilers, which have integrated preprocessors. The correct option
|
||||
# to use with these is +Maked; it writes dependencies to a file named
|
||||
# 'foo.d', which lands next to the object file, wherever that
|
||||
# happens to be.
|
||||
# Much of this is similar to the tru64 case; see comments there.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir.libs/$base.d
|
||||
"$@" -Wc,+Maked
|
||||
else
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
"$@" +Maked
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
|
||||
# Add `dependent.h:' lines.
|
||||
sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile" "$tmpdepfile2"
|
||||
;;
|
||||
|
||||
tru64)
|
||||
# The Tru64 compiler uses -MD to generate dependencies as a side
|
||||
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
|
||||
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
|
||||
# dependencies in `foo.d' instead, so we check for that too.
|
||||
# Subdirectories are respected.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
|
||||
if test "$libtool" = yes; then
|
||||
# With Tru64 cc, shared objects can also be used to make a
|
||||
# static library. This mechanism is used in libtool 1.4 series to
|
||||
# handle both shared and static libraries in a single compilation.
|
||||
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
|
||||
#
|
||||
# With libtool 1.5 this exception was removed, and libtool now
|
||||
# generates 2 separate objects for the 2 libraries. These two
|
||||
# compilations output dependencies in $dir.libs/$base.o.d and
|
||||
# in $dir$base.o.d. We have to check for both files, because
|
||||
# one of the two compilations can be disabled. We should prefer
|
||||
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
|
||||
# automatically cleaned when .libs/ is deleted, while ignoring
|
||||
# the former would cause a distcleancheck panic.
|
||||
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
|
||||
tmpdepfile2=$dir$base.o.d # libtool 1.5
|
||||
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
|
||||
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
|
||||
"$@" -Wc,-MD
|
||||
else
|
||||
tmpdepfile1=$dir$base.o.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
tmpdepfile3=$dir$base.d
|
||||
tmpdepfile4=$dir$base.d
|
||||
"$@" -MD
|
||||
fi
|
||||
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
|
||||
# That's a tab and a space in the [].
|
||||
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
#nosideeffect)
|
||||
# This comment above is used by automake to tell side-effect
|
||||
# dependency tracking mechanisms from slower ones.
|
||||
|
||||
dashmstdout)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout, regardless of -o.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test $1 != '--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove `-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
test -z "$dashmflag" && dashmflag=-M
|
||||
# Require at least two characters before searching for `:'
|
||||
# in the target name. This is to cope with DOS-style filenames:
|
||||
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
|
||||
"$@" $dashmflag |
|
||||
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" | \
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
dashXmstdout)
|
||||
# This case only exists to satisfy depend.m4. It is never actually
|
||||
# run, as this mode is specially recognized in the preamble.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
makedepend)
|
||||
"$@" || exit $?
|
||||
# Remove any Libtool call
|
||||
if test "$libtool" = yes; then
|
||||
while test $1 != '--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
# X makedepend
|
||||
shift
|
||||
cleared=no
|
||||
for arg in "$@"; do
|
||||
case $cleared in
|
||||
no)
|
||||
set ""; shift
|
||||
cleared=yes ;;
|
||||
esac
|
||||
case "$arg" in
|
||||
-D*|-I*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
# Strip any option that makedepend may not understand. Remove
|
||||
# the object too, otherwise makedepend will parse it as a source file.
|
||||
-*|$object)
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
esac
|
||||
done
|
||||
obj_suffix="`echo $object | sed 's/^.*\././'`"
|
||||
touch "$tmpdepfile"
|
||||
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
sed '1,2d' "$tmpdepfile" | tr ' ' '
|
||||
' | \
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile" "$tmpdepfile".bak
|
||||
;;
|
||||
|
||||
cpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test $1 != '--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove `-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
"$@" -E |
|
||||
sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
|
||||
sed '$ s: \\$::' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
cat < "$tmpdepfile" >> "$depfile"
|
||||
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvisualcpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout, regardless of -o,
|
||||
# because we must use -o when running libtool.
|
||||
"$@" || exit $?
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case "$arg" in
|
||||
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
|
||||
set fnord "$@"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
"$@" -E |
|
||||
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
|
||||
echo " " >> "$depfile"
|
||||
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
none)
|
||||
exec "$@"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown depmode $depmode" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-end: "$"
|
||||
# End:
|
Binary file not shown.
|
@ -8,6 +8,6 @@ regen:
|
|||
$(XELATEX) $(XELATEX_FLAGS) -no-pdf $(TEXSRC)
|
||||
$(XELATEX) $(XELATEX_FLAGS) $(TEXSRC)
|
||||
|
||||
EXTRA_DIST = $(srcdir)/*.tex
|
||||
EXTRA_DIST = $(srcdir)/*.tex $(srcdir)/*.inc
|
||||
|
||||
CLEANFILES = *.*~ *.aux *.dvi *.log *.out *.toc
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,30 @@
|
|||
|
||||
Upon unsuccessful termination, the \code{*struct_ptr_ptr}
|
||||
may contain partially decoded data. This data may be useful for debugging
|
||||
(such as by using \code{asn_fprint()}).
|
||||
Don't forget to discard the unused partially decoded data by calling
|
||||
\code{ASN_STRUCT_FREE()} or \code{ASN_STRUCT_RESET()}.
|
||||
|
||||
The function returns a compound structure:
|
||||
\begin{codesample}
|
||||
typedef struct {
|
||||
enum {
|
||||
RC_OK, /* Decoded successfully */
|
||||
RC_WMORE, /* More data expected, call again */
|
||||
RC_FAIL /* Failure to decode data */
|
||||
} code; /* Result code */
|
||||
size_t consumed; /* Number of bytes consumed */
|
||||
} asn_dec_rval_t;
|
||||
\end{codesample}
|
||||
|
||||
\noindent{}The \code{.code} member specifies the decoding outcome.
|
||||
|
||||
\begin{tabular}[h!]{ll}
|
||||
\texttt{RC\_OK} & Decoded successfully and completely \\
|
||||
\texttt{RC\_WMORE} & More data expected, call again \\
|
||||
\texttt{RC\_FAIL} & Failed for good
|
||||
\end{tabular}
|
||||
|
||||
\noindent{}The \code{.consumed} member specifies the amount of \code{buffer} data
|
||||
that was used during parsing, irrespectively of the \code{.code}.
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
The function returns a compound structure:
|
||||
|
||||
\begin{codesample}
|
||||
typedef struct {
|
||||
ssize_t encoded;
|
||||
const asn_TYPE_descriptor_t *failed_type;
|
||||
const void *structure_ptr;
|
||||
} asn_enc_rval_t;
|
||||
\end{codesample}
|
||||
|
||||
\noindent{}In case of unsuccessful encoding, the \code{.encoded} member is set to -1 and
|
||||
the other members of the compound structure point to where the encoding has
|
||||
failed to proceed further.
|
||||
|
||||
In case encoding is successful, the \code{.encoded} member specifies the
|
||||
size of the serialized output.
|
141
doc/man/asn1c.1
141
doc/man/asn1c.1
|
@ -1,7 +1,8 @@
|
|||
.\" Automatically generated by Pandoc 1.16.0.2
|
||||
.\"t
|
||||
.\" Automatically generated by Pandoc 1.19.2.1
|
||||
.\"
|
||||
.ad l
|
||||
.TH "asn1c" "1" "2016\-01\-23" "ASN.1 Compiler" "Version 0.9.28"
|
||||
.TH "asn1c" "1" "2017\-09\-01" "ASN.1 Compiler" "Version 0.9.29"
|
||||
.nh \" Turn off hyphenation by default.
|
||||
.SH NAME
|
||||
.PP
|
||||
|
@ -30,8 +31,8 @@ asn1c [\f[B]\-E\f[] [\f[B]\-F\f[]] | \f[B]\-P\f[] | \f[B]\-R\f[]]
|
|||
.SH DESCRIPTION
|
||||
.PP
|
||||
asn1c compiles ASN.1 specifications into a set of target language
|
||||
(C/C++) encoders and decoders for BER, DER, PER, XER and other encoding
|
||||
rules.
|
||||
(C/C++) encoders and decoders for BER, DER, PER, XER, OER and other
|
||||
encoding rules.
|
||||
.SH OPTIONS
|
||||
.SS Stage Selection Options
|
||||
.TP
|
||||
|
@ -77,6 +78,11 @@ Treat warnings as errors; abort if any warning is produced.
|
|||
.RE
|
||||
.TP
|
||||
.B \-Wdebug\-lexer
|
||||
Enable lexer debugging during the ASN.1 lexing stage.
|
||||
.RS
|
||||
.RE
|
||||
.TP
|
||||
.B \-Wdebug\-parser
|
||||
Enable lexer debugging during the ASN.1 parsing stage.
|
||||
.RS
|
||||
.RE
|
||||
|
@ -163,6 +169,11 @@ native machine\[aq]s data types (long, double).
|
|||
.RE
|
||||
.SS Codecs Generation Options
|
||||
.TP
|
||||
.B \-gen\-OER
|
||||
Generate the Octet Encoding Rules (OER) support code.
|
||||
.RS
|
||||
.RE
|
||||
.TP
|
||||
.B \-gen\-PER
|
||||
Generate the Packed Encoding Rules (PER) support code.
|
||||
.RS
|
||||
|
@ -192,6 +203,128 @@ compiler to explain its internal understanding of subtype constraints.
|
|||
Generate "\f[C]\-\-\ #line\f[]" comments in \f[B]\-E\f[] output.
|
||||
.RS
|
||||
.RE
|
||||
.SH TRANSFER SYNTAXES
|
||||
.PP
|
||||
The ASN.1 family of standards define a number of ways to encode data,
|
||||
including byte\-oriented (e.g., BER), bit\-oriented (e.g., PER), and
|
||||
textual (e.g., XER).
|
||||
Some encoding variants (e.g., DER) are just stricter variants of the
|
||||
more general encodings (e.g., BER).
|
||||
.PP
|
||||
The interoperability table below specifies which API functions can be
|
||||
used to exchange data in a compatible manner.
|
||||
If you need to \f[I]produce\f[] data conforming to the standard
|
||||
specified in the column 1, use the API function in the column 2.
|
||||
If you need to \f[I]process\f[] data conforming to the standard(s)
|
||||
specified in the column 3, use the API function specified in column 4.
|
||||
See the \f[C]asn1c\-usage.pdf\f[] for details.
|
||||
.PP
|
||||
.TS
|
||||
tab(@);
|
||||
lw(14.6n) lw(18.5n) lw(13.6n) lw(13.6n).
|
||||
T{
|
||||
Encoding
|
||||
T}@T{
|
||||
API function
|
||||
T}@T{
|
||||
Understood by
|
||||
T}@T{
|
||||
API function
|
||||
T}
|
||||
_
|
||||
T{
|
||||
BER
|
||||
T}@T{
|
||||
der_encode()
|
||||
T}@T{
|
||||
BER
|
||||
T}@T{
|
||||
ber_decode()
|
||||
T}
|
||||
T{
|
||||
DER
|
||||
T}@T{
|
||||
der_encode()
|
||||
T}@T{
|
||||
DER, BER
|
||||
T}@T{
|
||||
ber_decode()
|
||||
T}
|
||||
T{
|
||||
CER
|
||||
T}@T{
|
||||
\f[I]not supported\f[]
|
||||
T}@T{
|
||||
CER, BER
|
||||
T}@T{
|
||||
ber_decode()
|
||||
T}
|
||||
T{
|
||||
BASIC\-OER
|
||||
T}@T{
|
||||
oer_encode()
|
||||
T}@T{
|
||||
*\-OER
|
||||
T}@T{
|
||||
oer_decode()
|
||||
T}
|
||||
T{
|
||||
CANONICAL\-OER
|
||||
T}@T{
|
||||
oer_encode()
|
||||
T}@T{
|
||||
*\-OER
|
||||
T}@T{
|
||||
oer_decode()
|
||||
T}
|
||||
T{
|
||||
BASIC\-UPER
|
||||
T}@T{
|
||||
uper_encode()
|
||||
T}@T{
|
||||
*\-UPER
|
||||
T}@T{
|
||||
uper_decode()
|
||||
T}
|
||||
T{
|
||||
CANONICAL\-UPER
|
||||
T}@T{
|
||||
uper_encode()
|
||||
T}@T{
|
||||
*\-UPER
|
||||
T}@T{
|
||||
uper_decode()
|
||||
T}
|
||||
T{
|
||||
*\-APER
|
||||
T}@T{
|
||||
\f[I]not supported\f[]
|
||||
T}@T{
|
||||
*\-APER
|
||||
T}@T{
|
||||
\f[I]not supported\f[]
|
||||
T}
|
||||
T{
|
||||
BASIC\-XER
|
||||
T}@T{
|
||||
xer_encode(...)
|
||||
T}@T{
|
||||
*\-XER
|
||||
T}@T{
|
||||
xer_decode()
|
||||
T}
|
||||
T{
|
||||
CANONICAL\-XER
|
||||
T}@T{
|
||||
xer_encode (XER_F_CANONICAL)
|
||||
T}@T{
|
||||
*\-XER
|
||||
T}@T{
|
||||
xer_decode()
|
||||
T}
|
||||
.TE
|
||||
.PP
|
||||
*) Asterisk means both BASIC and CANONICAL variants.
|
||||
.SH SEE ALSO
|
||||
.PP
|
||||
\f[C]unber\f[](1), \f[C]enber\f[](1).
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
% asn1c(1) ASN.1 Compiler
|
||||
% Lev Walkin <vlm@lionet.info>
|
||||
% 2016-01-23
|
||||
% 2017-09-01
|
||||
|
||||
# NAME
|
||||
|
||||
|
@ -18,7 +18,7 @@ asn1c [**-E** [**-F**] | **-P** | **-R**] \
|
|||
# DESCRIPTION
|
||||
|
||||
asn1c compiles ASN.1 specifications into a set of
|
||||
target language (C/C++) encoders and decoders for BER, DER, PER, XER
|
||||
target language (C/C++) encoders and decoders for BER, DER, PER, XER, OER
|
||||
and other encoding rules.
|
||||
|
||||
# OPTIONS
|
||||
|
@ -54,6 +54,9 @@ and other encoding rules.
|
|||
: Treat warnings as errors; abort if any warning is produced.
|
||||
|
||||
-Wdebug-lexer
|
||||
: Enable lexer debugging during the ASN.1 lexing stage.
|
||||
|
||||
-Wdebug-parser
|
||||
: Enable lexer debugging during the ASN.1 parsing stage.
|
||||
|
||||
-Wdebug-fixer
|
||||
|
@ -111,6 +114,9 @@ and other encoding rules.
|
|||
|
||||
## Codecs Generation Options
|
||||
|
||||
-gen-OER
|
||||
: Generate the Octet Encoding Rules (OER) support code.
|
||||
|
||||
-gen-PER
|
||||
: Generate the Packed Encoding Rules (PER) support code.
|
||||
|
||||
|
@ -134,6 +140,49 @@ and other encoding rules.
|
|||
-print-lines
|
||||
: Generate "`-- #line`" comments in **-E** output.
|
||||
|
||||
# TRANSFER SYNTAXES
|
||||
|
||||
The ASN.1 family of standards define a number of ways to encode data,
|
||||
including byte-oriented (e.g., BER), bit-oriented (e.g., PER),
|
||||
and textual (e.g., XER). Some encoding variants (e.g., DER) are just stricter
|
||||
variants of the more general encodings (e.g., BER).
|
||||
|
||||
The interoperability table below specifies which API functions can be used
|
||||
to exchange data in a compatible manner. If you need to _produce_ data
|
||||
conforming to the standard specified in the column 1,
|
||||
use the API function in the column 2.
|
||||
If you need to _process_ data conforming to the standard(s) specified in the
|
||||
column 3, use the API function specified in column 4.
|
||||
See the `asn1c-usage.pdf` for details.
|
||||
|
||||
-------------------------------------------------------------
|
||||
Encoding API function Understood by API function
|
||||
-------------- ------------------ ------------- -------------
|
||||
BER der_encode() BER ber_decode()
|
||||
|
||||
DER der_encode() DER, BER ber_decode()
|
||||
|
||||
CER _not supported_ CER, BER ber_decode()
|
||||
|
||||
BASIC-OER oer_encode() *-OER oer_decode()
|
||||
|
||||
CANONICAL-OER oer_encode() *-OER oer_decode()
|
||||
|
||||
BASIC-UPER uper_encode() *-UPER uper_decode()
|
||||
|
||||
CANONICAL-UPER uper_encode() *-UPER uper_decode()
|
||||
|
||||
*-APER _not supported_ *-APER _not supported_
|
||||
|
||||
BASIC-XER xer_encode(...) *-XER xer_decode()
|
||||
|
||||
CANONICAL-XER xer_encode *-XER xer_decode()
|
||||
(XER_F_CANONICAL)
|
||||
-------------------------------------------------------------
|
||||
|
||||
*) Asterisk means both BASIC and CANONICAL variants.
|
||||
|
||||
|
||||
# SEE ALSO
|
||||
|
||||
`unber`(1), `enber`(1).
|
||||
|
|
|
@ -39,7 +39,7 @@ is treated as a beginning of a comment line, which is ignored
|
|||
completely.
|
||||
Empty lines are ignored as well.
|
||||
.PP
|
||||
The following example \f[C]enber\f[](1) input demostrates the use of
|
||||
The following example \f[C]enber\f[](1) input demonstrates the use of
|
||||
comments:
|
||||
.PP
|
||||
<C O="0" T="[1]" TL="2" V="2">
|
||||
|
|
|
@ -36,7 +36,7 @@ In particular, the XML style comments are not supported.
|
|||
A hash "**#**" or two dashes "**--**" following a whitespace is treated as a beginning of a comment line, which is ignored completely.
|
||||
Empty lines are ignored as well.
|
||||
|
||||
The following example `enber`(1) input demostrates the use of comments:
|
||||
The following example `enber`(1) input demonstrates the use of comments:
|
||||
|
||||
| \<C O="0" T="[1]" TL="2" V="2">
|
||||
| \<I O="2" T="[1]" TL="2" V="Indefinite">
|
||||
|
|
|
@ -26,19 +26,23 @@ $(ASN1_FILES_3): crfc2asn1.pl $(ASN1_SOURCE_3)
|
|||
${srcdir}/crfc2asn1.pl ${srcdir}/$(ASN1_SOURCE_3)
|
||||
|
||||
EXTRA_DIST = \
|
||||
rfc3280.txt rfc3525.txt rfc4511.txt \
|
||||
sample.source.LDAP3 \
|
||||
sample.source.MEGACO \
|
||||
sample.source.MHEG5 \
|
||||
sample.source.RRC \
|
||||
sample.source.TAP3 \
|
||||
sample.source.PKIX1 \
|
||||
sample.makefile.regen
|
||||
rfc3280.txt rfc3525.txt rfc4511.txt \
|
||||
sample.source.1609.2 \
|
||||
sample.source.J2735 \
|
||||
sample.source.LDAP3 \
|
||||
sample.source.LTE-RRC \
|
||||
sample.source.MEGACO \
|
||||
sample.source.MHEG5 \
|
||||
sample.source.PKIX1 \
|
||||
sample.source.RRC \
|
||||
sample.source.TAP3 \
|
||||
sample.source.ULP \
|
||||
sample.makefile.regen
|
||||
|
||||
CLEANFILES = $(ASN1_FILES_1) $(ASN1_FILES_2) $(ASN1_FILES_3)
|
||||
|
||||
clean-local:
|
||||
for dir in ${srcdir}/sample.source.*; do (cd $$dir && make distclean); done
|
||||
for dir in ${srcdir}/sample.source.*; do (cd $$dir && make distclean || :); done
|
||||
|
||||
dist-hook: clean-local
|
||||
rm -f `find $(distdir) -name "*.core" -or -name ".tmp.*"`
|
||||
|
|
|
@ -1,29 +1,40 @@
|
|||
|
||||
This directory contains a few examples.
|
||||
|
||||
1. The ./sample.source.PKIX1 directory contains the X.509 Certificate decoder,
|
||||
as specified in rfc3280.txt. Just type `make` in there to compile.
|
||||
1. The ./sample.source.PKIX1 directory contains the X.509 Certificate decoder,
|
||||
as specified in rfc3280.txt. Just type `make` in there to compile.
|
||||
|
||||
2. The ./sample.source.MHEG5 directory contains the decoder for
|
||||
ISO 13522 MHEG-5/ITU-T T.172 (Multimedia Hypermedia Experts Group,
|
||||
Multimedia Presentations). Read the README file in that directory.
|
||||
2. The ./sample.source.MHEG5 directory contains the decoder for
|
||||
ISO 13522 MHEG-5/ITU-T T.172 (Multimedia Hypermedia Experts Group,
|
||||
Multimedia Presentations). Read the README file in that directory.
|
||||
|
||||
3. The ./sample.source.MEGACO directory contains the decoder for
|
||||
Media Gateway Control Protocol data units as specified in rfc3525.txt.
|
||||
3. The ./sample.source.MEGACO directory contains the decoder for
|
||||
Media Gateway Control Protocol data units as specified in rfc3525.txt.
|
||||
|
||||
4. The ./sample.source.LDAP3 directory contains the decoder for
|
||||
Lightweight Directory Access Protocol version 3 PDU as specified in
|
||||
rfc4211.txt.
|
||||
4. The ./sample.source.LDAP3 directory contains the decoder for
|
||||
Lightweight Directory Access Protocol version 3 PDU as specified in
|
||||
rfc4211.txt.
|
||||
|
||||
6. The ./sample.source.RRC directory contains the 3GPP Radio Resource Control
|
||||
decoder for RRC version 7.1.0. Just type `make` in there to compile.
|
||||
5. The ./sample.source.RRC directory contains the 3GPP Radio Resource Control
|
||||
decoder for RRC version 7.1.0. Just type `make` in there to compile.
|
||||
|
||||
5. The ./sample.source.TAP3 directory contains the GSM TAP3 decoder.
|
||||
Before trying to compile, read the README file in that directory.
|
||||
6. The ./sample.source.LTE-RRC directory contains the 3GPP RRC
|
||||
decoder for LTE RRC version 14.2.1. Read the README file in that directory.
|
||||
|
||||
6. The ./sample.source.ULP directory contains the Open Mobile Alliance
|
||||
UserPlane Location Protocol decoder. Before trying to compile, read the
|
||||
README file in that directory.
|
||||
7. The ./sample.source.TAP3 directory contains the GSM TAP3 decoder.
|
||||
Before trying to compile, read the README file in that directory.
|
||||
|
||||
8. The ./sample.source.ULP directory contains the Open Mobile Alliance
|
||||
UserPlane Location Protocol decoder.
|
||||
Before trying to compile, read the README file in that directory.
|
||||
|
||||
9. The ./sample.source.J2735 directory contains the SAE J2735-201603 decoder.
|
||||
Before trying to compile, read the README file in that directory.
|
||||
WARNING WARNING WARNING: WORK IN PROGRESS. Not supposed to work yet.
|
||||
|
||||
10. The ./sample.source.1609.2 directory contains the IEEE 1609.2-2016 decoder.
|
||||
Before trying to compile, read the README file in that directory.
|
||||
WARNING WARNING WARNING: WORK IN PROGRESS. Not supposed to work yet.
|
||||
|
||||
The crfc2asn1.pl script can be used to extract ASN.1 data from RFC texts.
|
||||
For instance, it is used to extract X.509, MEGACO, and LDAPv3 ASN.1 modules
|
||||
|
|
|
@ -1,142 +1,154 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# This script attempts to compile the given ASN.1 specification and then
|
||||
# transforms the resulting Makefile.am.sample tailored to that specification
|
||||
# into a customized Makefile.
|
||||
# This script attempts to compile the given ASN.1 specification by first
|
||||
# building the specialized Makefile.
|
||||
#
|
||||
# The information which is necessary for this script is passed from the
|
||||
# Makefile which is going to be replaced with an updated Makefile.
|
||||
# This is called "boot-strapping" and is frequently the source of inside jokes.
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
if test -z "$ASN1PDU" \
|
||||
-o -z "$ASN1MODULES" \
|
||||
-o -z "$PROGNAME" \
|
||||
if test -z "$ASN_PDU" \
|
||||
-o -z "$ASN_MODULES" \
|
||||
-o -z "$ASN_PROGRAM" \
|
||||
; then
|
||||
echo "ASN1CMDOPTS=\"$ASN1CMDOPTS\""
|
||||
echo "ASN1MODULES=\"$ASN1MODULES\""
|
||||
echo "ASN1PDU=\"$ASN1PDU\""
|
||||
echo "PROGNAME=\"$PROGNAME\""
|
||||
echo "ASN1PDU, ASN1MODULES, and PROGNAME are mandatory"
|
||||
exit
|
||||
fi
|
||||
|
||||
CMDOPTS="-pdu=${ASN1PDU} ${ASN1CMDOPTS} ${ASN1MODULES}"
|
||||
|
||||
if test -x ../../asn1c/asn1c ; then
|
||||
echo "Compiling ${ASN1MODULES} using local compiler"
|
||||
../../asn1c/asn1c -S ../../skeletons ${CMDOPTS} || exit $?
|
||||
else
|
||||
echo "Compiling ${ASN1MODULES} using system compiler"
|
||||
asn1c ${CMDOPTS} || exit $?
|
||||
fi
|
||||
|
||||
if test ! -f Makefile.am.sample ; then
|
||||
echo "Makefile.am.sample is missing"
|
||||
cat <<-NOTE
|
||||
ASN_CMDOPTS="$ASN_CMDOPTS"
|
||||
ASN_MODULES="$ASN_MODULES"
|
||||
ASN_PDU="$ASN_PDU"
|
||||
ASN_PROGRAM="$ASN_PROGRAM"
|
||||
ASN_PDU, ASN_MODULES, and ASN_PROGRAM are mandatory.
|
||||
NOTE
|
||||
exit 1
|
||||
fi
|
||||
|
||||
EXTRA_CFLAGS="-DJUNKTEST"
|
||||
EFFECTIVE_CMDOPTS="-pdu=${ASN_PDU} ${ASN_CMDOPTS} ${ASN_MODULES}"
|
||||
|
||||
if test -x ../../asn1c/asn1c ; then
|
||||
echo "Compiling ${ASN_MODULES} using local compiler"
|
||||
../../asn1c/asn1c -S ../../skeletons ${EFFECTIVE_CMDOPTS} || exit $?
|
||||
else
|
||||
echo "Compiling ${ASN_MODULES} using system compiler"
|
||||
asn1c ${EFFECTIVE_CMDOPTS} || exit $?
|
||||
fi
|
||||
|
||||
if test ! -f converter-example.mk ; then
|
||||
echo "converter-example.mk is missing"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
EXTRA_CFLAGS="-DJUNKTEST -D_DEFAULT_SOURCE"
|
||||
test -f config.h && EXTRA_CFLAGS="-DHAVE_CONFIG_H ${EXTRA_CFLAGS}"
|
||||
test -n "$TITLE" && EXTRA_CFLAGS="-DASN_CONVERTER_TITLE=\"$TITLE\" ${EXTRA_CFLAGS}"
|
||||
|
||||
set -x
|
||||
cat Makefile.am.sample \
|
||||
| sed -e "s/^CFLAGS += /CFLAGS += ${EXTRA_CFLAGS} /" \
|
||||
| sed -e "s/^all: /all: ${ASN1PDU}.c /" \
|
||||
| sed -e "s/progname/${PROGNAME}/" \
|
||||
> Makefile.$$
|
||||
set +x
|
||||
|
||||
( echo
|
||||
echo "${ASN1PDU}.c: $0 ${ASN1MODULES}"
|
||||
{
|
||||
echo "ASN_PROGRAM = ${ASN_PROGRAM}"
|
||||
echo "CFLAGS += ${EXTRA_CFLAGS}"
|
||||
echo "begin: ${ASN_PDU}.c maybe-wip-pause all"
|
||||
echo
|
||||
echo "-include converter-example.mk"
|
||||
echo
|
||||
echo "${ASN_PDU}.c: $0 ${ASN_MODULES}"
|
||||
echo " make regen-makefile"
|
||||
echo " @touch ${ASN1PDU}.c"
|
||||
echo " @touch ${ASN_PDU}.c"
|
||||
echo " make"
|
||||
echo
|
||||
echo "regen-makefile:"
|
||||
test -n "$TITLE" && echo " TITLE=\"$TITLE\" \\"
|
||||
echo " ASN1CMDOPTS=\"${ASN1CMDOPTS}\" \\"
|
||||
echo " ASN1MODULES=\"${ASN1MODULES}\" \\"
|
||||
echo " ASN1PDU=${ASN1PDU} \\"
|
||||
echo " PROGNAME=${PROGNAME} \\"
|
||||
echo " ASN_CMDOPTS=\"${ASN_CMDOPTS}\" \\"
|
||||
echo " ASN_MODULES=\"${ASN_MODULES}\" \\"
|
||||
echo " ASN_PDU=${ASN_PDU} \\"
|
||||
echo " ASN_PROGRAM=${ASN_PROGRAM} \\"
|
||||
echo " $0"
|
||||
echo
|
||||
echo 'check: ${TARGET} check-ber check-xer check-per'
|
||||
echo 'check: ${ASN_PROGRAM} check-ber check-xer check-oer check-per'
|
||||
echo ' @echo ================'
|
||||
echo ' @echo All tests passed'
|
||||
echo ' @echo ================'
|
||||
echo
|
||||
echo 'check-ber:'
|
||||
echo " @if test -f sample-${ASN1PDU}-1.[db]er ; then \\"
|
||||
echo " for f in sample-${ASN1PDU}-*.[db]er; do \\"
|
||||
echo " @if test -f sample-${ASN_PDU}-1.[db]er ; then \\"
|
||||
echo " for f in sample-*-*.[db]er; do \\"
|
||||
echo ' pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\\1/"`; \'
|
||||
echo ' for b in 1 17 33 980 8192; do \'
|
||||
echo ' echo "Recoding $$f into XER and back ($$b)..."; \'
|
||||
echo ' ./${TARGET} -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \'
|
||||
echo ' ./${TARGET} -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \'
|
||||
echo ' echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \'
|
||||
echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \'
|
||||
echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \'
|
||||
echo ' diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 4; \'
|
||||
echo ' rm -f ./.tmp.[12].$$$$; \'
|
||||
echo ' echo "Test junking $$f (please wait)..."; \'
|
||||
echo ' ./${TARGET} -J0.0001 -n 1000 -b $$b -iber -onull $$f || exit 5; \'
|
||||
echo ' ./${TARGET} -J0.001 -n 1000 -b $$b -iber -onull $$f || exit 6; \'
|
||||
echo ' ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 5; \'
|
||||
echo ' ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 6; \'
|
||||
echo ' done; done; fi'
|
||||
echo
|
||||
echo 'check-xer:'
|
||||
echo " @if test -f sample-${ASN1PDU}-1.xer ; then \\"
|
||||
echo " for f in sample-${ASN1PDU}-*.xer; do \\"
|
||||
echo " @if test -f sample-${ASN_PDU}-1.xer ; then \\"
|
||||
echo " for f in sample-*-*.xer; do \\"
|
||||
echo ' pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\\1/"`; \'
|
||||
echo ' for b in 1 17 33 980 8192; do \'
|
||||
echo ' echo "Recoding $$f into DER and back ($$b)..."; \'
|
||||
echo ' ./${TARGET} -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \'
|
||||
echo ' ./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \'
|
||||
echo ' echo "Recoding $$f ($$pdu) into DER and back ($$b)..."; \'
|
||||
echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \'
|
||||
echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \'
|
||||
echo ' diff $$f ./.tmp.2.$$$$ || exit 4; \'
|
||||
echo ' rm -f ./.tmp.[12].$$$$; \'
|
||||
echo ' echo "Test junking $$f (please wait)..."; \'
|
||||
echo ' ./${TARGET} -J0.0001 -n 1000 -b $$b -ixer -onull $$f || exit 5; \'
|
||||
echo ' ./${TARGET} -J0.001 -n 1000 -b $$b -ixer -onull $$f || exit 6; \'
|
||||
echo ' ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 5; \'
|
||||
echo ' ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 6; \'
|
||||
echo ' done; done; fi'
|
||||
echo
|
||||
echo 'check-oer:'
|
||||
echo " @if test -f sample-${ASN_PDU}-1.*oer ; then \\"
|
||||
echo " for f in sample-*-*.*oer; do \\"
|
||||
echo ' pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\\1/"`; \'
|
||||
echo ' for b in 1 17 33 980 8192; do \'
|
||||
echo ' echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \'
|
||||
echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -ioer -oxer $$f > ./.tmp.1.$$$$ || exit 2; \'
|
||||
echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -ooer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \'
|
||||
echo ' diff $$f ./.tmp.2.$$$$ || exit 4; \'
|
||||
echo ' rm -f ./.tmp.[12].$$$$; \'
|
||||
echo ' echo "Test junking $$f (please wait) ($$b) ..."; \'
|
||||
echo ' ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 5; \'
|
||||
echo ' ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 6; \'
|
||||
echo ' done; done; fi'
|
||||
echo
|
||||
echo 'check-per:'
|
||||
echo " @if test -f sample-${ASN1PDU}-1-nopad.per ; then \\"
|
||||
echo " for f in sample-${ASN1PDU}-[1-9]-nopad.per; do \\"
|
||||
echo " @if test -f sample-${ASN_PDU}-1-nopad.per ; then \\"
|
||||
echo " for f in sample-*-[1-9]-nopad.per; do \\"
|
||||
echo ' pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\\1/"`; \'
|
||||
echo ' for b in 1 17 33 980 8192; do \'
|
||||
echo ' echo "Recoding non-padded $$f into DER into XER and back ($$b)..."; \'
|
||||
echo ' ./${TARGET} -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \'
|
||||
echo ' ./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \'
|
||||
echo ' ./${TARGET} -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \'
|
||||
echo ' echo "Recoding non-padded $$f ($$pdu) into DER into XER and back ($$b)..."; \'
|
||||
echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \'
|
||||
echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \'
|
||||
echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \'
|
||||
echo ' diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 5; \'
|
||||
echo ' rm -f ./.tmp.[123].$$$$; \'
|
||||
echo ' echo "Test junking $$f (please wait)..."; \'
|
||||
echo ' ./${TARGET} -J0.0001 -n 1000 -b $$b -per-nopad -iper -onull $$f || exit 6; \'
|
||||
echo ' ./${TARGET} -J0.001 -n 1000 -b $$b -per-nopad -iper -onull $$f || exit 7; \'
|
||||
echo ' ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 6; \'
|
||||
echo ' ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 7; \'
|
||||
echo ' done; done; fi'
|
||||
echo " @if test -f sample-${ASN1PDU}-1.per ; then \\"
|
||||
echo " @if test -f sample-${ASN_PDU}-1.per ; then \\"
|
||||
echo " for f in sample-*-[1-9].per; do \\"
|
||||
echo ' pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z-]+)-[0-9].*/\1/"`; \'
|
||||
echo ' pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\\1/"`; \'
|
||||
echo ' for b in 1 17 33 980 8192; do \'
|
||||
echo ' echo "Recoding $$f into DER into XER and back ($$b)..."; \'
|
||||
echo ' ./${TARGET} -b $$b -p $$pdu -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \'
|
||||
echo ' ./${TARGET} -b $$b -p $$pdu -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \'
|
||||
echo ' ./${TARGET} -b $$b -p $$pdu -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \'
|
||||
echo ' echo "Recoding $$f ($$pdu) into DER into XER and back ($$b)..."; \'
|
||||
echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \'
|
||||
echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \'
|
||||
echo ' ./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \'
|
||||
echo ' diff $$f ./.tmp.1.$$$$ || exit 6; \'
|
||||
echo ' rm -f ./.tmp.[12].$$$$; \'
|
||||
echo ' echo "Test junking $$f (please wait)..."; \'
|
||||
echo ' ./${TARGET} -J0.0001 -n 1000 -b $$b -iper -onull $$f || exit 7; \'
|
||||
echo ' ./${TARGET} -J0.001 -n 1000 -b $$b -iper -onull $$f || exit 8; \'
|
||||
echo ' ./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 7; \'
|
||||
echo ' ./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 8; \'
|
||||
echo ' done; done; fi'
|
||||
echo
|
||||
echo "maybe-wip-pause:"
|
||||
echo " @if [ -f WIP ]; then cat WIP; sleep 2; fi"
|
||||
echo
|
||||
echo "distclean: clean"
|
||||
echo ' rm -f $(ASN_MODULE_SOURCES)'
|
||||
echo ' rm -f $(ASN_MODULE_HEADERS)'
|
||||
echo ' rm -f $(ASN_CONVERTER_SOURCES) $(ASN_CONVERTER_HEADERS)'
|
||||
echo " rm -f Makefile.am.sample"
|
||||
) >> Makefile.$$
|
||||
|
||||
set -x
|
||||
mv Makefile.$$ Makefile || exit $?
|
||||
rm Makefile.am.sample || exit $?
|
||||
set +x
|
||||
echo ' rm -f $(ASN_MODULE_SRCS)'
|
||||
echo ' rm -f $(ASN_MODULE_HDRS)'
|
||||
echo ' rm -f $(ASN_PROGRAM_SRCS) $(ASN_PROGRAM_HDRS)'
|
||||
echo " rm -f converter-example.mk"
|
||||
} > Makefile
|
||||
|
||||
echo
|
||||
echo "Makefile generation finished"
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
ASN_PROGRAM = 1609-2-dump
|
||||
CFLAGS += -DASN_CONVERTER_TITLE="IEEE 1609.2-2016 decoder" -DHAVE_CONFIG_H -DJUNKTEST -D_DEFAULT_SOURCE
|
||||
begin: Certificate.c maybe-wip-pause all
|
||||
|
||||
-include converter-example.mk
|
||||
|
||||
Certificate.c: ../sample.makefile.regen ../IEEE-1609.2-2016.asn1
|
||||
make regen-makefile
|
||||
@touch Certificate.c
|
||||
make
|
||||
|
||||
regen-makefile:
|
||||
TITLE="IEEE 1609.2-2016 decoder" \
|
||||
ASN_CMDOPTS="-pdu=auto -pdu=Ieee1609Dot2Data -fcompound-names" \
|
||||
ASN_MODULES="../IEEE-1609.2-2016.asn1" \
|
||||
ASN_PDU=Certificate \
|
||||
ASN_PROGRAM=1609-2-dump \
|
||||
../sample.makefile.regen
|
||||
|
||||
check: ${ASN_PROGRAM} check-ber check-xer check-oer check-per
|
||||
@echo ================
|
||||
@echo All tests passed
|
||||
@echo ================
|
||||
|
||||
check-ber:
|
||||
@if test -f sample-Certificate-1.[db]er ; then \
|
||||
for f in sample-*-*.[db]er; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 4; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 5; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 6; \
|
||||
done; done; fi
|
||||
|
||||
check-xer:
|
||||
@if test -f sample-Certificate-1.xer ; then \
|
||||
for f in sample-*-*.xer; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f ($$pdu) into DER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
diff $$f ./.tmp.2.$$$$ || exit 4; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 5; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 6; \
|
||||
done; done; fi
|
||||
|
||||
check-oer:
|
||||
@if test -f sample-Certificate-1.*oer ; then \
|
||||
for f in sample-*-*.*oer; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ioer -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -ooer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
diff $$f ./.tmp.2.$$$$ || exit 4; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait) ($$b) ..."; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 5; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 6; \
|
||||
done; done; fi
|
||||
|
||||
check-per:
|
||||
@if test -f sample-Certificate-1-nopad.per ; then \
|
||||
for f in sample-*-[1-9]-nopad.per; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding non-padded $$f ($$pdu) into DER into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \
|
||||
diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 5; \
|
||||
rm -f ./.tmp.[123].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 6; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 7; \
|
||||
done; done; fi
|
||||
@if test -f sample-Certificate-1.per ; then \
|
||||
for f in sample-*-[1-9].per; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f ($$pdu) into DER into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \
|
||||
diff $$f ./.tmp.1.$$$$ || exit 6; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 7; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 8; \
|
||||
done; done; fi
|
||||
|
||||
maybe-wip-pause:
|
||||
@if [ -f WIP ]; then cat WIP; sleep 2; fi
|
||||
|
||||
distclean: clean
|
||||
rm -f $(ASN_MODULE_SRCS)
|
||||
rm -f $(ASN_MODULE_HDRS)
|
||||
rm -f $(ASN_PROGRAM_SRCS) $(ASN_PROGRAM_HDRS)
|
||||
rm -f converter-example.mk
|
|
@ -0,0 +1,46 @@
|
|||
|
||||
GENERAL INFORMATION
|
||||
===================
|
||||
|
||||
The IEEE 1609.2-2016 "Wireless Access in Vehicular Environments --
|
||||
Security Services for Applications and Management Messages" messages decoder.
|
||||
Invoking `make` will compile the ASN.1 specifications from the
|
||||
../IEEE-1609.2-2016.asn1 file.
|
||||
|
||||
THERE IS NO IEEE-1609.2-2016.asn1 FILE THERE YET!
|
||||
|
||||
OBTAINING THE IEEE 1609.2-2016 SPECIFICATION
|
||||
============================================
|
||||
|
||||
Download the standard containing the ASN.1 module files from
|
||||
https://standards.ieee.org/findstds/standard/1609.2-2016.html
|
||||
|
||||
You should extract the ASN.1 modules from there and save it
|
||||
into a single ../IEEE-1609.2-2016.asn1 file. This file should start with
|
||||
the following line
|
||||
|
||||
IEEE1609dot2BaseTypes {iso(1) identified-organization(3) ieee(111)
|
||||
|
||||
or
|
||||
|
||||
IEEE1609dot2 {iso(1) identified-organization(3) ieee(111)
|
||||
|
||||
(both of these modules should be present in the file; order is unimportant)
|
||||
and end with the "END" token.
|
||||
Be careful not to copy any non-ASN.1 preambles from that .DOC file.
|
||||
|
||||
After obtaining the IEEE-1609.2-2016.asn1, type `make` in the directory
|
||||
containing this README file.
|
||||
|
||||
1609-2-dump USAGE
|
||||
=================
|
||||
|
||||
The 1609-2-dump utility may be used to dump the contents of the
|
||||
OER-encoded Certificate file:
|
||||
|
||||
./1609-2-dump 1609cert.oer # Print as XML (BASIC-XER)
|
||||
|
||||
The full list of recognized command line options may be obtained with
|
||||
|
||||
> ./1609-2-dump -h
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
extern int opt_debug;
|
||||
|
||||
#define ASN_DEBUG(fmt, args...) do { \
|
||||
if(opt_debug < 2) break; \
|
||||
fprintf(stderr, fmt, ##args); \
|
||||
fprintf(stderr, " (%s:%d)\n", \
|
||||
__FILE__, __LINE__); \
|
||||
} while(0)
|
||||
|
Binary file not shown.
|
@ -0,0 +1,95 @@
|
|||
<Certificate>
|
||||
<version>3</version>
|
||||
<type><explicit/></type>
|
||||
<issuer>
|
||||
<sha256AndDigest>AF 23 26 18 BE 5E 6F 55</sha256AndDigest>
|
||||
</issuer>
|
||||
<toBeSigned>
|
||||
<id>
|
||||
<name>vehicle-test.example.com</name>
|
||||
</id>
|
||||
<cracaId>5E 6F 5B</cracaId>
|
||||
<crlSeries>2</crlSeries>
|
||||
<validityPeriod>
|
||||
<start>17469212</start>
|
||||
<duration>
|
||||
<years>10</years>
|
||||
</duration>
|
||||
</validityPeriod>
|
||||
<region>
|
||||
<identifiedRegion>
|
||||
<countryOnly>12</countryOnly>
|
||||
|
||||
<countryOnly>34</countryOnly>
|
||||
|
||||
</identifiedRegion>
|
||||
</region>
|
||||
<appPermissions>
|
||||
<PsidSsp>
|
||||
<psid>35</psid>
|
||||
<ssp>
|
||||
<opaque>83 00 01</opaque>
|
||||
</ssp>
|
||||
</PsidSsp>
|
||||
</appPermissions>
|
||||
<certIssuePermissions>
|
||||
<PsidGroupPermissions>
|
||||
<subjectPermissions>
|
||||
<all></all>
|
||||
</subjectPermissions>
|
||||
<minChainDepth>2</minChainDepth>
|
||||
<chainDepthRange>0</chainDepthRange>
|
||||
<eeType>
|
||||
11000000
|
||||
</eeType>
|
||||
</PsidGroupPermissions>
|
||||
<PsidGroupPermissions>
|
||||
<subjectPermissions>
|
||||
<explicit>
|
||||
<PsidSspRange>
|
||||
<psid>35</psid>
|
||||
<sspRange>
|
||||
<all></all>
|
||||
</sspRange>
|
||||
</PsidSspRange>
|
||||
<PsidSspRange>
|
||||
<psid>256</psid>
|
||||
<sspRange>
|
||||
<all></all>
|
||||
</sspRange>
|
||||
</PsidSspRange>
|
||||
</explicit>
|
||||
</subjectPermissions>
|
||||
<minChainDepth>1</minChainDepth>
|
||||
<chainDepthRange>-1</chainDepthRange>
|
||||
<eeType>
|
||||
11000000
|
||||
</eeType>
|
||||
</PsidGroupPermissions>
|
||||
</certIssuePermissions>
|
||||
<verifyKeyIndicator>
|
||||
<verificationKey>
|
||||
<ecdsaNistP256>
|
||||
<compressed-y-0>
|
||||
08 C3 C0 70 B0 40 C0 40 10 80 33 07 0D 05 01 CE
|
||||
0C 0A 08 06 01 7B 00 F0 30 D2 03 EA 04 BE 09 03
|
||||
</compressed-y-0>
|
||||
</ecdsaNistP256>
|
||||
</verificationKey>
|
||||
</verifyKeyIndicator>
|
||||
</toBeSigned>
|
||||
<signature>
|
||||
<ecdsaNistP256Signature>
|
||||
<r>
|
||||
<x-only>
|
||||
08 B2 03 01 04 02 0A 0D 01 0C 01 05 C0 F8 0B B1
|
||||
46 02 39 34 8D 17 40 5C 1A 84 51 51 D4 06 12 00
|
||||
</x-only>
|
||||
</r>
|
||||
<s>
|
||||
26 17 CF 4E 6B 25 09 7F 03 F5 02 AD 0C 6F 2F 12
|
||||
59 74 70 0D 31 A6 0F D1 EF 12 04 0E 4D 82 31 AB
|
||||
</s>
|
||||
</ecdsaNistP256Signature>
|
||||
</signature>
|
||||
</Certificate>
|
Binary file not shown.
|
@ -0,0 +1,46 @@
|
|||
<Certificate>
|
||||
<version>3</version>
|
||||
<type><implicit/></type>
|
||||
<issuer>
|
||||
<sha256AndDigest>90 E3 08 2D A8 0E 64 01</sha256AndDigest>
|
||||
</issuer>
|
||||
<toBeSigned>
|
||||
<id>
|
||||
<binaryId>90 77 72 1D 06 CB 01 60</binaryId>
|
||||
</id>
|
||||
<cracaId>5E 6F 5B</cracaId>
|
||||
<crlSeries>3</crlSeries>
|
||||
<validityPeriod>
|
||||
<start>20493427</start>
|
||||
<duration>
|
||||
<hours>69</hours>
|
||||
</duration>
|
||||
</validityPeriod>
|
||||
<region>
|
||||
<identifiedRegion>
|
||||
<countryOnly>12</countryOnly>
|
||||
|
||||
<countryOnly>34</countryOnly>
|
||||
|
||||
<countryOnly>56</countryOnly>
|
||||
|
||||
</identifiedRegion>
|
||||
</region>
|
||||
<appPermissions>
|
||||
<PsidSsp>
|
||||
<psid>135</psid>
|
||||
<ssp>
|
||||
<opaque></opaque>
|
||||
</ssp>
|
||||
</PsidSsp>
|
||||
</appPermissions>
|
||||
<verifyKeyIndicator>
|
||||
<reconstructionValue>
|
||||
<compressed-y-0>
|
||||
03 10 8D FB BB 7A 77 77 70 76 74 7F 35 3E 56 99
|
||||
05 0F 02 02 03 04 03 0B 0E 68 64 6E 65 6B 61 E1
|
||||
</compressed-y-0>
|
||||
</reconstructionValue>
|
||||
</verifyKeyIndicator>
|
||||
</toBeSigned>
|
||||
</Certificate>
|
Binary file not shown.
|
@ -0,0 +1,107 @@
|
|||
ASN_PROGRAM = j2735-dump
|
||||
CFLAGS += -DASN_CONVERTER_TITLE="J2735 DSRC decoder" -DHAVE_CONFIG_H -DJUNKTEST -D_DEFAULT_SOURCE
|
||||
begin: MessageFrame.c maybe-wip-pause all
|
||||
|
||||
-include converter-example.mk
|
||||
|
||||
MessageFrame.c: ../sample.makefile.regen ../J2735_201603.asn1
|
||||
make regen-makefile
|
||||
@touch MessageFrame.c
|
||||
make
|
||||
|
||||
regen-makefile:
|
||||
TITLE="J2735 DSRC decoder" \
|
||||
ASN_CMDOPTS="-fcompound-names -pdu=auto" \
|
||||
ASN_MODULES="../J2735_201603.asn1" \
|
||||
ASN_PDU=MessageFrame \
|
||||
ASN_PROGRAM=j2735-dump \
|
||||
../sample.makefile.regen
|
||||
|
||||
check: ${ASN_PROGRAM} check-ber check-xer check-oer check-per
|
||||
@echo ================
|
||||
@echo All tests passed
|
||||
@echo ================
|
||||
|
||||
check-ber:
|
||||
@if test -f sample-MessageFrame-1.[db]er ; then \
|
||||
for f in sample-*-*.[db]er; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 4; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 5; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 6; \
|
||||
done; done; fi
|
||||
|
||||
check-xer:
|
||||
@if test -f sample-MessageFrame-1.xer ; then \
|
||||
for f in sample-*-*.xer; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f ($$pdu) into DER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
diff $$f ./.tmp.2.$$$$ || exit 4; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 5; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 6; \
|
||||
done; done; fi
|
||||
|
||||
check-oer:
|
||||
@if test -f sample-MessageFrame-1.*oer ; then \
|
||||
for f in sample-*-*.*oer; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ioer -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -ooer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
diff $$f ./.tmp.2.$$$$ || exit 4; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait) ($$b) ..."; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 5; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 6; \
|
||||
done; done; fi
|
||||
|
||||
check-per:
|
||||
@if test -f sample-MessageFrame-1-nopad.per ; then \
|
||||
for f in sample-*-[1-9]-nopad.per; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding non-padded $$f ($$pdu) into DER into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \
|
||||
diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 5; \
|
||||
rm -f ./.tmp.[123].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 6; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 7; \
|
||||
done; done; fi
|
||||
@if test -f sample-MessageFrame-1.per ; then \
|
||||
for f in sample-*-[1-9].per; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f ($$pdu) into DER into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \
|
||||
diff $$f ./.tmp.1.$$$$ || exit 6; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 7; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 8; \
|
||||
done; done; fi
|
||||
|
||||
maybe-wip-pause:
|
||||
@if [ -f WIP ]; then cat WIP; sleep 2; fi
|
||||
|
||||
distclean: clean
|
||||
rm -f $(ASN_MODULE_SRCS)
|
||||
rm -f $(ASN_MODULE_HDRS)
|
||||
rm -f $(ASN_PROGRAM_SRCS) $(ASN_PROGRAM_HDRS)
|
||||
rm -f converter-example.mk
|
|
@ -0,0 +1,40 @@
|
|||
|
||||
GENERAL INFORMATION
|
||||
===================
|
||||
|
||||
The SAE J2735-201603 Dedicated Short Range Communications (DSRC)
|
||||
Message Set Dictionary decoder.
|
||||
Invoking `make` will compile the ASN.1 specifications from the
|
||||
../J2735_201603.asn1 file.
|
||||
|
||||
THERE IS NO J2735_201603.asn1 FILE THERE YET!
|
||||
|
||||
OBTAINING THE J2735 SPECIFICATION
|
||||
=================================
|
||||
|
||||
Go to http://standards.sae.org/j2735_201603/ and download the files.
|
||||
|
||||
You should extract the ASN.1 module from there and save it
|
||||
as the ../J2735_201603.asn1 file. This file should start with
|
||||
the following line
|
||||
|
||||
DSRC DEFINITIONS AUTOMATIC TAGS ::=
|
||||
|
||||
and end with the "END" token.
|
||||
Be careful not to copy any non-ASN.1 preambles from that .DOC file.
|
||||
|
||||
After obtaining the J2735_201603.asn1, type `make` in the directory
|
||||
containing this README file.
|
||||
|
||||
j2735-dump USAGE
|
||||
================
|
||||
|
||||
The j2735-dump utility may be used to dump the contents of the
|
||||
UPER-encoded DSRC message record file:
|
||||
|
||||
./j2735-dump j2735file.per # Print as XML (BASIC-XER)
|
||||
|
||||
The full list of recognized command line options may be obtained with
|
||||
|
||||
> ./j2735-dump -h
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
extern int opt_debug;
|
||||
|
||||
#define ASN_DEBUG(fmt, args...) do { \
|
||||
if(opt_debug < 2) break; \
|
||||
fprintf(stderr, fmt, ##args); \
|
||||
fprintf(stderr, " (%s:%d)\n", \
|
||||
__FILE__, __LINE__); \
|
||||
} while(0)
|
||||
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,140 @@
|
|||
<MessageFrame>
|
||||
<messageId>20</messageId>
|
||||
<value>
|
||||
<BasicSafetyMessage>
|
||||
<coreData>
|
||||
<msgCnt>88</msgCnt>
|
||||
<id>00 00 00 00</id>
|
||||
<secMark>59000</secMark>
|
||||
<lat>511041141</lat>
|
||||
<long>-1341224725</long>
|
||||
<elev>188</elev>
|
||||
<accuracy>
|
||||
<semiMajor>255</semiMajor>
|
||||
<semiMinor>255</semiMinor>
|
||||
<orientation>65535</orientation>
|
||||
</accuracy>
|
||||
<transmission><unavailable/></transmission>
|
||||
<speed>0</speed>
|
||||
<heading>15290</heading>
|
||||
<angle>127</angle>
|
||||
<accelSet>
|
||||
<long>2001</long>
|
||||
<lat>2001</lat>
|
||||
<vert>-127</vert>
|
||||
<yaw>0</yaw>
|
||||
</accelSet>
|
||||
<brakes>
|
||||
<wheelBrakes>
|
||||
10000
|
||||
</wheelBrakes>
|
||||
<traction><unavailable/></traction>
|
||||
<abs><unavailable/></abs>
|
||||
<scs><unavailable/></scs>
|
||||
<brakeBoost><unavailable/></brakeBoost>
|
||||
<auxBrakes><unavailable/></auxBrakes>
|
||||
</brakes>
|
||||
<size>
|
||||
<width>0</width>
|
||||
<length>0</length>
|
||||
</size>
|
||||
</coreData>
|
||||
<partII>
|
||||
<PartIIcontent>
|
||||
<partII-Id>0</partII-Id>
|
||||
<partII-Value>
|
||||
<VehicleSafetyExtensions>
|
||||
<pathHistory>
|
||||
<crumbData>
|
||||
<PathHistoryPoint>
|
||||
<latOffset>-131072</latOffset>
|
||||
<lonOffset>-131072</lonOffset>
|
||||
<elevationOffset>-2048</elevationOffset>
|
||||
<timeOffset>1</timeOffset>
|
||||
</PathHistoryPoint>
|
||||
<PathHistoryPoint>
|
||||
<latOffset>131071</latOffset>
|
||||
<lonOffset>131071</lonOffset>
|
||||
<elevationOffset>2037</elevationOffset>
|
||||
<timeOffset>65535</timeOffset>
|
||||
</PathHistoryPoint>
|
||||
</crumbData>
|
||||
</pathHistory>
|
||||
<pathPrediction>
|
||||
<radiusOfCurve>32767</radiusOfCurve>
|
||||
<confidence>0</confidence>
|
||||
</pathPrediction>
|
||||
</VehicleSafetyExtensions>
|
||||
</partII-Value>
|
||||
</PartIIcontent>
|
||||
</partII>
|
||||
</BasicSafetyMessage>
|
||||
</value>
|
||||
</MessageFrame>
|
||||
<MessageFrame>
|
||||
<messageId>20</messageId>
|
||||
<value>
|
||||
<BasicSafetyMessage>
|
||||
<coreData>
|
||||
<msgCnt>89</msgCnt>
|
||||
<id>FF 00 00 01</id>
|
||||
<secMark>59000</secMark>
|
||||
<lat>511041141</lat>
|
||||
<long>-1341224725</long>
|
||||
<elev>188</elev>
|
||||
<accuracy>
|
||||
<semiMajor>255</semiMajor>
|
||||
<semiMinor>255</semiMinor>
|
||||
<orientation>65535</orientation>
|
||||
</accuracy>
|
||||
<transmission><unavailable/></transmission>
|
||||
<speed>0</speed>
|
||||
<heading>15290</heading>
|
||||
<angle>127</angle>
|
||||
<accelSet>
|
||||
<long>2001</long>
|
||||
<lat>2001</lat>
|
||||
<vert>-127</vert>
|
||||
<yaw>0</yaw>
|
||||
</accelSet>
|
||||
<brakes>
|
||||
<wheelBrakes>
|
||||
10000
|
||||
</wheelBrakes>
|
||||
<traction><unavailable/></traction>
|
||||
<abs><unavailable/></abs>
|
||||
<scs><unavailable/></scs>
|
||||
<brakeBoost><unavailable/></brakeBoost>
|
||||
<auxBrakes><unavailable/></auxBrakes>
|
||||
</brakes>
|
||||
<size>
|
||||
<width>0</width>
|
||||
<length>0</length>
|
||||
</size>
|
||||
</coreData>
|
||||
<partII>
|
||||
<PartIIcontent>
|
||||
<partII-Id>0</partII-Id>
|
||||
<partII-Value>
|
||||
<VehicleSafetyExtensions>
|
||||
<pathHistory>
|
||||
<crumbData>
|
||||
<PathHistoryPoint>
|
||||
<latOffset>0</latOffset>
|
||||
<lonOffset>0</lonOffset>
|
||||
<elevationOffset>0</elevationOffset>
|
||||
<timeOffset>1</timeOffset>
|
||||
</PathHistoryPoint>
|
||||
</crumbData>
|
||||
</pathHistory>
|
||||
<pathPrediction>
|
||||
<radiusOfCurve>0</radiusOfCurve>
|
||||
<confidence>0</confidence>
|
||||
</pathPrediction>
|
||||
</VehicleSafetyExtensions>
|
||||
</partII-Value>
|
||||
</PartIIcontent>
|
||||
</partII>
|
||||
</BasicSafetyMessage>
|
||||
</value>
|
||||
</MessageFrame>
|
|
@ -1,191 +1,8 @@
|
|||
ASN_MODULE_SOURCES= \
|
||||
LDAPMessage.c \
|
||||
MessageID.c \
|
||||
LDAPString.c \
|
||||
LDAPOID.c \
|
||||
LDAPDN.c \
|
||||
RelativeLDAPDN.c \
|
||||
AttributeDescription.c \
|
||||
AttributeValue.c \
|
||||
AttributeValueAssertion.c \
|
||||
AssertionValue.c \
|
||||
PartialAttribute.c \
|
||||
Attribute.c \
|
||||
MatchingRuleId.c \
|
||||
LDAPResult.c \
|
||||
Referral.c \
|
||||
URI.c \
|
||||
Controls.c \
|
||||
Control.c \
|
||||
BindRequest.c \
|
||||
AuthenticationChoice.c \
|
||||
SaslCredentials.c \
|
||||
BindResponse.c \
|
||||
UnbindRequest.c \
|
||||
SearchRequest.c \
|
||||
AttributeSelection.c \
|
||||
Filter.c \
|
||||
SubstringFilter.c \
|
||||
MatchingRuleAssertion.c \
|
||||
SearchResultEntry.c \
|
||||
PartialAttributeList.c \
|
||||
SearchResultReference.c \
|
||||
SearchResultDone.c \
|
||||
ModifyRequest.c \
|
||||
ModifyResponse.c \
|
||||
AddRequest.c \
|
||||
AttributeList.c \
|
||||
AddResponse.c \
|
||||
DelRequest.c \
|
||||
DelResponse.c \
|
||||
ModifyDNRequest.c \
|
||||
ModifyDNResponse.c \
|
||||
CompareRequest.c \
|
||||
CompareResponse.c \
|
||||
AbandonRequest.c \
|
||||
ExtendedRequest.c \
|
||||
ExtendedResponse.c \
|
||||
IntermediateResponse.c
|
||||
|
||||
ASN_MODULE_HEADERS= \
|
||||
LDAPMessage.h \
|
||||
MessageID.h \
|
||||
LDAPString.h \
|
||||
LDAPOID.h \
|
||||
LDAPDN.h \
|
||||
RelativeLDAPDN.h \
|
||||
AttributeDescription.h \
|
||||
AttributeValue.h \
|
||||
AttributeValueAssertion.h \
|
||||
AssertionValue.h \
|
||||
PartialAttribute.h \
|
||||
Attribute.h \
|
||||
MatchingRuleId.h \
|
||||
LDAPResult.h \
|
||||
Referral.h \
|
||||
URI.h \
|
||||
Controls.h \
|
||||
Control.h \
|
||||
BindRequest.h \
|
||||
AuthenticationChoice.h \
|
||||
SaslCredentials.h \
|
||||
BindResponse.h \
|
||||
UnbindRequest.h \
|
||||
SearchRequest.h \
|
||||
AttributeSelection.h \
|
||||
Filter.h \
|
||||
SubstringFilter.h \
|
||||
MatchingRuleAssertion.h \
|
||||
SearchResultEntry.h \
|
||||
PartialAttributeList.h \
|
||||
SearchResultReference.h \
|
||||
SearchResultDone.h \
|
||||
ModifyRequest.h \
|
||||
ModifyResponse.h \
|
||||
AddRequest.h \
|
||||
AttributeList.h \
|
||||
AddResponse.h \
|
||||
DelRequest.h \
|
||||
DelResponse.h \
|
||||
ModifyDNRequest.h \
|
||||
ModifyDNResponse.h \
|
||||
CompareRequest.h \
|
||||
CompareResponse.h \
|
||||
AbandonRequest.h \
|
||||
ExtendedRequest.h \
|
||||
ExtendedResponse.h \
|
||||
IntermediateResponse.h
|
||||
|
||||
ASN_MODULE_HEADERS+=BOOLEAN.h
|
||||
ASN_MODULE_SOURCES+=BOOLEAN.c
|
||||
ASN_MODULE_HEADERS+=INTEGER.h
|
||||
ASN_MODULE_HEADERS+=NativeEnumerated.h
|
||||
ASN_MODULE_SOURCES+=INTEGER.c
|
||||
ASN_MODULE_HEADERS+=NULL.h
|
||||
ASN_MODULE_SOURCES+=NULL.c
|
||||
ASN_MODULE_SOURCES+=NativeEnumerated.c
|
||||
ASN_MODULE_HEADERS+=NativeInteger.h
|
||||
ASN_MODULE_SOURCES+=NativeInteger.c
|
||||
ASN_MODULE_HEADERS+=asn_SEQUENCE_OF.h
|
||||
ASN_MODULE_SOURCES+=asn_SEQUENCE_OF.c
|
||||
ASN_MODULE_HEADERS+=asn_SET_OF.h
|
||||
ASN_MODULE_SOURCES+=asn_SET_OF.c
|
||||
ASN_MODULE_HEADERS+=constr_CHOICE.h
|
||||
ASN_MODULE_SOURCES+=constr_CHOICE.c
|
||||
ASN_MODULE_HEADERS+=constr_SEQUENCE.h
|
||||
ASN_MODULE_SOURCES+=constr_SEQUENCE.c
|
||||
ASN_MODULE_HEADERS+=constr_SEQUENCE_OF.h
|
||||
ASN_MODULE_SOURCES+=constr_SEQUENCE_OF.c
|
||||
ASN_MODULE_HEADERS+=constr_SET_OF.h
|
||||
ASN_MODULE_SOURCES+=constr_SET_OF.c
|
||||
ASN_MODULE_HEADERS+=asn_application.h
|
||||
ASN_MODULE_HEADERS+=asn_system.h
|
||||
ASN_MODULE_HEADERS+=asn_codecs.h
|
||||
ASN_MODULE_HEADERS+=asn_internal.h
|
||||
ASN_MODULE_HEADERS+=OCTET_STRING.h
|
||||
ASN_MODULE_SOURCES+=OCTET_STRING.c
|
||||
ASN_MODULE_HEADERS+=BIT_STRING.h
|
||||
ASN_MODULE_SOURCES+=BIT_STRING.c
|
||||
ASN_MODULE_SOURCES+=asn_codecs_prim.c
|
||||
ASN_MODULE_HEADERS+=asn_codecs_prim.h
|
||||
ASN_MODULE_HEADERS+=ber_tlv_length.h
|
||||
ASN_MODULE_SOURCES+=ber_tlv_length.c
|
||||
ASN_MODULE_HEADERS+=ber_tlv_tag.h
|
||||
ASN_MODULE_SOURCES+=ber_tlv_tag.c
|
||||
ASN_MODULE_HEADERS+=ber_decoder.h
|
||||
ASN_MODULE_SOURCES+=ber_decoder.c
|
||||
ASN_MODULE_HEADERS+=der_encoder.h
|
||||
ASN_MODULE_SOURCES+=der_encoder.c
|
||||
ASN_MODULE_HEADERS+=constr_TYPE.h
|
||||
ASN_MODULE_SOURCES+=constr_TYPE.c
|
||||
ASN_MODULE_HEADERS+=constraints.h
|
||||
ASN_MODULE_SOURCES+=constraints.c
|
||||
ASN_MODULE_HEADERS+=xer_support.h
|
||||
ASN_MODULE_SOURCES+=xer_support.c
|
||||
ASN_MODULE_HEADERS+=xer_decoder.h
|
||||
ASN_MODULE_SOURCES+=xer_decoder.c
|
||||
ASN_MODULE_HEADERS+=xer_encoder.h
|
||||
ASN_MODULE_SOURCES+=xer_encoder.c
|
||||
ASN_MODULE_HEADERS+=per_support.h
|
||||
ASN_MODULE_SOURCES+=per_support.c
|
||||
ASN_MODULE_HEADERS+=per_decoder.h
|
||||
ASN_MODULE_SOURCES+=per_decoder.c
|
||||
ASN_MODULE_HEADERS+=per_encoder.h
|
||||
ASN_MODULE_SOURCES+=per_encoder.c
|
||||
ASN_MODULE_HEADERS+=per_opentype.h
|
||||
ASN_MODULE_SOURCES+=per_opentype.c
|
||||
ASN_CONVERTER_SOURCES+=converter-sample.c
|
||||
|
||||
|
||||
lib_LTLIBRARIES=libsomething.la
|
||||
libsomething_la_SOURCES=$(ASN_MODULE_SOURCES) $(ASN_MODULE_HEADERS)
|
||||
|
||||
# This file may be used as an input for make(3)
|
||||
# Remove the lines below to convert it into a pure .am file
|
||||
TARGET = ldap3dump
|
||||
CFLAGS += -DASN_CONVERTER_TITLE="Lightweight Directory Access Protocol V3 decoder" -DHAVE_CONFIG_H -DJUNKTEST -DPDU=LDAPMessage -I.
|
||||
OBJS=${ASN_MODULE_SOURCES:.c=.o} ${ASN_CONVERTER_SOURCES:.c=.o}
|
||||
|
||||
all: LDAPMessage.c $(TARGET)
|
||||
|
||||
$(TARGET): ${OBJS}
|
||||
$(CC) $(CFLAGS) -o $(TARGET) ${OBJS} $(LDFLAGS) $(LIBS)
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .o
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) -o $@ -c $<
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET)
|
||||
rm -f $(OBJS)
|
||||
|
||||
regen: regenerate-from-asn1-source
|
||||
|
||||
regenerate-from-asn1-source:
|
||||
../../asn1c/asn1c -S ../../skeletons -pdu=LDAPMessage -fcompound-names ../rfc4511-Lightweight-Directory-Access-Protocol-V3.asn1
|
||||
ASN_PROGRAM = ldap3dump
|
||||
CFLAGS += -DASN_CONVERTER_TITLE="Lightweight Directory Access Protocol V3 decoder" -DHAVE_CONFIG_H -DJUNKTEST -D_DEFAULT_SOURCE
|
||||
begin: LDAPMessage.c maybe-wip-pause all
|
||||
|
||||
-include converter-example.mk
|
||||
|
||||
LDAPMessage.c: ../sample.makefile.regen ../rfc4511-Lightweight-Directory-Access-Protocol-V3.asn1
|
||||
make regen-makefile
|
||||
|
@ -194,76 +11,97 @@ LDAPMessage.c: ../sample.makefile.regen ../rfc4511-Lightweight-Directory-Access-
|
|||
|
||||
regen-makefile:
|
||||
TITLE="Lightweight Directory Access Protocol V3 decoder" \
|
||||
ASN1CMDOPTS="-fcompound-names" \
|
||||
ASN1MODULES="../rfc4511-Lightweight-Directory-Access-Protocol-V3.asn1" \
|
||||
ASN1PDU=LDAPMessage \
|
||||
PROGNAME=ldap3dump \
|
||||
ASN_CMDOPTS="-fcompound-names" \
|
||||
ASN_MODULES="../rfc4511-Lightweight-Directory-Access-Protocol-V3.asn1" \
|
||||
ASN_PDU=LDAPMessage \
|
||||
ASN_PROGRAM=ldap3dump \
|
||||
../sample.makefile.regen
|
||||
|
||||
check: ${TARGET} check-ber check-xer check-per
|
||||
check: ${ASN_PROGRAM} check-ber check-xer check-oer check-per
|
||||
@echo ================
|
||||
@echo All tests passed
|
||||
@echo ================
|
||||
|
||||
check-ber:
|
||||
@if test -f sample-LDAPMessage-1.[db]er ; then \
|
||||
for f in sample-LDAPMessage-*.[db]er; do \
|
||||
for f in sample-*-*.[db]er; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f into XER and back ($$b)..."; \
|
||||
./${TARGET} -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${TARGET} -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 4; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -iber -onull $$f || exit 5; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -iber -onull $$f || exit 6; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 5; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 6; \
|
||||
done; done; fi
|
||||
|
||||
check-xer:
|
||||
@if test -f sample-LDAPMessage-1.xer ; then \
|
||||
for f in sample-LDAPMessage-*.xer; do \
|
||||
for f in sample-*-*.xer; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f into DER and back ($$b)..."; \
|
||||
./${TARGET} -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
echo "Recoding $$f ($$pdu) into DER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
diff $$f ./.tmp.2.$$$$ || exit 4; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -ixer -onull $$f || exit 5; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -ixer -onull $$f || exit 6; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 5; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 6; \
|
||||
done; done; fi
|
||||
|
||||
check-oer:
|
||||
@if test -f sample-LDAPMessage-1.*oer ; then \
|
||||
for f in sample-*-*.*oer; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ioer -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -ooer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
diff $$f ./.tmp.2.$$$$ || exit 4; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait) ($$b) ..."; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 5; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 6; \
|
||||
done; done; fi
|
||||
|
||||
check-per:
|
||||
@if test -f sample-LDAPMessage-1-nopad.per ; then \
|
||||
for f in sample-LDAPMessage-[1-9]-nopad.per; do \
|
||||
for f in sample-*-[1-9]-nopad.per; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding non-padded $$f into DER into XER and back ($$b)..."; \
|
||||
./${TARGET} -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
./${TARGET} -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \
|
||||
echo "Recoding non-padded $$f ($$pdu) into DER into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \
|
||||
diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 5; \
|
||||
rm -f ./.tmp.[123].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -per-nopad -iper -onull $$f || exit 6; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -per-nopad -iper -onull $$f || exit 7; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 6; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 7; \
|
||||
done; done; fi
|
||||
@if test -f sample-LDAPMessage-1.per ; then \
|
||||
for f in sample-*-[1-9].per; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z-]+)-[0-9].*/\1/"`; \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f into DER into XER and back ($$b)..."; \
|
||||
./${TARGET} -b $$b -p $$pdu -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \
|
||||
./${TARGET} -b $$b -p $$pdu -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \
|
||||
./${TARGET} -b $$b -p $$pdu -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \
|
||||
echo "Recoding $$f ($$pdu) into DER into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \
|
||||
diff $$f ./.tmp.1.$$$$ || exit 6; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -iper -onull $$f || exit 7; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -iper -onull $$f || exit 8; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 7; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 8; \
|
||||
done; done; fi
|
||||
|
||||
maybe-wip-pause:
|
||||
@if [ -f WIP ]; then cat WIP; sleep 2; fi
|
||||
|
||||
distclean: clean
|
||||
rm -f $(ASN_MODULE_SOURCES)
|
||||
rm -f $(ASN_MODULE_HEADERS)
|
||||
rm -f $(ASN_CONVERTER_SOURCES) $(ASN_CONVERTER_HEADERS)
|
||||
rm -f Makefile.am.sample
|
||||
rm -f $(ASN_MODULE_SRCS)
|
||||
rm -f $(ASN_MODULE_HDRS)
|
||||
rm -f $(ASN_PROGRAM_SRCS) $(ASN_PROGRAM_HDRS)
|
||||
rm -f converter-example.mk
|
||||
|
|
|
@ -3,7 +3,7 @@ GENERAL INFORMATION
|
|||
===================
|
||||
|
||||
The LDAPv3 (Lightweight Directory Access Protocol) PDU decoder.
|
||||
Invoking `make` will compile the ASN.1 specifications from the rfc4211.txt
|
||||
Invoking `make` will compile the ASN.1 specifications from the rfc4511.txt
|
||||
in the above directory.
|
||||
|
||||
This LDAP decoder has been successfully tested against the PROTOS c06-ldapv3
|
||||
|
@ -13,7 +13,7 @@ http://www.ee.oulu.fi/research/ouspg/protos/testing/c06/ldapv3/index.html
|
|||
ldap3dump USAGE
|
||||
==============
|
||||
|
||||
./ldap3dump LDAPMessage.ber # Print as XML (BASIC-XER)
|
||||
./ldap3dump -p LDAPMessage -iber -oxer sample-LDAPMessage-1.ber # Print as XML (BASIC-XER)
|
||||
|
||||
The full list of recognized command line options may be obtained with
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,38 @@
|
|||
|
||||
GENERAL INFORMATION
|
||||
===================
|
||||
|
||||
The 3GPP TS 36.331 version 14.2.1 Radio Resource Control (RRC) Unaligned PER decoder.
|
||||
Invoking `make` will compile the ASN.1 specifications from the
|
||||
../lte-rrc-14.2.1.asn1 file.
|
||||
|
||||
Currently only Makefile and binary sample in this directory.
|
||||
|
||||
OBTAINING THE LTE-RRC SPECIFICATION
|
||||
===================================
|
||||
|
||||
To obtain this LTE-RRC ASN.1 specification or other version, you should go to
|
||||
http://www.3gpp.org/ftp/Specs/html-info/36331.htm
|
||||
and download any version of LTE-RRC specification you like.
|
||||
|
||||
A .ZIP file with a Microsoft Word .DOC files will download shortly.
|
||||
|
||||
You should extract the ASN.1 modules from that .DOC file.
|
||||
Be careful not to copy any preambles, chapter titles and other non-ASN.1 text.
|
||||
|
||||
lte-rrc-dump USAGE
|
||||
==================
|
||||
|
||||
The lte-rrc-dump utility may be used to dump the contents of a Unaligned PER-encoded
|
||||
LTE-RRC protocol data unit. Since LTE-RRC specification contains multiple PDUs,
|
||||
a PDU must be selected manually using -p <PDU> command line option:
|
||||
|
||||
./lte-rrc-dump -iper -p DL-DCCH-Message message.per
|
||||
./lte-rrc-dump -iper -p PCCH-Message message.per
|
||||
|
||||
The list of recognized PDUs may be obtained using `-p list`.
|
||||
|
||||
The full list of recognized command line options may be obtained with
|
||||
|
||||
> ./lte-rrc-dump -h
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
extern int opt_debug;
|
||||
|
||||
#define ASN_DEBUG(fmt, args...) do { \
|
||||
if(opt_debug < 2) break; \
|
||||
fprintf(stderr, fmt, ##args); \
|
||||
fprintf(stderr, " (%s:%d)\n", \
|
||||
__FILE__, __LINE__); \
|
||||
} while(0)
|
||||
|
Binary file not shown.
|
@ -1,313 +1,8 @@
|
|||
ASN_MODULE_SOURCES= \
|
||||
MegacoMessage.c \
|
||||
AuthenticationHeader.c \
|
||||
SecurityParmIndex.c \
|
||||
SequenceNum.c \
|
||||
AuthData.c \
|
||||
Message.c \
|
||||
MId.c \
|
||||
DomainName.c \
|
||||
IP4Address.c \
|
||||
IP6Address.c \
|
||||
PathName.c \
|
||||
Transaction.c \
|
||||
TransactionId.c \
|
||||
TransactionRequest.c \
|
||||
TransactionPending.c \
|
||||
TransactionReply.c \
|
||||
TransactionResponseAck.c \
|
||||
TransactionAck.c \
|
||||
ErrorDescriptor.c \
|
||||
ErrorCode.c \
|
||||
ErrorText.c \
|
||||
ContextID.c \
|
||||
ActionRequest.c \
|
||||
ActionReply.c \
|
||||
ContextRequest.c \
|
||||
ContextAttrAuditRequest.c \
|
||||
CommandRequest.c \
|
||||
Command.c \
|
||||
CommandReply.c \
|
||||
TopologyRequest.c \
|
||||
AmmRequest.c \
|
||||
AmmDescriptor.c \
|
||||
AmmsReply.c \
|
||||
SubtractRequest.c \
|
||||
AuditRequest.c \
|
||||
AuditReply.c \
|
||||
AuditResult.c \
|
||||
TerminationAudit.c \
|
||||
AuditReturnParameter.c \
|
||||
AuditDescriptor.c \
|
||||
NotifyRequest.c \
|
||||
NotifyReply.c \
|
||||
ObservedEventsDescriptor.c \
|
||||
ObservedEvent.c \
|
||||
EventName.c \
|
||||
EventParameter.c \
|
||||
ServiceChangeRequest.c \
|
||||
ServiceChangeReply.c \
|
||||
ServiceChangeResult.c \
|
||||
WildcardField.c \
|
||||
TerminationID.c \
|
||||
TerminationIDList.c \
|
||||
MediaDescriptor.c \
|
||||
StreamDescriptor.c \
|
||||
StreamParms.c \
|
||||
LocalControlDescriptor.c \
|
||||
StreamMode.c \
|
||||
PropertyParm.c \
|
||||
Name.c \
|
||||
PkgdName.c \
|
||||
Relation.c \
|
||||
LocalRemoteDescriptor.c \
|
||||
PropertyGroup.c \
|
||||
TerminationStateDescriptor.c \
|
||||
EventBufferControl.c \
|
||||
ServiceState.c \
|
||||
MuxDescriptor.c \
|
||||
MuxType.c \
|
||||
StreamID.c \
|
||||
EventsDescriptor.c \
|
||||
RequestedEvent.c \
|
||||
RequestedActions.c \
|
||||
EventDM.c \
|
||||
SecondEventsDescriptor.c \
|
||||
SecondRequestedEvent.c \
|
||||
SecondRequestedActions.c \
|
||||
EventBufferDescriptor.c \
|
||||
EventSpec.c \
|
||||
SignalsDescriptor.c \
|
||||
SignalRequest.c \
|
||||
SeqSigList.c \
|
||||
Signal.c \
|
||||
SignalType.c \
|
||||
SignalName.c \
|
||||
NotifyCompletion.c \
|
||||
SigParameter.c \
|
||||
RequestID.c \
|
||||
ModemDescriptor.c \
|
||||
ModemType.c \
|
||||
DigitMapDescriptor.c \
|
||||
DigitMapName.c \
|
||||
DigitMapValue.c \
|
||||
ServiceChangeParm.c \
|
||||
ServiceChangeAddress.c \
|
||||
ServiceChangeResParm.c \
|
||||
ServiceChangeMethod.c \
|
||||
ServiceChangeProfile.c \
|
||||
PackagesDescriptor.c \
|
||||
PackagesItem.c \
|
||||
StatisticsDescriptor.c \
|
||||
StatisticsParameter.c \
|
||||
NonStandardData.c \
|
||||
NonStandardIdentifier.c \
|
||||
H221NonStandard.c \
|
||||
TimeNotation.c \
|
||||
Value.c
|
||||
|
||||
ASN_MODULE_HEADERS= \
|
||||
MegacoMessage.h \
|
||||
AuthenticationHeader.h \
|
||||
SecurityParmIndex.h \
|
||||
SequenceNum.h \
|
||||
AuthData.h \
|
||||
Message.h \
|
||||
MId.h \
|
||||
DomainName.h \
|
||||
IP4Address.h \
|
||||
IP6Address.h \
|
||||
PathName.h \
|
||||
Transaction.h \
|
||||
TransactionId.h \
|
||||
TransactionRequest.h \
|
||||
TransactionPending.h \
|
||||
TransactionReply.h \
|
||||
TransactionResponseAck.h \
|
||||
TransactionAck.h \
|
||||
ErrorDescriptor.h \
|
||||
ErrorCode.h \
|
||||
ErrorText.h \
|
||||
ContextID.h \
|
||||
ActionRequest.h \
|
||||
ActionReply.h \
|
||||
ContextRequest.h \
|
||||
ContextAttrAuditRequest.h \
|
||||
CommandRequest.h \
|
||||
Command.h \
|
||||
CommandReply.h \
|
||||
TopologyRequest.h \
|
||||
AmmRequest.h \
|
||||
AmmDescriptor.h \
|
||||
AmmsReply.h \
|
||||
SubtractRequest.h \
|
||||
AuditRequest.h \
|
||||
AuditReply.h \
|
||||
AuditResult.h \
|
||||
TerminationAudit.h \
|
||||
AuditReturnParameter.h \
|
||||
AuditDescriptor.h \
|
||||
NotifyRequest.h \
|
||||
NotifyReply.h \
|
||||
ObservedEventsDescriptor.h \
|
||||
ObservedEvent.h \
|
||||
EventName.h \
|
||||
EventParameter.h \
|
||||
ServiceChangeRequest.h \
|
||||
ServiceChangeReply.h \
|
||||
ServiceChangeResult.h \
|
||||
WildcardField.h \
|
||||
TerminationID.h \
|
||||
TerminationIDList.h \
|
||||
MediaDescriptor.h \
|
||||
StreamDescriptor.h \
|
||||
StreamParms.h \
|
||||
LocalControlDescriptor.h \
|
||||
StreamMode.h \
|
||||
PropertyParm.h \
|
||||
Name.h \
|
||||
PkgdName.h \
|
||||
Relation.h \
|
||||
LocalRemoteDescriptor.h \
|
||||
PropertyGroup.h \
|
||||
TerminationStateDescriptor.h \
|
||||
EventBufferControl.h \
|
||||
ServiceState.h \
|
||||
MuxDescriptor.h \
|
||||
MuxType.h \
|
||||
StreamID.h \
|
||||
EventsDescriptor.h \
|
||||
RequestedEvent.h \
|
||||
RequestedActions.h \
|
||||
EventDM.h \
|
||||
SecondEventsDescriptor.h \
|
||||
SecondRequestedEvent.h \
|
||||
SecondRequestedActions.h \
|
||||
EventBufferDescriptor.h \
|
||||
EventSpec.h \
|
||||
SignalsDescriptor.h \
|
||||
SignalRequest.h \
|
||||
SeqSigList.h \
|
||||
Signal.h \
|
||||
SignalType.h \
|
||||
SignalName.h \
|
||||
NotifyCompletion.h \
|
||||
SigParameter.h \
|
||||
RequestID.h \
|
||||
ModemDescriptor.h \
|
||||
ModemType.h \
|
||||
DigitMapDescriptor.h \
|
||||
DigitMapName.h \
|
||||
DigitMapValue.h \
|
||||
ServiceChangeParm.h \
|
||||
ServiceChangeAddress.h \
|
||||
ServiceChangeResParm.h \
|
||||
ServiceChangeMethod.h \
|
||||
ServiceChangeProfile.h \
|
||||
PackagesDescriptor.h \
|
||||
PackagesItem.h \
|
||||
StatisticsDescriptor.h \
|
||||
StatisticsParameter.h \
|
||||
NonStandardData.h \
|
||||
NonStandardIdentifier.h \
|
||||
H221NonStandard.h \
|
||||
TimeNotation.h \
|
||||
Value.h
|
||||
|
||||
ASN_MODULE_HEADERS+=BOOLEAN.h
|
||||
ASN_MODULE_SOURCES+=BOOLEAN.c
|
||||
ASN_MODULE_HEADERS+=INTEGER.h
|
||||
ASN_MODULE_HEADERS+=NativeEnumerated.h
|
||||
ASN_MODULE_HEADERS+=IA5String.h
|
||||
ASN_MODULE_SOURCES+=IA5String.c
|
||||
ASN_MODULE_SOURCES+=INTEGER.c
|
||||
ASN_MODULE_HEADERS+=NULL.h
|
||||
ASN_MODULE_SOURCES+=NULL.c
|
||||
ASN_MODULE_SOURCES+=NativeEnumerated.c
|
||||
ASN_MODULE_HEADERS+=NativeInteger.h
|
||||
ASN_MODULE_SOURCES+=NativeInteger.c
|
||||
ASN_MODULE_HEADERS+=OBJECT_IDENTIFIER.h
|
||||
ASN_MODULE_SOURCES+=OBJECT_IDENTIFIER.c
|
||||
ASN_MODULE_HEADERS+=asn_SEQUENCE_OF.h
|
||||
ASN_MODULE_SOURCES+=asn_SEQUENCE_OF.c
|
||||
ASN_MODULE_HEADERS+=asn_SET_OF.h
|
||||
ASN_MODULE_SOURCES+=asn_SET_OF.c
|
||||
ASN_MODULE_HEADERS+=constr_CHOICE.h
|
||||
ASN_MODULE_SOURCES+=constr_CHOICE.c
|
||||
ASN_MODULE_HEADERS+=constr_SEQUENCE.h
|
||||
ASN_MODULE_SOURCES+=constr_SEQUENCE.c
|
||||
ASN_MODULE_HEADERS+=constr_SEQUENCE_OF.h
|
||||
ASN_MODULE_SOURCES+=constr_SEQUENCE_OF.c
|
||||
ASN_MODULE_HEADERS+=constr_SET_OF.h
|
||||
ASN_MODULE_SOURCES+=constr_SET_OF.c
|
||||
ASN_MODULE_HEADERS+=asn_application.h
|
||||
ASN_MODULE_HEADERS+=asn_system.h
|
||||
ASN_MODULE_HEADERS+=asn_codecs.h
|
||||
ASN_MODULE_HEADERS+=asn_internal.h
|
||||
ASN_MODULE_HEADERS+=OCTET_STRING.h
|
||||
ASN_MODULE_SOURCES+=OCTET_STRING.c
|
||||
ASN_MODULE_HEADERS+=BIT_STRING.h
|
||||
ASN_MODULE_SOURCES+=BIT_STRING.c
|
||||
ASN_MODULE_SOURCES+=asn_codecs_prim.c
|
||||
ASN_MODULE_HEADERS+=asn_codecs_prim.h
|
||||
ASN_MODULE_HEADERS+=ber_tlv_length.h
|
||||
ASN_MODULE_SOURCES+=ber_tlv_length.c
|
||||
ASN_MODULE_HEADERS+=ber_tlv_tag.h
|
||||
ASN_MODULE_SOURCES+=ber_tlv_tag.c
|
||||
ASN_MODULE_HEADERS+=ber_decoder.h
|
||||
ASN_MODULE_SOURCES+=ber_decoder.c
|
||||
ASN_MODULE_HEADERS+=der_encoder.h
|
||||
ASN_MODULE_SOURCES+=der_encoder.c
|
||||
ASN_MODULE_HEADERS+=constr_TYPE.h
|
||||
ASN_MODULE_SOURCES+=constr_TYPE.c
|
||||
ASN_MODULE_HEADERS+=constraints.h
|
||||
ASN_MODULE_SOURCES+=constraints.c
|
||||
ASN_MODULE_HEADERS+=xer_support.h
|
||||
ASN_MODULE_SOURCES+=xer_support.c
|
||||
ASN_MODULE_HEADERS+=xer_decoder.h
|
||||
ASN_MODULE_SOURCES+=xer_decoder.c
|
||||
ASN_MODULE_HEADERS+=xer_encoder.h
|
||||
ASN_MODULE_SOURCES+=xer_encoder.c
|
||||
ASN_MODULE_HEADERS+=per_support.h
|
||||
ASN_MODULE_SOURCES+=per_support.c
|
||||
ASN_MODULE_HEADERS+=per_decoder.h
|
||||
ASN_MODULE_SOURCES+=per_decoder.c
|
||||
ASN_MODULE_HEADERS+=per_encoder.h
|
||||
ASN_MODULE_SOURCES+=per_encoder.c
|
||||
ASN_MODULE_HEADERS+=per_opentype.h
|
||||
ASN_MODULE_SOURCES+=per_opentype.c
|
||||
ASN_CONVERTER_SOURCES+=converter-sample.c
|
||||
|
||||
|
||||
lib_LTLIBRARIES=libsomething.la
|
||||
libsomething_la_SOURCES=$(ASN_MODULE_SOURCES) $(ASN_MODULE_HEADERS)
|
||||
|
||||
# This file may be used as an input for make(3)
|
||||
# Remove the lines below to convert it into a pure .am file
|
||||
TARGET = megaco-dump
|
||||
CFLAGS += -DHAVE_CONFIG_H -DJUNKTEST -DPDU=MegacoMessage -I.
|
||||
OBJS=${ASN_MODULE_SOURCES:.c=.o} ${ASN_CONVERTER_SOURCES:.c=.o}
|
||||
|
||||
all: MegacoMessage.c $(TARGET)
|
||||
|
||||
$(TARGET): ${OBJS}
|
||||
$(CC) $(CFLAGS) -o $(TARGET) ${OBJS} $(LDFLAGS) $(LIBS)
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .o
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) -o $@ -c $<
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET)
|
||||
rm -f $(OBJS)
|
||||
|
||||
regen: regenerate-from-asn1-source
|
||||
|
||||
regenerate-from-asn1-source:
|
||||
../../asn1c/asn1c -S ../../skeletons -pdu=MegacoMessage -fcompound-names ../rfc3525-MEDIA-GATEWAY-CONTROL.asn1
|
||||
ASN_PROGRAM = megaco-dump
|
||||
CFLAGS += -DHAVE_CONFIG_H -DJUNKTEST -D_DEFAULT_SOURCE
|
||||
begin: MegacoMessage.c maybe-wip-pause all
|
||||
|
||||
-include converter-example.mk
|
||||
|
||||
MegacoMessage.c: ../sample.makefile.regen ../rfc3525-MEDIA-GATEWAY-CONTROL.asn1
|
||||
make regen-makefile
|
||||
|
@ -315,76 +10,97 @@ MegacoMessage.c: ../sample.makefile.regen ../rfc3525-MEDIA-GATEWAY-CONTROL.asn1
|
|||
make
|
||||
|
||||
regen-makefile:
|
||||
ASN1CMDOPTS="-fcompound-names" \
|
||||
ASN1MODULES="../rfc3525-MEDIA-GATEWAY-CONTROL.asn1" \
|
||||
ASN1PDU=MegacoMessage \
|
||||
PROGNAME=megaco-dump \
|
||||
ASN_CMDOPTS="-fcompound-names" \
|
||||
ASN_MODULES="../rfc3525-MEDIA-GATEWAY-CONTROL.asn1" \
|
||||
ASN_PDU=MegacoMessage \
|
||||
ASN_PROGRAM=megaco-dump \
|
||||
../sample.makefile.regen
|
||||
|
||||
check: ${TARGET} check-ber check-xer check-per
|
||||
check: ${ASN_PROGRAM} check-ber check-xer check-oer check-per
|
||||
@echo ================
|
||||
@echo All tests passed
|
||||
@echo ================
|
||||
|
||||
check-ber:
|
||||
@if test -f sample-MegacoMessage-1.[db]er ; then \
|
||||
for f in sample-MegacoMessage-*.[db]er; do \
|
||||
for f in sample-*-*.[db]er; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f into XER and back ($$b)..."; \
|
||||
./${TARGET} -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${TARGET} -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 4; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -iber -onull $$f || exit 5; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -iber -onull $$f || exit 6; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 5; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 6; \
|
||||
done; done; fi
|
||||
|
||||
check-xer:
|
||||
@if test -f sample-MegacoMessage-1.xer ; then \
|
||||
for f in sample-MegacoMessage-*.xer; do \
|
||||
for f in sample-*-*.xer; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f into DER and back ($$b)..."; \
|
||||
./${TARGET} -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
echo "Recoding $$f ($$pdu) into DER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
diff $$f ./.tmp.2.$$$$ || exit 4; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -ixer -onull $$f || exit 5; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -ixer -onull $$f || exit 6; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 5; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 6; \
|
||||
done; done; fi
|
||||
|
||||
check-oer:
|
||||
@if test -f sample-MegacoMessage-1.*oer ; then \
|
||||
for f in sample-*-*.*oer; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ioer -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -ooer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
diff $$f ./.tmp.2.$$$$ || exit 4; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait) ($$b) ..."; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 5; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 6; \
|
||||
done; done; fi
|
||||
|
||||
check-per:
|
||||
@if test -f sample-MegacoMessage-1-nopad.per ; then \
|
||||
for f in sample-MegacoMessage-[1-9]-nopad.per; do \
|
||||
for f in sample-*-[1-9]-nopad.per; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding non-padded $$f into DER into XER and back ($$b)..."; \
|
||||
./${TARGET} -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
./${TARGET} -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \
|
||||
echo "Recoding non-padded $$f ($$pdu) into DER into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \
|
||||
diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 5; \
|
||||
rm -f ./.tmp.[123].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -per-nopad -iper -onull $$f || exit 6; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -per-nopad -iper -onull $$f || exit 7; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 6; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 7; \
|
||||
done; done; fi
|
||||
@if test -f sample-MegacoMessage-1.per ; then \
|
||||
for f in sample-*-[1-9].per; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z-]+)-[0-9].*/\1/"`; \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f into DER into XER and back ($$b)..."; \
|
||||
./${TARGET} -b $$b -p $$pdu -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \
|
||||
./${TARGET} -b $$b -p $$pdu -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \
|
||||
./${TARGET} -b $$b -p $$pdu -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \
|
||||
echo "Recoding $$f ($$pdu) into DER into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \
|
||||
diff $$f ./.tmp.1.$$$$ || exit 6; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -iper -onull $$f || exit 7; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -iper -onull $$f || exit 8; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 7; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 8; \
|
||||
done; done; fi
|
||||
|
||||
maybe-wip-pause:
|
||||
@if [ -f WIP ]; then cat WIP; sleep 2; fi
|
||||
|
||||
distclean: clean
|
||||
rm -f $(ASN_MODULE_SOURCES)
|
||||
rm -f $(ASN_MODULE_HEADERS)
|
||||
rm -f $(ASN_CONVERTER_SOURCES) $(ASN_CONVERTER_HEADERS)
|
||||
rm -f Makefile.am.sample
|
||||
rm -f $(ASN_MODULE_SRCS)
|
||||
rm -f $(ASN_MODULE_HDRS)
|
||||
rm -f $(ASN_PROGRAM_SRCS) $(ASN_PROGRAM_HDRS)
|
||||
rm -f converter-example.mk
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
ASN_MODULE_SOURCES= \
|
||||
ASN_MODULE_SRCS= \
|
||||
InterchangedObject.c \
|
||||
RootClass.c \
|
||||
GroupClass.c \
|
||||
|
@ -186,10 +186,9 @@ ASN_MODULE_SOURCES= \
|
|||
GenericBoolean.c \
|
||||
GenericOctetString.c \
|
||||
Colour.c \
|
||||
XYPosition.c \
|
||||
OctetString.c
|
||||
XYPosition.c
|
||||
|
||||
ASN_MODULE_HEADERS= \
|
||||
ASN_MODULE_HDRS= \
|
||||
InterchangedObject.h \
|
||||
RootClass.h \
|
||||
GroupClass.h \
|
||||
|
@ -377,84 +376,79 @@ ASN_MODULE_HEADERS= \
|
|||
GenericBoolean.h \
|
||||
GenericOctetString.h \
|
||||
Colour.h \
|
||||
XYPosition.h \
|
||||
OctetString.h
|
||||
XYPosition.h
|
||||
|
||||
ASN_MODULE_HEADERS+=ANY.h
|
||||
ASN_MODULE_SOURCES+=ANY.c
|
||||
ASN_MODULE_HEADERS+=BOOLEAN.h
|
||||
ASN_MODULE_SOURCES+=BOOLEAN.c
|
||||
ASN_MODULE_HEADERS+=ENUMERATED.h
|
||||
ASN_MODULE_SOURCES+=ENUMERATED.c
|
||||
ASN_MODULE_HEADERS+=INTEGER.h
|
||||
ASN_MODULE_HEADERS+=NativeEnumerated.h
|
||||
ASN_MODULE_HEADERS+=IA5String.h
|
||||
ASN_MODULE_SOURCES+=IA5String.c
|
||||
ASN_MODULE_SOURCES+=INTEGER.c
|
||||
ASN_MODULE_HEADERS+=NULL.h
|
||||
ASN_MODULE_SOURCES+=NULL.c
|
||||
ASN_MODULE_SOURCES+=NativeEnumerated.c
|
||||
ASN_MODULE_HEADERS+=NativeInteger.h
|
||||
ASN_MODULE_SOURCES+=NativeInteger.c
|
||||
ASN_MODULE_HEADERS+=asn_SEQUENCE_OF.h
|
||||
ASN_MODULE_SOURCES+=asn_SEQUENCE_OF.c
|
||||
ASN_MODULE_HEADERS+=asn_SET_OF.h
|
||||
ASN_MODULE_SOURCES+=asn_SET_OF.c
|
||||
ASN_MODULE_HEADERS+=constr_CHOICE.h
|
||||
ASN_MODULE_SOURCES+=constr_CHOICE.c
|
||||
ASN_MODULE_HEADERS+=constr_SEQUENCE.h
|
||||
ASN_MODULE_SOURCES+=constr_SEQUENCE.c
|
||||
ASN_MODULE_HEADERS+=constr_SEQUENCE_OF.h
|
||||
ASN_MODULE_SOURCES+=constr_SEQUENCE_OF.c
|
||||
ASN_MODULE_HEADERS+=constr_SET_OF.h
|
||||
ASN_MODULE_HEADERS+=constr_SET.h
|
||||
ASN_MODULE_SOURCES+=constr_SET.c
|
||||
ASN_MODULE_SOURCES+=constr_SET_OF.c
|
||||
ASN_MODULE_HEADERS+=asn_application.h
|
||||
ASN_MODULE_HEADERS+=asn_system.h
|
||||
ASN_MODULE_HEADERS+=asn_codecs.h
|
||||
ASN_MODULE_HEADERS+=asn_internal.h
|
||||
ASN_MODULE_HEADERS+=OCTET_STRING.h
|
||||
ASN_MODULE_SOURCES+=OCTET_STRING.c
|
||||
ASN_MODULE_HEADERS+=BIT_STRING.h
|
||||
ASN_MODULE_SOURCES+=BIT_STRING.c
|
||||
ASN_MODULE_SOURCES+=asn_codecs_prim.c
|
||||
ASN_MODULE_HEADERS+=asn_codecs_prim.h
|
||||
ASN_MODULE_HEADERS+=ber_tlv_length.h
|
||||
ASN_MODULE_SOURCES+=ber_tlv_length.c
|
||||
ASN_MODULE_HEADERS+=ber_tlv_tag.h
|
||||
ASN_MODULE_SOURCES+=ber_tlv_tag.c
|
||||
ASN_MODULE_HEADERS+=ber_decoder.h
|
||||
ASN_MODULE_SOURCES+=ber_decoder.c
|
||||
ASN_MODULE_HEADERS+=der_encoder.h
|
||||
ASN_MODULE_SOURCES+=der_encoder.c
|
||||
ASN_MODULE_HEADERS+=constr_TYPE.h
|
||||
ASN_MODULE_SOURCES+=constr_TYPE.c
|
||||
ASN_MODULE_HEADERS+=constraints.h
|
||||
ASN_MODULE_SOURCES+=constraints.c
|
||||
ASN_MODULE_HEADERS+=xer_support.h
|
||||
ASN_MODULE_SOURCES+=xer_support.c
|
||||
ASN_MODULE_HEADERS+=xer_decoder.h
|
||||
ASN_MODULE_SOURCES+=xer_decoder.c
|
||||
ASN_MODULE_HEADERS+=xer_encoder.h
|
||||
ASN_MODULE_SOURCES+=xer_encoder.c
|
||||
ASN_MODULE_HEADERS+=per_support.h
|
||||
ASN_MODULE_SOURCES+=per_support.c
|
||||
ASN_MODULE_HEADERS+=per_decoder.h
|
||||
ASN_MODULE_SOURCES+=per_decoder.c
|
||||
ASN_MODULE_HEADERS+=per_encoder.h
|
||||
ASN_MODULE_SOURCES+=per_encoder.c
|
||||
ASN_MODULE_HDRS+=BOOLEAN.h
|
||||
ASN_MODULE_SRCS+=BOOLEAN.c
|
||||
ASN_MODULE_HDRS+=INTEGER.h
|
||||
ASN_MODULE_HDRS+=NativeEnumerated.h
|
||||
ASN_MODULE_SRCS+=INTEGER.c
|
||||
ASN_MODULE_HDRS+=NULL.h
|
||||
ASN_MODULE_SRCS+=NULL.c
|
||||
ASN_MODULE_SRCS+=NativeEnumerated.c
|
||||
ASN_MODULE_HDRS+=NativeInteger.h
|
||||
ASN_MODULE_SRCS+=NativeInteger.c
|
||||
ASN_MODULE_HDRS+=asn_SEQUENCE_OF.h
|
||||
ASN_MODULE_SRCS+=asn_SEQUENCE_OF.c
|
||||
ASN_MODULE_HDRS+=asn_SET_OF.h
|
||||
ASN_MODULE_SRCS+=asn_SET_OF.c
|
||||
ASN_MODULE_HDRS+=constr_CHOICE.h
|
||||
ASN_MODULE_SRCS+=constr_CHOICE.c
|
||||
ASN_MODULE_HDRS+=constr_SEQUENCE.h
|
||||
ASN_MODULE_SRCS+=constr_SEQUENCE.c
|
||||
ASN_MODULE_HDRS+=constr_SEQUENCE_OF.h
|
||||
ASN_MODULE_SRCS+=constr_SEQUENCE_OF.c
|
||||
ASN_MODULE_HDRS+=constr_SET_OF.h
|
||||
ASN_MODULE_HDRS+=constr_SET.h
|
||||
ASN_MODULE_SRCS+=constr_SET.c
|
||||
ASN_MODULE_SRCS+=constr_SET_OF.c
|
||||
ASN_MODULE_HDRS+=asn_application.h
|
||||
ASN_MODULE_HDRS+=asn_system.h
|
||||
ASN_MODULE_HDRS+=asn_codecs.h
|
||||
ASN_MODULE_HDRS+=asn_internal.h
|
||||
ASN_MODULE_HDRS+=OCTET_STRING.h
|
||||
ASN_MODULE_SRCS+=OCTET_STRING.c
|
||||
ASN_MODULE_HDRS+=BIT_STRING.h
|
||||
ASN_MODULE_SRCS+=BIT_STRING.c
|
||||
ASN_MODULE_SRCS+=asn_codecs_prim.c
|
||||
ASN_MODULE_HDRS+=asn_codecs_prim.h
|
||||
ASN_MODULE_HDRS+=ber_tlv_length.h
|
||||
ASN_MODULE_SRCS+=ber_tlv_length.c
|
||||
ASN_MODULE_HDRS+=ber_tlv_tag.h
|
||||
ASN_MODULE_SRCS+=ber_tlv_tag.c
|
||||
ASN_MODULE_HDRS+=ber_decoder.h
|
||||
ASN_MODULE_SRCS+=ber_decoder.c
|
||||
ASN_MODULE_HDRS+=der_encoder.h
|
||||
ASN_MODULE_SRCS+=der_encoder.c
|
||||
ASN_MODULE_HDRS+=constr_TYPE.h
|
||||
ASN_MODULE_SRCS+=constr_TYPE.c
|
||||
ASN_MODULE_HDRS+=constraints.h
|
||||
ASN_MODULE_SRCS+=constraints.c
|
||||
ASN_MODULE_HDRS+=xer_support.h
|
||||
ASN_MODULE_SRCS+=xer_support.c
|
||||
ASN_MODULE_HDRS+=xer_decoder.h
|
||||
ASN_MODULE_SRCS+=xer_decoder.c
|
||||
ASN_MODULE_HDRS+=xer_encoder.h
|
||||
ASN_MODULE_SRCS+=xer_encoder.c
|
||||
ASN_MODULE_HDRS+=per_support.h
|
||||
ASN_MODULE_SRCS+=per_support.c
|
||||
ASN_MODULE_HDRS+=per_decoder.h
|
||||
ASN_MODULE_SRCS+=per_decoder.c
|
||||
ASN_MODULE_HDRS+=per_encoder.h
|
||||
ASN_MODULE_SRCS+=per_encoder.c
|
||||
ASN_MODULE_HDRS+=per_opentype.h
|
||||
ASN_MODULE_SRCS+=per_opentype.c
|
||||
ASN_CONVERTER_SOURCES+=converter-sample.c
|
||||
|
||||
|
||||
lib_LTLIBRARIES=libsomething.la
|
||||
libsomething_la_SOURCES=$(ASN_MODULE_SOURCES) $(ASN_MODULE_HEADERS)
|
||||
libsomething_la_SOURCES=$(ASN_MODULE_SRCS) $(ASN_MODULE_HDRS)
|
||||
|
||||
# This file may be used as an input for make(3)
|
||||
# Remove the lines below to convert it into a pure .am file
|
||||
TARGET = mheg5dump
|
||||
CFLAGS += -DHAVE_CONFIG_H -DJUNKTEST -DPDU=InterchangedObject -I.
|
||||
OBJS=${ASN_MODULE_SOURCES:.c=.o} ${ASN_CONVERTER_SOURCES:.c=.o}
|
||||
CFLAGS += -DHAVE_CONFIG_H -DJUNKTEST -D_DEFAULT_SOURCE -DPDU=InterchangedObject -I.
|
||||
OBJS=${ASN_MODULE_SRCS:.c=.o} ${ASN_CONVERTER_SOURCES:.c=.o}
|
||||
|
||||
all: InterchangedObject.c $(TARGET)
|
||||
|
||||
|
@ -483,10 +477,11 @@ InterchangedObject.c: ../sample.makefile.regen ../ISO13522-MHEG-5.asn
|
|||
make
|
||||
|
||||
regen-makefile:
|
||||
ASN1CMDOPTS="-fcompound-names" \
|
||||
ASN1MODULES="../ISO13522-MHEG-5.asn" \
|
||||
ASN1PDU=InterchangedObject \
|
||||
PROGNAME=mheg5dump \
|
||||
ASN_CMDOPTS="-fcompound-names" \
|
||||
ASN_MODULES="../ISO13522-MHEG-5.asn" \
|
||||
ASN_PDU=InterchangedObject \
|
||||
ASN_PROGRAM=mheg5dump \
|
||||
CFLAGS="" \
|
||||
../sample.makefile.regen
|
||||
|
||||
check: ${TARGET} check-ber check-xer check-per
|
||||
|
@ -500,12 +495,12 @@ check-ber:
|
|||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f into XER and back ($$b)..."; \
|
||||
./${TARGET} -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${TARGET} -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \
|
||||
diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 2; \
|
||||
./${TARGET} -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 4; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -iber -onull $$f || exit 2; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -iber -onull $$f || exit 2; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -iber -onull $$f || exit 5; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -iber -onull $$f || exit 6; \
|
||||
done; done; fi
|
||||
|
||||
check-xer:
|
||||
|
@ -514,45 +509,45 @@ check-xer:
|
|||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f into DER and back ($$b)..."; \
|
||||
./${TARGET} -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \
|
||||
diff $$f ./.tmp.2.$$$$ || exit 2; \
|
||||
./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
diff $$f ./.tmp.2.$$$$ || exit 4; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -ixer -onull $$f || exit 2; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -ixer -onull $$f || exit 2; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -ixer -onull $$f || exit 5; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -ixer -onull $$f || exit 6; \
|
||||
done; done; fi
|
||||
|
||||
check-per:
|
||||
@if test -f sample-InterchangedObject-1.per ; then \
|
||||
for f in sample-InterchangedObject-[1-9].per; do \
|
||||
@if test -f sample-InterchangedObject-1-nopad.per ; then \
|
||||
for f in sample-InterchangedObject-[1-9]-nopad.per; do \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f into DER into XER and back ($$b)..."; \
|
||||
./${TARGET} -b $$b -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \
|
||||
./${TARGET} -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 2; \
|
||||
diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 2; \
|
||||
echo "Recoding non-padded $$f into DER into XER and back ($$b)..."; \
|
||||
./${TARGET} -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
./${TARGET} -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \
|
||||
diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 5; \
|
||||
rm -f ./.tmp.[123].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -iper -onull $$f || exit 2; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -iper -onull $$f || exit 2; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -per-nopad -iper -onull $$f || exit 6; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -per-nopad -iper -onull $$f || exit 7; \
|
||||
done; done; fi
|
||||
@if test -f sample-InterchangedObject-1-padded.per ; then \
|
||||
for f in sample-*-[1-9]-padded.per; do \
|
||||
@if test -f sample-InterchangedObject-1.per ; then \
|
||||
for f in sample-*-[1-9].per; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding byte-padded $$f into DER into XER and back ($$b)..."; \
|
||||
./${TARGET} -b $$b -per-padded -p $$pdu -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${TARGET} -b $$b -p $$pdu -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \
|
||||
./${TARGET} -b $$b -p $$pdu -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 2; \
|
||||
diff $$f ./.tmp.1.$$$$ || exit 2; \
|
||||
echo "Recoding $$f into DER into XER and back ($$b)..."; \
|
||||
./${TARGET} -b $$b -p $$pdu -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \
|
||||
./${TARGET} -b $$b -p $$pdu -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \
|
||||
./${TARGET} -b $$b -p $$pdu -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \
|
||||
diff $$f ./.tmp.1.$$$$ || exit 6; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -per-padded -iper -onull $$f || exit 2; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -per-padded -iper -onull $$f || exit 2; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -iper -onull $$f || exit 7; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -iper -onull $$f || exit 8; \
|
||||
done; done; fi
|
||||
|
||||
distclean: clean
|
||||
rm -f $(ASN_MODULE_SOURCES)
|
||||
rm -f $(ASN_MODULE_HEADERS)
|
||||
rm -f $(ASN_MODULE_SRCS)
|
||||
rm -f $(ASN_MODULE_HDRS)
|
||||
rm -f $(ASN_CONVERTER_SOURCES) $(ASN_CONVERTER_HEADERS)
|
||||
rm -f Makefile.am.sample
|
||||
|
|
|
@ -1,373 +1,8 @@
|
|||
ASN_MODULE_SOURCES= \
|
||||
Attribute.c \
|
||||
AttributeType.c \
|
||||
AttributeValue.c \
|
||||
AttributeTypeAndValue.c \
|
||||
X520name.c \
|
||||
X520CommonName.c \
|
||||
X520LocalityName.c \
|
||||
X520StateOrProvinceName.c \
|
||||
X520OrganizationName.c \
|
||||
X520OrganizationalUnitName.c \
|
||||
X520Title.c \
|
||||
X520dnQualifier.c \
|
||||
X520countryName.c \
|
||||
X520SerialNumber.c \
|
||||
X520Pseudonym.c \
|
||||
DomainComponent.c \
|
||||
EmailAddress.c \
|
||||
Name.c \
|
||||
RDNSequence.c \
|
||||
DistinguishedName.c \
|
||||
RelativeDistinguishedName.c \
|
||||
DirectoryString.c \
|
||||
Certificate.c \
|
||||
TBSCertificate.c \
|
||||
Version.c \
|
||||
CertificateSerialNumber.c \
|
||||
Validity.c \
|
||||
Time.c \
|
||||
UniqueIdentifier.c \
|
||||
SubjectPublicKeyInfo.c \
|
||||
Extensions.c \
|
||||
Extension.c \
|
||||
CertificateList.c \
|
||||
TBSCertList.c \
|
||||
AlgorithmIdentifier.c \
|
||||
ORAddress.c \
|
||||
BuiltInStandardAttributes.c \
|
||||
CountryName.c \
|
||||
AdministrationDomainName.c \
|
||||
NetworkAddress.c \
|
||||
X121Address.c \
|
||||
TerminalIdentifier.c \
|
||||
PrivateDomainName.c \
|
||||
OrganizationName.c \
|
||||
NumericUserIdentifier.c \
|
||||
PersonalName.c \
|
||||
OrganizationalUnitNames.c \
|
||||
OrganizationalUnitName.c \
|
||||
BuiltInDomainDefinedAttributes.c \
|
||||
BuiltInDomainDefinedAttribute.c \
|
||||
ExtensionAttributes.c \
|
||||
ExtensionAttribute.c \
|
||||
CommonName.c \
|
||||
TeletexCommonName.c \
|
||||
TeletexOrganizationName.c \
|
||||
TeletexPersonalName.c \
|
||||
TeletexOrganizationalUnitNames.c \
|
||||
TeletexOrganizationalUnitName.c \
|
||||
PDSName.c \
|
||||
PhysicalDeliveryCountryName.c \
|
||||
PostalCode.c \
|
||||
PhysicalDeliveryOfficeName.c \
|
||||
PhysicalDeliveryOfficeNumber.c \
|
||||
ExtensionORAddressComponents.c \
|
||||
PhysicalDeliveryPersonalName.c \
|
||||
PhysicalDeliveryOrganizationName.c \
|
||||
ExtensionPhysicalDeliveryAddressComponents.c \
|
||||
UnformattedPostalAddress.c \
|
||||
StreetAddress.c \
|
||||
PostOfficeBoxAddress.c \
|
||||
PosteRestanteAddress.c \
|
||||
UniquePostalName.c \
|
||||
LocalPostalAttributes.c \
|
||||
PDSParameter.c \
|
||||
ExtendedNetworkAddress.c \
|
||||
PresentationAddress.c \
|
||||
TerminalType.c \
|
||||
TeletexDomainDefinedAttributes.c \
|
||||
TeletexDomainDefinedAttribute.c \
|
||||
AuthorityKeyIdentifier.c \
|
||||
KeyIdentifier.c \
|
||||
SubjectKeyIdentifier.c \
|
||||
KeyUsage.c \
|
||||
PrivateKeyUsagePeriod.c \
|
||||
CertificatePolicies.c \
|
||||
PolicyInformation.c \
|
||||
CertPolicyId.c \
|
||||
PolicyQualifierInfo.c \
|
||||
PolicyQualifierId.c \
|
||||
CPSuri.c \
|
||||
UserNotice.c \
|
||||
NoticeReference.c \
|
||||
DisplayText.c \
|
||||
PolicyMappings.c \
|
||||
SubjectAltName.c \
|
||||
GeneralNames.c \
|
||||
GeneralName.c \
|
||||
AnotherName.c \
|
||||
EDIPartyName.c \
|
||||
IssuerAltName.c \
|
||||
SubjectDirectoryAttributes.c \
|
||||
BasicConstraints.c \
|
||||
NameConstraints.c \
|
||||
GeneralSubtrees.c \
|
||||
GeneralSubtree.c \
|
||||
BaseDistance.c \
|
||||
PolicyConstraints.c \
|
||||
SkipCerts.c \
|
||||
CRLDistributionPoints.c \
|
||||
DistributionPoint.c \
|
||||
DistributionPointName.c \
|
||||
ReasonFlags.c \
|
||||
ExtKeyUsageSyntax.c \
|
||||
KeyPurposeId.c \
|
||||
InhibitAnyPolicy.c \
|
||||
FreshestCRL.c \
|
||||
AuthorityInfoAccessSyntax.c \
|
||||
AccessDescription.c \
|
||||
SubjectInfoAccessSyntax.c \
|
||||
CRLNumber.c \
|
||||
IssuingDistributionPoint.c \
|
||||
BaseCRLNumber.c \
|
||||
CRLReason.c \
|
||||
CertificateIssuer.c \
|
||||
HoldInstructionCode.c \
|
||||
InvalidityDate.c
|
||||
|
||||
ASN_MODULE_HEADERS= \
|
||||
Attribute.h \
|
||||
AttributeType.h \
|
||||
AttributeValue.h \
|
||||
AttributeTypeAndValue.h \
|
||||
X520name.h \
|
||||
X520CommonName.h \
|
||||
X520LocalityName.h \
|
||||
X520StateOrProvinceName.h \
|
||||
X520OrganizationName.h \
|
||||
X520OrganizationalUnitName.h \
|
||||
X520Title.h \
|
||||
X520dnQualifier.h \
|
||||
X520countryName.h \
|
||||
X520SerialNumber.h \
|
||||
X520Pseudonym.h \
|
||||
DomainComponent.h \
|
||||
EmailAddress.h \
|
||||
Name.h \
|
||||
RDNSequence.h \
|
||||
DistinguishedName.h \
|
||||
RelativeDistinguishedName.h \
|
||||
DirectoryString.h \
|
||||
Certificate.h \
|
||||
TBSCertificate.h \
|
||||
Version.h \
|
||||
CertificateSerialNumber.h \
|
||||
Validity.h \
|
||||
Time.h \
|
||||
UniqueIdentifier.h \
|
||||
SubjectPublicKeyInfo.h \
|
||||
Extensions.h \
|
||||
Extension.h \
|
||||
CertificateList.h \
|
||||
TBSCertList.h \
|
||||
AlgorithmIdentifier.h \
|
||||
ORAddress.h \
|
||||
BuiltInStandardAttributes.h \
|
||||
CountryName.h \
|
||||
AdministrationDomainName.h \
|
||||
NetworkAddress.h \
|
||||
X121Address.h \
|
||||
TerminalIdentifier.h \
|
||||
PrivateDomainName.h \
|
||||
OrganizationName.h \
|
||||
NumericUserIdentifier.h \
|
||||
PersonalName.h \
|
||||
OrganizationalUnitNames.h \
|
||||
OrganizationalUnitName.h \
|
||||
BuiltInDomainDefinedAttributes.h \
|
||||
BuiltInDomainDefinedAttribute.h \
|
||||
ExtensionAttributes.h \
|
||||
ExtensionAttribute.h \
|
||||
CommonName.h \
|
||||
TeletexCommonName.h \
|
||||
TeletexOrganizationName.h \
|
||||
TeletexPersonalName.h \
|
||||
TeletexOrganizationalUnitNames.h \
|
||||
TeletexOrganizationalUnitName.h \
|
||||
PDSName.h \
|
||||
PhysicalDeliveryCountryName.h \
|
||||
PostalCode.h \
|
||||
PhysicalDeliveryOfficeName.h \
|
||||
PhysicalDeliveryOfficeNumber.h \
|
||||
ExtensionORAddressComponents.h \
|
||||
PhysicalDeliveryPersonalName.h \
|
||||
PhysicalDeliveryOrganizationName.h \
|
||||
ExtensionPhysicalDeliveryAddressComponents.h \
|
||||
UnformattedPostalAddress.h \
|
||||
StreetAddress.h \
|
||||
PostOfficeBoxAddress.h \
|
||||
PosteRestanteAddress.h \
|
||||
UniquePostalName.h \
|
||||
LocalPostalAttributes.h \
|
||||
PDSParameter.h \
|
||||
ExtendedNetworkAddress.h \
|
||||
PresentationAddress.h \
|
||||
TerminalType.h \
|
||||
TeletexDomainDefinedAttributes.h \
|
||||
TeletexDomainDefinedAttribute.h \
|
||||
AuthorityKeyIdentifier.h \
|
||||
KeyIdentifier.h \
|
||||
SubjectKeyIdentifier.h \
|
||||
KeyUsage.h \
|
||||
PrivateKeyUsagePeriod.h \
|
||||
CertificatePolicies.h \
|
||||
PolicyInformation.h \
|
||||
CertPolicyId.h \
|
||||
PolicyQualifierInfo.h \
|
||||
PolicyQualifierId.h \
|
||||
CPSuri.h \
|
||||
UserNotice.h \
|
||||
NoticeReference.h \
|
||||
DisplayText.h \
|
||||
PolicyMappings.h \
|
||||
SubjectAltName.h \
|
||||
GeneralNames.h \
|
||||
GeneralName.h \
|
||||
AnotherName.h \
|
||||
EDIPartyName.h \
|
||||
IssuerAltName.h \
|
||||
SubjectDirectoryAttributes.h \
|
||||
BasicConstraints.h \
|
||||
NameConstraints.h \
|
||||
GeneralSubtrees.h \
|
||||
GeneralSubtree.h \
|
||||
BaseDistance.h \
|
||||
PolicyConstraints.h \
|
||||
SkipCerts.h \
|
||||
CRLDistributionPoints.h \
|
||||
DistributionPoint.h \
|
||||
DistributionPointName.h \
|
||||
ReasonFlags.h \
|
||||
ExtKeyUsageSyntax.h \
|
||||
KeyPurposeId.h \
|
||||
InhibitAnyPolicy.h \
|
||||
FreshestCRL.h \
|
||||
AuthorityInfoAccessSyntax.h \
|
||||
AccessDescription.h \
|
||||
SubjectInfoAccessSyntax.h \
|
||||
CRLNumber.h \
|
||||
IssuingDistributionPoint.h \
|
||||
BaseCRLNumber.h \
|
||||
CRLReason.h \
|
||||
CertificateIssuer.h \
|
||||
HoldInstructionCode.h \
|
||||
InvalidityDate.h
|
||||
|
||||
ASN_MODULE_HEADERS+=ANY.h
|
||||
ASN_MODULE_SOURCES+=ANY.c
|
||||
ASN_MODULE_HEADERS+=BMPString.h
|
||||
ASN_MODULE_SOURCES+=BMPString.c
|
||||
ASN_MODULE_HEADERS+=UTF8String.h
|
||||
ASN_MODULE_HEADERS+=BOOLEAN.h
|
||||
ASN_MODULE_SOURCES+=BOOLEAN.c
|
||||
ASN_MODULE_HEADERS+=INTEGER.h
|
||||
ASN_MODULE_HEADERS+=NativeEnumerated.h
|
||||
ASN_MODULE_HEADERS+=GeneralizedTime.h
|
||||
ASN_MODULE_SOURCES+=GeneralizedTime.c
|
||||
ASN_MODULE_HEADERS+=IA5String.h
|
||||
ASN_MODULE_SOURCES+=IA5String.c
|
||||
ASN_MODULE_SOURCES+=INTEGER.c
|
||||
ASN_MODULE_SOURCES+=NativeEnumerated.c
|
||||
ASN_MODULE_HEADERS+=NativeInteger.h
|
||||
ASN_MODULE_SOURCES+=NativeInteger.c
|
||||
ASN_MODULE_HEADERS+=NumericString.h
|
||||
ASN_MODULE_SOURCES+=NumericString.c
|
||||
ASN_MODULE_HEADERS+=OBJECT_IDENTIFIER.h
|
||||
ASN_MODULE_SOURCES+=OBJECT_IDENTIFIER.c
|
||||
ASN_MODULE_HEADERS+=PrintableString.h
|
||||
ASN_MODULE_SOURCES+=PrintableString.c
|
||||
ASN_MODULE_HEADERS+=TeletexString.h
|
||||
ASN_MODULE_SOURCES+=TeletexString.c
|
||||
ASN_MODULE_HEADERS+=UTCTime.h
|
||||
ASN_MODULE_SOURCES+=UTCTime.c
|
||||
ASN_MODULE_SOURCES+=UTF8String.c
|
||||
ASN_MODULE_HEADERS+=UniversalString.h
|
||||
ASN_MODULE_SOURCES+=UniversalString.c
|
||||
ASN_MODULE_HEADERS+=VisibleString.h
|
||||
ASN_MODULE_SOURCES+=VisibleString.c
|
||||
ASN_MODULE_HEADERS+=asn_SEQUENCE_OF.h
|
||||
ASN_MODULE_SOURCES+=asn_SEQUENCE_OF.c
|
||||
ASN_MODULE_HEADERS+=asn_SET_OF.h
|
||||
ASN_MODULE_SOURCES+=asn_SET_OF.c
|
||||
ASN_MODULE_HEADERS+=constr_CHOICE.h
|
||||
ASN_MODULE_SOURCES+=constr_CHOICE.c
|
||||
ASN_MODULE_HEADERS+=constr_SEQUENCE.h
|
||||
ASN_MODULE_SOURCES+=constr_SEQUENCE.c
|
||||
ASN_MODULE_HEADERS+=constr_SEQUENCE_OF.h
|
||||
ASN_MODULE_SOURCES+=constr_SEQUENCE_OF.c
|
||||
ASN_MODULE_HEADERS+=constr_SET_OF.h
|
||||
ASN_MODULE_HEADERS+=constr_SET.h
|
||||
ASN_MODULE_SOURCES+=constr_SET.c
|
||||
ASN_MODULE_SOURCES+=constr_SET_OF.c
|
||||
ASN_MODULE_HEADERS+=asn_application.h
|
||||
ASN_MODULE_HEADERS+=asn_system.h
|
||||
ASN_MODULE_HEADERS+=asn_codecs.h
|
||||
ASN_MODULE_HEADERS+=asn_internal.h
|
||||
ASN_MODULE_HEADERS+=OCTET_STRING.h
|
||||
ASN_MODULE_SOURCES+=OCTET_STRING.c
|
||||
ASN_MODULE_HEADERS+=BIT_STRING.h
|
||||
ASN_MODULE_SOURCES+=BIT_STRING.c
|
||||
ASN_MODULE_SOURCES+=asn_codecs_prim.c
|
||||
ASN_MODULE_HEADERS+=asn_codecs_prim.h
|
||||
ASN_MODULE_HEADERS+=ber_tlv_length.h
|
||||
ASN_MODULE_SOURCES+=ber_tlv_length.c
|
||||
ASN_MODULE_HEADERS+=ber_tlv_tag.h
|
||||
ASN_MODULE_SOURCES+=ber_tlv_tag.c
|
||||
ASN_MODULE_HEADERS+=ber_decoder.h
|
||||
ASN_MODULE_SOURCES+=ber_decoder.c
|
||||
ASN_MODULE_HEADERS+=der_encoder.h
|
||||
ASN_MODULE_SOURCES+=der_encoder.c
|
||||
ASN_MODULE_HEADERS+=constr_TYPE.h
|
||||
ASN_MODULE_SOURCES+=constr_TYPE.c
|
||||
ASN_MODULE_HEADERS+=constraints.h
|
||||
ASN_MODULE_SOURCES+=constraints.c
|
||||
ASN_MODULE_HEADERS+=xer_support.h
|
||||
ASN_MODULE_SOURCES+=xer_support.c
|
||||
ASN_MODULE_HEADERS+=xer_decoder.h
|
||||
ASN_MODULE_SOURCES+=xer_decoder.c
|
||||
ASN_MODULE_HEADERS+=xer_encoder.h
|
||||
ASN_MODULE_SOURCES+=xer_encoder.c
|
||||
ASN_MODULE_HEADERS+=per_support.h
|
||||
ASN_MODULE_SOURCES+=per_support.c
|
||||
ASN_MODULE_HEADERS+=per_decoder.h
|
||||
ASN_MODULE_SOURCES+=per_decoder.c
|
||||
ASN_MODULE_HEADERS+=per_encoder.h
|
||||
ASN_MODULE_SOURCES+=per_encoder.c
|
||||
ASN_MODULE_HEADERS+=per_opentype.h
|
||||
ASN_MODULE_SOURCES+=per_opentype.c
|
||||
ASN_CONVERTER_SOURCES+=converter-sample.c
|
||||
|
||||
|
||||
lib_LTLIBRARIES=libsomething.la
|
||||
libsomething_la_SOURCES=$(ASN_MODULE_SOURCES) $(ASN_MODULE_HEADERS)
|
||||
|
||||
# This file may be used as an input for make(3)
|
||||
# Remove the lines below to convert it into a pure .am file
|
||||
TARGET = x509dump
|
||||
CFLAGS += -DHAVE_CONFIG_H -DJUNKTEST -DPDU=Certificate -I.
|
||||
OBJS=${ASN_MODULE_SOURCES:.c=.o} ${ASN_CONVERTER_SOURCES:.c=.o}
|
||||
|
||||
all: Certificate.c $(TARGET)
|
||||
|
||||
$(TARGET): ${OBJS}
|
||||
$(CC) $(CFLAGS) -o $(TARGET) ${OBJS} $(LDFLAGS) $(LIBS)
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .o
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) -o $@ -c $<
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET)
|
||||
rm -f $(OBJS)
|
||||
|
||||
regen: regenerate-from-asn1-source
|
||||
|
||||
regenerate-from-asn1-source:
|
||||
../../asn1c/asn1c -S ../../skeletons -pdu=Certificate ../rfc3280-PKIX1Explicit88.asn1 ../rfc3280-PKIX1Implicit88.asn1
|
||||
ASN_PROGRAM = x509dump
|
||||
CFLAGS += -DHAVE_CONFIG_H -DJUNKTEST -D_DEFAULT_SOURCE
|
||||
begin: Certificate.c maybe-wip-pause all
|
||||
|
||||
-include converter-example.mk
|
||||
|
||||
Certificate.c: ../sample.makefile.regen ../rfc3280-*.asn1
|
||||
make regen-makefile
|
||||
|
@ -375,76 +10,97 @@ Certificate.c: ../sample.makefile.regen ../rfc3280-*.asn1
|
|||
make
|
||||
|
||||
regen-makefile:
|
||||
ASN1CMDOPTS="" \
|
||||
ASN1MODULES="../rfc3280-*.asn1" \
|
||||
ASN1PDU=Certificate \
|
||||
PROGNAME=x509dump \
|
||||
ASN_CMDOPTS="-fcompound-names -fwide-types" \
|
||||
ASN_MODULES="../rfc3280-*.asn1" \
|
||||
ASN_PDU=Certificate \
|
||||
ASN_PROGRAM=x509dump \
|
||||
../sample.makefile.regen
|
||||
|
||||
check: ${TARGET} check-ber check-xer check-per
|
||||
check: ${ASN_PROGRAM} check-ber check-xer check-oer check-per
|
||||
@echo ================
|
||||
@echo All tests passed
|
||||
@echo ================
|
||||
|
||||
check-ber:
|
||||
@if test -f sample-Certificate-1.[db]er ; then \
|
||||
for f in sample-Certificate-*.[db]er; do \
|
||||
for f in sample-*-*.[db]er; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f into XER and back ($$b)..."; \
|
||||
./${TARGET} -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${TARGET} -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 4; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -iber -onull $$f || exit 5; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -iber -onull $$f || exit 6; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 5; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 6; \
|
||||
done; done; fi
|
||||
|
||||
check-xer:
|
||||
@if test -f sample-Certificate-1.xer ; then \
|
||||
for f in sample-Certificate-*.xer; do \
|
||||
for f in sample-*-*.xer; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f into DER and back ($$b)..."; \
|
||||
./${TARGET} -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
echo "Recoding $$f ($$pdu) into DER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
diff $$f ./.tmp.2.$$$$ || exit 4; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -ixer -onull $$f || exit 5; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -ixer -onull $$f || exit 6; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 5; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 6; \
|
||||
done; done; fi
|
||||
|
||||
check-oer:
|
||||
@if test -f sample-Certificate-1.*oer ; then \
|
||||
for f in sample-*-*.*oer; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ioer -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -ooer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
diff $$f ./.tmp.2.$$$$ || exit 4; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait) ($$b) ..."; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 5; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 6; \
|
||||
done; done; fi
|
||||
|
||||
check-per:
|
||||
@if test -f sample-Certificate-1-nopad.per ; then \
|
||||
for f in sample-Certificate-[1-9]-nopad.per; do \
|
||||
for f in sample-*-[1-9]-nopad.per; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding non-padded $$f into DER into XER and back ($$b)..."; \
|
||||
./${TARGET} -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
./${TARGET} -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \
|
||||
echo "Recoding non-padded $$f ($$pdu) into DER into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \
|
||||
diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 5; \
|
||||
rm -f ./.tmp.[123].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -per-nopad -iper -onull $$f || exit 6; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -per-nopad -iper -onull $$f || exit 7; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 6; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 7; \
|
||||
done; done; fi
|
||||
@if test -f sample-Certificate-1.per ; then \
|
||||
for f in sample-*-[1-9].per; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z-]+)-[0-9].*/\1/"`; \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f into DER into XER and back ($$b)..."; \
|
||||
./${TARGET} -b $$b -p $$pdu -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \
|
||||
./${TARGET} -b $$b -p $$pdu -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \
|
||||
./${TARGET} -b $$b -p $$pdu -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \
|
||||
echo "Recoding $$f ($$pdu) into DER into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \
|
||||
diff $$f ./.tmp.1.$$$$ || exit 6; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -iper -onull $$f || exit 7; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -iper -onull $$f || exit 8; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 7; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 8; \
|
||||
done; done; fi
|
||||
|
||||
maybe-wip-pause:
|
||||
@if [ -f WIP ]; then cat WIP; sleep 2; fi
|
||||
|
||||
distclean: clean
|
||||
rm -f $(ASN_MODULE_SOURCES)
|
||||
rm -f $(ASN_MODULE_HEADERS)
|
||||
rm -f $(ASN_CONVERTER_SOURCES) $(ASN_CONVERTER_HEADERS)
|
||||
rm -f Makefile.am.sample
|
||||
rm -f $(ASN_MODULE_SRCS)
|
||||
rm -f $(ASN_MODULE_HDRS)
|
||||
rm -f $(ASN_PROGRAM_SRCS) $(ASN_PROGRAM_HDRS)
|
||||
rm -f converter-example.mk
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,709 +1,8 @@
|
|||
ASN_MODULE_SOURCES= \
|
||||
DataInterChange.c \
|
||||
TransferBatch.c \
|
||||
Notification.c \
|
||||
CallEventDetailList.c \
|
||||
CallEventDetail.c \
|
||||
BatchControlInfo.c \
|
||||
AccountingInfo.c \
|
||||
NetworkInfo.c \
|
||||
MessageDescriptionInfoList.c \
|
||||
MobileOriginatedCall.c \
|
||||
MobileTerminatedCall.c \
|
||||
SupplServiceEvent.c \
|
||||
ServiceCentreUsage.c \
|
||||
GprsCall.c \
|
||||
ContentTransaction.c \
|
||||
LocationService.c \
|
||||
AuditControlInfo.c \
|
||||
AccessPointNameNI.c \
|
||||
AccessPointNameOI.c \
|
||||
ActualDeliveryTimeStamp.c \
|
||||
AddressStringDigits.c \
|
||||
AdvisedCharge.c \
|
||||
AdvisedChargeCurrency.c \
|
||||
AdvisedChargeInformation.c \
|
||||
AgeOfLocation.c \
|
||||
BasicService.c \
|
||||
BasicServiceCode.c \
|
||||
BasicServiceCodeList.c \
|
||||
BasicServiceUsed.c \
|
||||
BasicServiceUsedList.c \
|
||||
BearerServiceCode.c \
|
||||
CalledNumber.c \
|
||||
CalledPlace.c \
|
||||
CalledRegion.c \
|
||||
CallEventDetailsCount.c \
|
||||
CallEventStartTimeStamp.c \
|
||||
CallingNumber.c \
|
||||
CallOriginator.c \
|
||||
CallReference.c \
|
||||
CallTypeGroup.c \
|
||||
CallTypeLevel1.c \
|
||||
CallTypeLevel2.c \
|
||||
CallTypeLevel3.c \
|
||||
CamelDestinationNumber.c \
|
||||
CamelInvocationFee.c \
|
||||
CamelServiceKey.c \
|
||||
CamelServiceLevel.c \
|
||||
CamelServiceUsed.c \
|
||||
CauseForTerm.c \
|
||||
CellId.c \
|
||||
Charge.c \
|
||||
ChargeableSubscriber.c \
|
||||
ChargeableUnits.c \
|
||||
ChargeDetail.c \
|
||||
ChargeDetailList.c \
|
||||
ChargeDetailTimeStamp.c \
|
||||
ChargedItem.c \
|
||||
ChargedPartyEquipment.c \
|
||||
ChargedPartyHomeIdentification.c \
|
||||
ChargedPartyHomeIdList.c \
|
||||
ChargedPartyIdentification.c \
|
||||
ChargedPartyIdentifier.c \
|
||||
ChargedPartyIdList.c \
|
||||
ChargedPartyIdType.c \
|
||||
ChargedPartyInformation.c \
|
||||
ChargedPartyLocation.c \
|
||||
ChargedPartyLocationList.c \
|
||||
ChargedPartyStatus.c \
|
||||
ChargedUnits.c \
|
||||
ChargeInformation.c \
|
||||
ChargeInformationList.c \
|
||||
ChargeRefundIndicator.c \
|
||||
ChargeType.c \
|
||||
ChargingId.c \
|
||||
ChargingPoint.c \
|
||||
ChargingTimeStamp.c \
|
||||
ClirIndicator.c \
|
||||
Commission.c \
|
||||
CompletionTimeStamp.c \
|
||||
ContentChargingPoint.c \
|
||||
ContentProvider.c \
|
||||
ContentProviderIdentifier.c \
|
||||
ContentProviderIdList.c \
|
||||
ContentProviderIdType.c \
|
||||
ContentProviderName.c \
|
||||
ContentServiceUsed.c \
|
||||
ContentServiceUsedList.c \
|
||||
ContentTransactionBasicInfo.c \
|
||||
ContentTransactionCode.c \
|
||||
ContentTransactionType.c \
|
||||
CseInformation.c \
|
||||
CurrencyConversion.c \
|
||||
CurrencyConversionList.c \
|
||||
CustomerIdentifier.c \
|
||||
CustomerIdType.c \
|
||||
DataVolume.c \
|
||||
DataVolumeIncoming.c \
|
||||
DataVolumeOutgoing.c \
|
||||
DateTime.c \
|
||||
DateTimeLong.c \
|
||||
DefaultCallHandlingIndicator.c \
|
||||
DepositTimeStamp.c \
|
||||
Destination.c \
|
||||
DestinationNetwork.c \
|
||||
DialledDigits.c \
|
||||
Discount.c \
|
||||
DiscountableAmount.c \
|
||||
DiscountApplied.c \
|
||||
DiscountCode.c \
|
||||
DiscountInformation.c \
|
||||
Discounting.c \
|
||||
DiscountingList.c \
|
||||
DiscountRate.c \
|
||||
DiscountValue.c \
|
||||
DistanceChargeBandCode.c \
|
||||
EarliestCallTimeStamp.c \
|
||||
EquipmentId.c \
|
||||
EquipmentIdType.c \
|
||||
Esn.c \
|
||||
ExchangeRate.c \
|
||||
ExchangeRateCode.c \
|
||||
FileAvailableTimeStamp.c \
|
||||
FileCreationTimeStamp.c \
|
||||
FileSequenceNumber.c \
|
||||
FileTypeIndicator.c \
|
||||
FixedDiscountValue.c \
|
||||
Fnur.c \
|
||||
GeographicalLocation.c \
|
||||
GprsBasicCallInformation.c \
|
||||
GprsChargeableSubscriber.c \
|
||||
GprsDestination.c \
|
||||
GprsLocationInformation.c \
|
||||
GprsNetworkLocation.c \
|
||||
GprsServiceUsed.c \
|
||||
GsmChargeableSubscriber.c \
|
||||
GuaranteedBitRate.c \
|
||||
HomeBid.c \
|
||||
HomeIdentifier.c \
|
||||
HomeIdType.c \
|
||||
HomeLocationDescription.c \
|
||||
HomeLocationInformation.c \
|
||||
HorizontalAccuracyDelivered.c \
|
||||
HorizontalAccuracyRequested.c \
|
||||
HSCSDIndicator.c \
|
||||
Imei.c \
|
||||
ImeiOrEsn.c \
|
||||
Imsi.c \
|
||||
IMSSignallingContext.c \
|
||||
InternetServiceProvider.c \
|
||||
InternetServiceProviderIdList.c \
|
||||
IspIdentifier.c \
|
||||
IspIdType.c \
|
||||
ISPList.c \
|
||||
NetworkIdType.c \
|
||||
NetworkIdentifier.c \
|
||||
Network.c \
|
||||
NetworkList.c \
|
||||
LatestCallTimeStamp.c \
|
||||
LCSQosDelivered.c \
|
||||
LCSQosRequested.c \
|
||||
LCSRequestTimestamp.c \
|
||||
LCSSPIdentification.c \
|
||||
LCSSPIdentificationList.c \
|
||||
LCSSPInformation.c \
|
||||
LCSTransactionStatus.c \
|
||||
LocalCurrency.c \
|
||||
LocalTimeStamp.c \
|
||||
LocationArea.c \
|
||||
LocationDescription.c \
|
||||
LocationIdentifier.c \
|
||||
LocationIdType.c \
|
||||
LocationInformation.c \
|
||||
LocationServiceUsage.c \
|
||||
MaximumBitRate.c \
|
||||
Mdn.c \
|
||||
MessageDescription.c \
|
||||
MessageDescriptionCode.c \
|
||||
MessageDescriptionInformation.c \
|
||||
MessageStatus.c \
|
||||
MessageType.c \
|
||||
Min.c \
|
||||
MinChargeableSubscriber.c \
|
||||
MoBasicCallInformation.c \
|
||||
Msisdn.c \
|
||||
MtBasicCallInformation.c \
|
||||
NetworkAccessIdentifier.c \
|
||||
NetworkId.c \
|
||||
NetworkInitPDPContext.c \
|
||||
NetworkLocation.c \
|
||||
NonChargedNumber.c \
|
||||
NumberOfDecimalPlaces.c \
|
||||
ObjectType.c \
|
||||
OperatorSpecInfoList.c \
|
||||
OperatorSpecInformation.c \
|
||||
OrderPlacedTimeStamp.c \
|
||||
OriginatingNetwork.c \
|
||||
PacketDataProtocolAddress.c \
|
||||
PaidIndicator.c \
|
||||
PartialTypeIndicator.c \
|
||||
PaymentMethod.c \
|
||||
PdpAddress.c \
|
||||
PDPContextStartTimestamp.c \
|
||||
PlmnId.c \
|
||||
PositioningMethod.c \
|
||||
PriorityCode.c \
|
||||
RapFileSequenceNumber.c \
|
||||
RecEntityCode.c \
|
||||
RecEntityCodeList.c \
|
||||
RecEntityId.c \
|
||||
RecEntityInfoList.c \
|
||||
RecEntityInformation.c \
|
||||
RecEntityType.c \
|
||||
Recipient.c \
|
||||
ReleaseVersionNumber.c \
|
||||
RequestedDeliveryTimeStamp.c \
|
||||
ResponseTime.c \
|
||||
ResponseTimeCategory.c \
|
||||
ScuBasicInformation.c \
|
||||
ScuChargeType.c \
|
||||
ScuTimeStamps.c \
|
||||
ScuChargeableSubscriber.c \
|
||||
Sender.c \
|
||||
ServingBid.c \
|
||||
ServingLocationDescription.c \
|
||||
ServingNetwork.c \
|
||||
ServingPartiesInformation.c \
|
||||
SimChargeableSubscriber.c \
|
||||
SimToolkitIndicator.c \
|
||||
SMSDestinationNumber.c \
|
||||
SMSOriginator.c \
|
||||
SpecificationVersionNumber.c \
|
||||
SsParameters.c \
|
||||
SupplServiceActionCode.c \
|
||||
SupplServiceCode.c \
|
||||
SupplServiceUsed.c \
|
||||
TapCurrency.c \
|
||||
TapDecimalPlaces.c \
|
||||
TaxableAmount.c \
|
||||
Taxation.c \
|
||||
TaxationList.c \
|
||||
TaxCode.c \
|
||||
TaxInformation.c \
|
||||
TaxInformationList.c \
|
||||
TaxRate.c \
|
||||
TaxType.c \
|
||||
TaxValue.c \
|
||||
TeleServiceCode.c \
|
||||
ThirdPartyInformation.c \
|
||||
ThirdPartyNumber.c \
|
||||
ThreeGcamelDestination.c \
|
||||
TotalAdvisedCharge.c \
|
||||
TotalAdvisedChargeRefund.c \
|
||||
TotalAdvisedChargeValue.c \
|
||||
TotalAdvisedChargeValueList.c \
|
||||
TotalCallEventDuration.c \
|
||||
TotalCharge.c \
|
||||
TotalChargeRefund.c \
|
||||
TotalCommission.c \
|
||||
TotalCommissionRefund.c \
|
||||
TotalDataVolume.c \
|
||||
TotalDiscountRefund.c \
|
||||
TotalDiscountValue.c \
|
||||
TotalTaxRefund.c \
|
||||
TotalTaxValue.c \
|
||||
TotalTransactionDuration.c \
|
||||
TrackedCustomerEquipment.c \
|
||||
TrackedCustomerHomeId.c \
|
||||
TrackedCustomerHomeIdList.c \
|
||||
TrackedCustomerIdentification.c \
|
||||
TrackedCustomerIdList.c \
|
||||
TrackedCustomerInformation.c \
|
||||
TrackedCustomerLocation.c \
|
||||
TrackedCustomerLocList.c \
|
||||
TrackingCustomerEquipment.c \
|
||||
TrackingCustomerHomeId.c \
|
||||
TrackingCustomerHomeIdList.c \
|
||||
TrackingCustomerIdentification.c \
|
||||
TrackingCustomerIdList.c \
|
||||
TrackingCustomerInformation.c \
|
||||
TrackingCustomerLocation.c \
|
||||
TrackingCustomerLocList.c \
|
||||
TrackingFrequency.c \
|
||||
TrackingPeriod.c \
|
||||
TransactionAuthCode.c \
|
||||
TransactionDescriptionSupp.c \
|
||||
TransactionDetailDescription.c \
|
||||
TransactionIdentifier.c \
|
||||
TransactionShortDescription.c \
|
||||
TransactionStatus.c \
|
||||
TransferCutOffTimeStamp.c \
|
||||
TransparencyIndicator.c \
|
||||
UserProtocolIndicator.c \
|
||||
UtcTimeOffset.c \
|
||||
UtcTimeOffsetCode.c \
|
||||
UtcTimeOffsetInfo.c \
|
||||
UtcTimeOffsetInfoList.c \
|
||||
VerticalAccuracyDelivered.c \
|
||||
VerticalAccuracyRequested.c \
|
||||
AbsoluteAmount.c \
|
||||
Bid.c \
|
||||
Code.c \
|
||||
AsciiString.c \
|
||||
BCDString.c \
|
||||
Currency.c \
|
||||
HexString.c \
|
||||
NumberString.c \
|
||||
PercentageRate.c
|
||||
|
||||
ASN_MODULE_HEADERS= \
|
||||
DataInterChange.h \
|
||||
TransferBatch.h \
|
||||
Notification.h \
|
||||
CallEventDetailList.h \
|
||||
CallEventDetail.h \
|
||||
BatchControlInfo.h \
|
||||
AccountingInfo.h \
|
||||
NetworkInfo.h \
|
||||
MessageDescriptionInfoList.h \
|
||||
MobileOriginatedCall.h \
|
||||
MobileTerminatedCall.h \
|
||||
SupplServiceEvent.h \
|
||||
ServiceCentreUsage.h \
|
||||
GprsCall.h \
|
||||
ContentTransaction.h \
|
||||
LocationService.h \
|
||||
AuditControlInfo.h \
|
||||
AccessPointNameNI.h \
|
||||
AccessPointNameOI.h \
|
||||
ActualDeliveryTimeStamp.h \
|
||||
AddressStringDigits.h \
|
||||
AdvisedCharge.h \
|
||||
AdvisedChargeCurrency.h \
|
||||
AdvisedChargeInformation.h \
|
||||
AgeOfLocation.h \
|
||||
BasicService.h \
|
||||
BasicServiceCode.h \
|
||||
BasicServiceCodeList.h \
|
||||
BasicServiceUsed.h \
|
||||
BasicServiceUsedList.h \
|
||||
BearerServiceCode.h \
|
||||
CalledNumber.h \
|
||||
CalledPlace.h \
|
||||
CalledRegion.h \
|
||||
CallEventDetailsCount.h \
|
||||
CallEventStartTimeStamp.h \
|
||||
CallingNumber.h \
|
||||
CallOriginator.h \
|
||||
CallReference.h \
|
||||
CallTypeGroup.h \
|
||||
CallTypeLevel1.h \
|
||||
CallTypeLevel2.h \
|
||||
CallTypeLevel3.h \
|
||||
CamelDestinationNumber.h \
|
||||
CamelInvocationFee.h \
|
||||
CamelServiceKey.h \
|
||||
CamelServiceLevel.h \
|
||||
CamelServiceUsed.h \
|
||||
CauseForTerm.h \
|
||||
CellId.h \
|
||||
Charge.h \
|
||||
ChargeableSubscriber.h \
|
||||
ChargeableUnits.h \
|
||||
ChargeDetail.h \
|
||||
ChargeDetailList.h \
|
||||
ChargeDetailTimeStamp.h \
|
||||
ChargedItem.h \
|
||||
ChargedPartyEquipment.h \
|
||||
ChargedPartyHomeIdentification.h \
|
||||
ChargedPartyHomeIdList.h \
|
||||
ChargedPartyIdentification.h \
|
||||
ChargedPartyIdentifier.h \
|
||||
ChargedPartyIdList.h \
|
||||
ChargedPartyIdType.h \
|
||||
ChargedPartyInformation.h \
|
||||
ChargedPartyLocation.h \
|
||||
ChargedPartyLocationList.h \
|
||||
ChargedPartyStatus.h \
|
||||
ChargedUnits.h \
|
||||
ChargeInformation.h \
|
||||
ChargeInformationList.h \
|
||||
ChargeRefundIndicator.h \
|
||||
ChargeType.h \
|
||||
ChargingId.h \
|
||||
ChargingPoint.h \
|
||||
ChargingTimeStamp.h \
|
||||
ClirIndicator.h \
|
||||
Commission.h \
|
||||
CompletionTimeStamp.h \
|
||||
ContentChargingPoint.h \
|
||||
ContentProvider.h \
|
||||
ContentProviderIdentifier.h \
|
||||
ContentProviderIdList.h \
|
||||
ContentProviderIdType.h \
|
||||
ContentProviderName.h \
|
||||
ContentServiceUsed.h \
|
||||
ContentServiceUsedList.h \
|
||||
ContentTransactionBasicInfo.h \
|
||||
ContentTransactionCode.h \
|
||||
ContentTransactionType.h \
|
||||
CseInformation.h \
|
||||
CurrencyConversion.h \
|
||||
CurrencyConversionList.h \
|
||||
CustomerIdentifier.h \
|
||||
CustomerIdType.h \
|
||||
DataVolume.h \
|
||||
DataVolumeIncoming.h \
|
||||
DataVolumeOutgoing.h \
|
||||
DateTime.h \
|
||||
DateTimeLong.h \
|
||||
DefaultCallHandlingIndicator.h \
|
||||
DepositTimeStamp.h \
|
||||
Destination.h \
|
||||
DestinationNetwork.h \
|
||||
DialledDigits.h \
|
||||
Discount.h \
|
||||
DiscountableAmount.h \
|
||||
DiscountApplied.h \
|
||||
DiscountCode.h \
|
||||
DiscountInformation.h \
|
||||
Discounting.h \
|
||||
DiscountingList.h \
|
||||
DiscountRate.h \
|
||||
DiscountValue.h \
|
||||
DistanceChargeBandCode.h \
|
||||
EarliestCallTimeStamp.h \
|
||||
EquipmentId.h \
|
||||
EquipmentIdType.h \
|
||||
Esn.h \
|
||||
ExchangeRate.h \
|
||||
ExchangeRateCode.h \
|
||||
FileAvailableTimeStamp.h \
|
||||
FileCreationTimeStamp.h \
|
||||
FileSequenceNumber.h \
|
||||
FileTypeIndicator.h \
|
||||
FixedDiscountValue.h \
|
||||
Fnur.h \
|
||||
GeographicalLocation.h \
|
||||
GprsBasicCallInformation.h \
|
||||
GprsChargeableSubscriber.h \
|
||||
GprsDestination.h \
|
||||
GprsLocationInformation.h \
|
||||
GprsNetworkLocation.h \
|
||||
GprsServiceUsed.h \
|
||||
GsmChargeableSubscriber.h \
|
||||
GuaranteedBitRate.h \
|
||||
HomeBid.h \
|
||||
HomeIdentifier.h \
|
||||
HomeIdType.h \
|
||||
HomeLocationDescription.h \
|
||||
HomeLocationInformation.h \
|
||||
HorizontalAccuracyDelivered.h \
|
||||
HorizontalAccuracyRequested.h \
|
||||
HSCSDIndicator.h \
|
||||
Imei.h \
|
||||
ImeiOrEsn.h \
|
||||
Imsi.h \
|
||||
IMSSignallingContext.h \
|
||||
InternetServiceProvider.h \
|
||||
InternetServiceProviderIdList.h \
|
||||
IspIdentifier.h \
|
||||
IspIdType.h \
|
||||
ISPList.h \
|
||||
NetworkIdType.h \
|
||||
NetworkIdentifier.h \
|
||||
Network.h \
|
||||
NetworkList.h \
|
||||
LatestCallTimeStamp.h \
|
||||
LCSQosDelivered.h \
|
||||
LCSQosRequested.h \
|
||||
LCSRequestTimestamp.h \
|
||||
LCSSPIdentification.h \
|
||||
LCSSPIdentificationList.h \
|
||||
LCSSPInformation.h \
|
||||
LCSTransactionStatus.h \
|
||||
LocalCurrency.h \
|
||||
LocalTimeStamp.h \
|
||||
LocationArea.h \
|
||||
LocationDescription.h \
|
||||
LocationIdentifier.h \
|
||||
LocationIdType.h \
|
||||
LocationInformation.h \
|
||||
LocationServiceUsage.h \
|
||||
MaximumBitRate.h \
|
||||
Mdn.h \
|
||||
MessageDescription.h \
|
||||
MessageDescriptionCode.h \
|
||||
MessageDescriptionInformation.h \
|
||||
MessageStatus.h \
|
||||
MessageType.h \
|
||||
Min.h \
|
||||
MinChargeableSubscriber.h \
|
||||
MoBasicCallInformation.h \
|
||||
Msisdn.h \
|
||||
MtBasicCallInformation.h \
|
||||
NetworkAccessIdentifier.h \
|
||||
NetworkId.h \
|
||||
NetworkInitPDPContext.h \
|
||||
NetworkLocation.h \
|
||||
NonChargedNumber.h \
|
||||
NumberOfDecimalPlaces.h \
|
||||
ObjectType.h \
|
||||
OperatorSpecInfoList.h \
|
||||
OperatorSpecInformation.h \
|
||||
OrderPlacedTimeStamp.h \
|
||||
OriginatingNetwork.h \
|
||||
PacketDataProtocolAddress.h \
|
||||
PaidIndicator.h \
|
||||
PartialTypeIndicator.h \
|
||||
PaymentMethod.h \
|
||||
PdpAddress.h \
|
||||
PDPContextStartTimestamp.h \
|
||||
PlmnId.h \
|
||||
PositioningMethod.h \
|
||||
PriorityCode.h \
|
||||
RapFileSequenceNumber.h \
|
||||
RecEntityCode.h \
|
||||
RecEntityCodeList.h \
|
||||
RecEntityId.h \
|
||||
RecEntityInfoList.h \
|
||||
RecEntityInformation.h \
|
||||
RecEntityType.h \
|
||||
Recipient.h \
|
||||
ReleaseVersionNumber.h \
|
||||
RequestedDeliveryTimeStamp.h \
|
||||
ResponseTime.h \
|
||||
ResponseTimeCategory.h \
|
||||
ScuBasicInformation.h \
|
||||
ScuChargeType.h \
|
||||
ScuTimeStamps.h \
|
||||
ScuChargeableSubscriber.h \
|
||||
Sender.h \
|
||||
ServingBid.h \
|
||||
ServingLocationDescription.h \
|
||||
ServingNetwork.h \
|
||||
ServingPartiesInformation.h \
|
||||
SimChargeableSubscriber.h \
|
||||
SimToolkitIndicator.h \
|
||||
SMSDestinationNumber.h \
|
||||
SMSOriginator.h \
|
||||
SpecificationVersionNumber.h \
|
||||
SsParameters.h \
|
||||
SupplServiceActionCode.h \
|
||||
SupplServiceCode.h \
|
||||
SupplServiceUsed.h \
|
||||
TapCurrency.h \
|
||||
TapDecimalPlaces.h \
|
||||
TaxableAmount.h \
|
||||
Taxation.h \
|
||||
TaxationList.h \
|
||||
TaxCode.h \
|
||||
TaxInformation.h \
|
||||
TaxInformationList.h \
|
||||
TaxRate.h \
|
||||
TaxType.h \
|
||||
TaxValue.h \
|
||||
TeleServiceCode.h \
|
||||
ThirdPartyInformation.h \
|
||||
ThirdPartyNumber.h \
|
||||
ThreeGcamelDestination.h \
|
||||
TotalAdvisedCharge.h \
|
||||
TotalAdvisedChargeRefund.h \
|
||||
TotalAdvisedChargeValue.h \
|
||||
TotalAdvisedChargeValueList.h \
|
||||
TotalCallEventDuration.h \
|
||||
TotalCharge.h \
|
||||
TotalChargeRefund.h \
|
||||
TotalCommission.h \
|
||||
TotalCommissionRefund.h \
|
||||
TotalDataVolume.h \
|
||||
TotalDiscountRefund.h \
|
||||
TotalDiscountValue.h \
|
||||
TotalTaxRefund.h \
|
||||
TotalTaxValue.h \
|
||||
TotalTransactionDuration.h \
|
||||
TrackedCustomerEquipment.h \
|
||||
TrackedCustomerHomeId.h \
|
||||
TrackedCustomerHomeIdList.h \
|
||||
TrackedCustomerIdentification.h \
|
||||
TrackedCustomerIdList.h \
|
||||
TrackedCustomerInformation.h \
|
||||
TrackedCustomerLocation.h \
|
||||
TrackedCustomerLocList.h \
|
||||
TrackingCustomerEquipment.h \
|
||||
TrackingCustomerHomeId.h \
|
||||
TrackingCustomerHomeIdList.h \
|
||||
TrackingCustomerIdentification.h \
|
||||
TrackingCustomerIdList.h \
|
||||
TrackingCustomerInformation.h \
|
||||
TrackingCustomerLocation.h \
|
||||
TrackingCustomerLocList.h \
|
||||
TrackingFrequency.h \
|
||||
TrackingPeriod.h \
|
||||
TransactionAuthCode.h \
|
||||
TransactionDescriptionSupp.h \
|
||||
TransactionDetailDescription.h \
|
||||
TransactionIdentifier.h \
|
||||
TransactionShortDescription.h \
|
||||
TransactionStatus.h \
|
||||
TransferCutOffTimeStamp.h \
|
||||
TransparencyIndicator.h \
|
||||
UserProtocolIndicator.h \
|
||||
UtcTimeOffset.h \
|
||||
UtcTimeOffsetCode.h \
|
||||
UtcTimeOffsetInfo.h \
|
||||
UtcTimeOffsetInfoList.h \
|
||||
VerticalAccuracyDelivered.h \
|
||||
VerticalAccuracyRequested.h \
|
||||
AbsoluteAmount.h \
|
||||
Bid.h \
|
||||
Code.h \
|
||||
AsciiString.h \
|
||||
BCDString.h \
|
||||
Currency.h \
|
||||
HexString.h \
|
||||
NumberString.h \
|
||||
PercentageRate.h
|
||||
|
||||
ASN_MODULE_HEADERS+=INTEGER.h
|
||||
ASN_MODULE_HEADERS+=NativeEnumerated.h
|
||||
ASN_MODULE_HEADERS+=IA5String.h
|
||||
ASN_MODULE_SOURCES+=IA5String.c
|
||||
ASN_MODULE_SOURCES+=INTEGER.c
|
||||
ASN_MODULE_SOURCES+=NativeEnumerated.c
|
||||
ASN_MODULE_HEADERS+=NativeInteger.h
|
||||
ASN_MODULE_SOURCES+=NativeInteger.c
|
||||
ASN_MODULE_HEADERS+=asn_SEQUENCE_OF.h
|
||||
ASN_MODULE_SOURCES+=asn_SEQUENCE_OF.c
|
||||
ASN_MODULE_HEADERS+=asn_SET_OF.h
|
||||
ASN_MODULE_SOURCES+=asn_SET_OF.c
|
||||
ASN_MODULE_HEADERS+=constr_CHOICE.h
|
||||
ASN_MODULE_SOURCES+=constr_CHOICE.c
|
||||
ASN_MODULE_HEADERS+=constr_SEQUENCE.h
|
||||
ASN_MODULE_SOURCES+=constr_SEQUENCE.c
|
||||
ASN_MODULE_HEADERS+=constr_SEQUENCE_OF.h
|
||||
ASN_MODULE_SOURCES+=constr_SEQUENCE_OF.c
|
||||
ASN_MODULE_HEADERS+=constr_SET_OF.h
|
||||
ASN_MODULE_SOURCES+=constr_SET_OF.c
|
||||
ASN_MODULE_HEADERS+=asn_application.h
|
||||
ASN_MODULE_HEADERS+=asn_system.h
|
||||
ASN_MODULE_HEADERS+=asn_codecs.h
|
||||
ASN_MODULE_HEADERS+=asn_internal.h
|
||||
ASN_MODULE_HEADERS+=OCTET_STRING.h
|
||||
ASN_MODULE_SOURCES+=OCTET_STRING.c
|
||||
ASN_MODULE_HEADERS+=BIT_STRING.h
|
||||
ASN_MODULE_SOURCES+=BIT_STRING.c
|
||||
ASN_MODULE_SOURCES+=asn_codecs_prim.c
|
||||
ASN_MODULE_HEADERS+=asn_codecs_prim.h
|
||||
ASN_MODULE_HEADERS+=ber_tlv_length.h
|
||||
ASN_MODULE_SOURCES+=ber_tlv_length.c
|
||||
ASN_MODULE_HEADERS+=ber_tlv_tag.h
|
||||
ASN_MODULE_SOURCES+=ber_tlv_tag.c
|
||||
ASN_MODULE_HEADERS+=ber_decoder.h
|
||||
ASN_MODULE_SOURCES+=ber_decoder.c
|
||||
ASN_MODULE_HEADERS+=der_encoder.h
|
||||
ASN_MODULE_SOURCES+=der_encoder.c
|
||||
ASN_MODULE_HEADERS+=constr_TYPE.h
|
||||
ASN_MODULE_SOURCES+=constr_TYPE.c
|
||||
ASN_MODULE_HEADERS+=constraints.h
|
||||
ASN_MODULE_SOURCES+=constraints.c
|
||||
ASN_MODULE_HEADERS+=xer_support.h
|
||||
ASN_MODULE_SOURCES+=xer_support.c
|
||||
ASN_MODULE_HEADERS+=xer_decoder.h
|
||||
ASN_MODULE_SOURCES+=xer_decoder.c
|
||||
ASN_MODULE_HEADERS+=xer_encoder.h
|
||||
ASN_MODULE_SOURCES+=xer_encoder.c
|
||||
ASN_MODULE_HEADERS+=per_support.h
|
||||
ASN_MODULE_SOURCES+=per_support.c
|
||||
ASN_MODULE_HEADERS+=per_decoder.h
|
||||
ASN_MODULE_SOURCES+=per_decoder.c
|
||||
ASN_MODULE_HEADERS+=per_encoder.h
|
||||
ASN_MODULE_SOURCES+=per_encoder.c
|
||||
ASN_MODULE_HEADERS+=per_opentype.h
|
||||
ASN_MODULE_SOURCES+=per_opentype.c
|
||||
ASN_CONVERTER_SOURCES+=converter-sample.c
|
||||
|
||||
|
||||
lib_LTLIBRARIES=libsomething.la
|
||||
libsomething_la_SOURCES=$(ASN_MODULE_SOURCES) $(ASN_MODULE_HEADERS)
|
||||
|
||||
# This file may be used as an input for make(3)
|
||||
# Remove the lines below to convert it into a pure .am file
|
||||
TARGET = tap3dump
|
||||
CFLAGS += -DASN_CONVERTER_TITLE="GSM TAP3 (Transferred Account Procedure, Version 3) decoder" -DHAVE_CONFIG_H -DJUNKTEST -DPDU=DataInterChange -I.
|
||||
OBJS=${ASN_MODULE_SOURCES:.c=.o} ${ASN_CONVERTER_SOURCES:.c=.o}
|
||||
|
||||
all: DataInterChange.c $(TARGET)
|
||||
|
||||
$(TARGET): ${OBJS}
|
||||
$(CC) $(CFLAGS) -o $(TARGET) ${OBJS} $(LDFLAGS) $(LIBS)
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .o
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) -o $@ -c $<
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET)
|
||||
rm -f $(OBJS)
|
||||
|
||||
regen: regenerate-from-asn1-source
|
||||
|
||||
regenerate-from-asn1-source:
|
||||
../../asn1c/asn1c -S ../../skeletons -pdu=DataInterChange ../tap3.asn1
|
||||
ASN_PROGRAM = tap3dump
|
||||
CFLAGS += -DASN_CONVERTER_TITLE="GSM TAP3 (Transferred Account Procedure, Version 3) decoder" -DHAVE_CONFIG_H -DJUNKTEST -D_DEFAULT_SOURCE
|
||||
begin: DataInterChange.c maybe-wip-pause all
|
||||
|
||||
-include converter-example.mk
|
||||
|
||||
DataInterChange.c: ../sample.makefile.regen ../tap3.asn1
|
||||
make regen-makefile
|
||||
|
@ -712,76 +11,97 @@ DataInterChange.c: ../sample.makefile.regen ../tap3.asn1
|
|||
|
||||
regen-makefile:
|
||||
TITLE="GSM TAP3 (Transferred Account Procedure, Version 3) decoder" \
|
||||
ASN1CMDOPTS="" \
|
||||
ASN1MODULES="../tap3.asn1" \
|
||||
ASN1PDU=DataInterChange \
|
||||
PROGNAME=tap3dump \
|
||||
ASN_CMDOPTS="" \
|
||||
ASN_MODULES="../tap3.asn1" \
|
||||
ASN_PDU=DataInterChange \
|
||||
ASN_PROGRAM=tap3dump \
|
||||
../sample.makefile.regen
|
||||
|
||||
check: ${TARGET} check-ber check-xer check-per
|
||||
check: ${ASN_PROGRAM} check-ber check-xer check-oer check-per
|
||||
@echo ================
|
||||
@echo All tests passed
|
||||
@echo ================
|
||||
|
||||
check-ber:
|
||||
@if test -f sample-DataInterChange-1.[db]er ; then \
|
||||
for f in sample-DataInterChange-*.[db]er; do \
|
||||
for f in sample-*-*.[db]er; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f into XER and back ($$b)..."; \
|
||||
./${TARGET} -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${TARGET} -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 4; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -iber -onull $$f || exit 5; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -iber -onull $$f || exit 6; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 5; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 6; \
|
||||
done; done; fi
|
||||
|
||||
check-xer:
|
||||
@if test -f sample-DataInterChange-1.xer ; then \
|
||||
for f in sample-DataInterChange-*.xer; do \
|
||||
for f in sample-*-*.xer; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f into DER and back ($$b)..."; \
|
||||
./${TARGET} -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
echo "Recoding $$f ($$pdu) into DER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
diff $$f ./.tmp.2.$$$$ || exit 4; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -ixer -onull $$f || exit 5; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -ixer -onull $$f || exit 6; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 5; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 6; \
|
||||
done; done; fi
|
||||
|
||||
check-oer:
|
||||
@if test -f sample-DataInterChange-1.*oer ; then \
|
||||
for f in sample-*-*.*oer; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ioer -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -ooer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
diff $$f ./.tmp.2.$$$$ || exit 4; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait) ($$b) ..."; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 5; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 6; \
|
||||
done; done; fi
|
||||
|
||||
check-per:
|
||||
@if test -f sample-DataInterChange-1-nopad.per ; then \
|
||||
for f in sample-DataInterChange-[1-9]-nopad.per; do \
|
||||
for f in sample-*-[1-9]-nopad.per; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding non-padded $$f into DER into XER and back ($$b)..."; \
|
||||
./${TARGET} -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
./${TARGET} -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \
|
||||
echo "Recoding non-padded $$f ($$pdu) into DER into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \
|
||||
diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 5; \
|
||||
rm -f ./.tmp.[123].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -per-nopad -iper -onull $$f || exit 6; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -per-nopad -iper -onull $$f || exit 7; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 6; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 7; \
|
||||
done; done; fi
|
||||
@if test -f sample-DataInterChange-1.per ; then \
|
||||
for f in sample-*-[1-9].per; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z-]+)-[0-9].*/\1/"`; \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f into DER into XER and back ($$b)..."; \
|
||||
./${TARGET} -b $$b -p $$pdu -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \
|
||||
./${TARGET} -b $$b -p $$pdu -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \
|
||||
./${TARGET} -b $$b -p $$pdu -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \
|
||||
echo "Recoding $$f ($$pdu) into DER into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \
|
||||
diff $$f ./.tmp.1.$$$$ || exit 6; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -iper -onull $$f || exit 7; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -iper -onull $$f || exit 8; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 7; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 8; \
|
||||
done; done; fi
|
||||
|
||||
maybe-wip-pause:
|
||||
@if [ -f WIP ]; then cat WIP; sleep 2; fi
|
||||
|
||||
distclean: clean
|
||||
rm -f $(ASN_MODULE_SOURCES)
|
||||
rm -f $(ASN_MODULE_HEADERS)
|
||||
rm -f $(ASN_CONVERTER_SOURCES) $(ASN_CONVERTER_HEADERS)
|
||||
rm -f Makefile.am.sample
|
||||
rm -f $(ASN_MODULE_SRCS)
|
||||
rm -f $(ASN_MODULE_HDRS)
|
||||
rm -f $(ASN_PROGRAM_SRCS) $(ASN_PROGRAM_HDRS)
|
||||
rm -f converter-example.mk
|
||||
|
|
|
@ -1,262 +1,8 @@
|
|||
ASN_MODULE_SOURCES= \
|
||||
ULP-PDU.c \
|
||||
UlpMessage.c \
|
||||
SUPLINIT.c \
|
||||
Notification.c \
|
||||
NotificationType.c \
|
||||
EncodingType.c \
|
||||
FormatIndicator.c \
|
||||
SLPMode.c \
|
||||
MAC.c \
|
||||
KeyIdentity.c \
|
||||
SUPLSTART.c \
|
||||
SETCapabilities.c \
|
||||
PosTechnology.c \
|
||||
PrefMethod.c \
|
||||
PosProtocol.c \
|
||||
SUPLRESPONSE.c \
|
||||
SETAuthKey.c \
|
||||
KeyIdentity4.c \
|
||||
SUPLPOSINIT.c \
|
||||
RequestedAssistData.c \
|
||||
NavigationModel.c \
|
||||
SatelliteInfo.c \
|
||||
SatelliteInfoElement.c \
|
||||
SUPLPOS.c \
|
||||
PosPayLoad.c \
|
||||
SUPLEND.c \
|
||||
SUPLAUTHREQ.c \
|
||||
SETNonce.c \
|
||||
KeyIdentity2.c \
|
||||
SUPLAUTHRESP.c \
|
||||
SPCAuthKey.c \
|
||||
KeyIdentity3.c \
|
||||
Version.c \
|
||||
SessionID.c \
|
||||
SetSessionID.c \
|
||||
SETId.c \
|
||||
SlpSessionID.c \
|
||||
IPAddress.c \
|
||||
SLPAddress.c \
|
||||
FQDN.c \
|
||||
Ver.c \
|
||||
LocationId.c \
|
||||
Status.c \
|
||||
CellInfo.c \
|
||||
Position.c \
|
||||
PositionEstimate.c \
|
||||
AltitudeInfo.c \
|
||||
CdmaCellInformation.c \
|
||||
GsmCellInformation.c \
|
||||
WcdmaCellInformation.c \
|
||||
FrequencyInfo.c \
|
||||
FrequencyInfoFDD.c \
|
||||
FrequencyInfoTDD.c \
|
||||
UARFCN.c \
|
||||
NMR.c \
|
||||
NMRelement.c \
|
||||
MeasuredResultsList.c \
|
||||
MeasuredResults.c \
|
||||
CellMeasuredResultsList.c \
|
||||
UTRA-CarrierRSSI.c \
|
||||
CellMeasuredResults.c \
|
||||
CellParametersID.c \
|
||||
TGSN.c \
|
||||
PrimaryCCPCH-RSCP.c \
|
||||
TimeslotISCP.c \
|
||||
TimeslotISCP-List.c \
|
||||
PrimaryCPICH-Info.c \
|
||||
CPICH-Ec-N0.c \
|
||||
CPICH-RSCP.c \
|
||||
Pathloss.c \
|
||||
StatusCode.c \
|
||||
QoP.c \
|
||||
Velocity.c \
|
||||
Horvel.c \
|
||||
Horandvervel.c \
|
||||
Horveluncert.c \
|
||||
Horandveruncert.c \
|
||||
PosMethod.c
|
||||
|
||||
ASN_MODULE_HEADERS= \
|
||||
ULP-PDU.h \
|
||||
UlpMessage.h \
|
||||
SUPLINIT.h \
|
||||
Notification.h \
|
||||
NotificationType.h \
|
||||
EncodingType.h \
|
||||
FormatIndicator.h \
|
||||
SLPMode.h \
|
||||
MAC.h \
|
||||
KeyIdentity.h \
|
||||
SUPLSTART.h \
|
||||
SETCapabilities.h \
|
||||
PosTechnology.h \
|
||||
PrefMethod.h \
|
||||
PosProtocol.h \
|
||||
SUPLRESPONSE.h \
|
||||
SETAuthKey.h \
|
||||
KeyIdentity4.h \
|
||||
SUPLPOSINIT.h \
|
||||
RequestedAssistData.h \
|
||||
NavigationModel.h \
|
||||
SatelliteInfo.h \
|
||||
SatelliteInfoElement.h \
|
||||
SUPLPOS.h \
|
||||
PosPayLoad.h \
|
||||
SUPLEND.h \
|
||||
SUPLAUTHREQ.h \
|
||||
SETNonce.h \
|
||||
KeyIdentity2.h \
|
||||
SUPLAUTHRESP.h \
|
||||
SPCAuthKey.h \
|
||||
KeyIdentity3.h \
|
||||
Version.h \
|
||||
SessionID.h \
|
||||
SetSessionID.h \
|
||||
SETId.h \
|
||||
SlpSessionID.h \
|
||||
IPAddress.h \
|
||||
SLPAddress.h \
|
||||
FQDN.h \
|
||||
Ver.h \
|
||||
LocationId.h \
|
||||
Status.h \
|
||||
CellInfo.h \
|
||||
Position.h \
|
||||
PositionEstimate.h \
|
||||
AltitudeInfo.h \
|
||||
CdmaCellInformation.h \
|
||||
GsmCellInformation.h \
|
||||
WcdmaCellInformation.h \
|
||||
FrequencyInfo.h \
|
||||
FrequencyInfoFDD.h \
|
||||
FrequencyInfoTDD.h \
|
||||
UARFCN.h \
|
||||
NMR.h \
|
||||
NMRelement.h \
|
||||
MeasuredResultsList.h \
|
||||
MeasuredResults.h \
|
||||
CellMeasuredResultsList.h \
|
||||
UTRA-CarrierRSSI.h \
|
||||
CellMeasuredResults.h \
|
||||
CellParametersID.h \
|
||||
TGSN.h \
|
||||
PrimaryCCPCH-RSCP.h \
|
||||
TimeslotISCP.h \
|
||||
TimeslotISCP-List.h \
|
||||
PrimaryCPICH-Info.h \
|
||||
CPICH-Ec-N0.h \
|
||||
CPICH-RSCP.h \
|
||||
Pathloss.h \
|
||||
StatusCode.h \
|
||||
QoP.h \
|
||||
Velocity.h \
|
||||
Horvel.h \
|
||||
Horandvervel.h \
|
||||
Horveluncert.h \
|
||||
Horandveruncert.h \
|
||||
PosMethod.h
|
||||
|
||||
ASN_MODULE_HEADERS+=BOOLEAN.h
|
||||
ASN_MODULE_SOURCES+=BOOLEAN.c
|
||||
ASN_MODULE_HEADERS+=ENUMERATED.h
|
||||
ASN_MODULE_SOURCES+=ENUMERATED.c
|
||||
ASN_MODULE_HEADERS+=INTEGER.h
|
||||
ASN_MODULE_HEADERS+=NativeEnumerated.h
|
||||
ASN_MODULE_HEADERS+=GeneralizedTime.h
|
||||
ASN_MODULE_SOURCES+=GeneralizedTime.c
|
||||
ASN_MODULE_HEADERS+=IA5String.h
|
||||
ASN_MODULE_SOURCES+=IA5String.c
|
||||
ASN_MODULE_SOURCES+=INTEGER.c
|
||||
ASN_MODULE_SOURCES+=NativeEnumerated.c
|
||||
ASN_MODULE_HEADERS+=NativeInteger.h
|
||||
ASN_MODULE_SOURCES+=NativeInteger.c
|
||||
ASN_MODULE_HEADERS+=UTCTime.h
|
||||
ASN_MODULE_SOURCES+=UTCTime.c
|
||||
ASN_MODULE_HEADERS+=VisibleString.h
|
||||
ASN_MODULE_SOURCES+=VisibleString.c
|
||||
ASN_MODULE_HEADERS+=asn_SEQUENCE_OF.h
|
||||
ASN_MODULE_SOURCES+=asn_SEQUENCE_OF.c
|
||||
ASN_MODULE_HEADERS+=asn_SET_OF.h
|
||||
ASN_MODULE_SOURCES+=asn_SET_OF.c
|
||||
ASN_MODULE_HEADERS+=constr_CHOICE.h
|
||||
ASN_MODULE_SOURCES+=constr_CHOICE.c
|
||||
ASN_MODULE_HEADERS+=constr_SEQUENCE.h
|
||||
ASN_MODULE_SOURCES+=constr_SEQUENCE.c
|
||||
ASN_MODULE_HEADERS+=constr_SEQUENCE_OF.h
|
||||
ASN_MODULE_SOURCES+=constr_SEQUENCE_OF.c
|
||||
ASN_MODULE_HEADERS+=constr_SET_OF.h
|
||||
ASN_MODULE_SOURCES+=constr_SET_OF.c
|
||||
ASN_MODULE_HEADERS+=asn_application.h
|
||||
ASN_MODULE_HEADERS+=asn_system.h
|
||||
ASN_MODULE_HEADERS+=asn_codecs.h
|
||||
ASN_MODULE_HEADERS+=asn_internal.h
|
||||
ASN_MODULE_HEADERS+=OCTET_STRING.h
|
||||
ASN_MODULE_SOURCES+=OCTET_STRING.c
|
||||
ASN_MODULE_HEADERS+=BIT_STRING.h
|
||||
ASN_MODULE_SOURCES+=BIT_STRING.c
|
||||
ASN_MODULE_SOURCES+=asn_codecs_prim.c
|
||||
ASN_MODULE_HEADERS+=asn_codecs_prim.h
|
||||
ASN_MODULE_HEADERS+=ber_tlv_length.h
|
||||
ASN_MODULE_SOURCES+=ber_tlv_length.c
|
||||
ASN_MODULE_HEADERS+=ber_tlv_tag.h
|
||||
ASN_MODULE_SOURCES+=ber_tlv_tag.c
|
||||
ASN_MODULE_HEADERS+=ber_decoder.h
|
||||
ASN_MODULE_SOURCES+=ber_decoder.c
|
||||
ASN_MODULE_HEADERS+=der_encoder.h
|
||||
ASN_MODULE_SOURCES+=der_encoder.c
|
||||
ASN_MODULE_HEADERS+=constr_TYPE.h
|
||||
ASN_MODULE_SOURCES+=constr_TYPE.c
|
||||
ASN_MODULE_HEADERS+=constraints.h
|
||||
ASN_MODULE_SOURCES+=constraints.c
|
||||
ASN_MODULE_HEADERS+=xer_support.h
|
||||
ASN_MODULE_SOURCES+=xer_support.c
|
||||
ASN_MODULE_HEADERS+=xer_decoder.h
|
||||
ASN_MODULE_SOURCES+=xer_decoder.c
|
||||
ASN_MODULE_HEADERS+=xer_encoder.h
|
||||
ASN_MODULE_SOURCES+=xer_encoder.c
|
||||
ASN_MODULE_HEADERS+=per_support.h
|
||||
ASN_MODULE_SOURCES+=per_support.c
|
||||
ASN_MODULE_HEADERS+=per_decoder.h
|
||||
ASN_MODULE_SOURCES+=per_decoder.c
|
||||
ASN_MODULE_HEADERS+=per_encoder.h
|
||||
ASN_MODULE_SOURCES+=per_encoder.c
|
||||
ASN_MODULE_HEADERS+=per_opentype.h
|
||||
ASN_MODULE_SOURCES+=per_opentype.c
|
||||
ASN_CONVERTER_SOURCES+=converter-sample.c
|
||||
ASN_CONVERTER_SOURCES+=pdu_collection.c
|
||||
|
||||
|
||||
lib_LTLIBRARIES=libsomething.la
|
||||
libsomething_la_SOURCES=$(ASN_MODULE_SOURCES) $(ASN_MODULE_HEADERS)
|
||||
|
||||
# This file may be used as an input for make(3)
|
||||
# Remove the lines below to convert it into a pure .am file
|
||||
TARGET = ulp-dump
|
||||
CFLAGS += -DASN_CONVERTER_TITLE="OMA UserPlane Location Protocol decoder" -DHAVE_CONFIG_H -DJUNKTEST -DPDU=ULP_PDU -DASN_PDU_COLLECTION -I.
|
||||
OBJS=${ASN_MODULE_SOURCES:.c=.o} ${ASN_CONVERTER_SOURCES:.c=.o}
|
||||
|
||||
all: ULP-PDU.c $(TARGET)
|
||||
|
||||
$(TARGET): ${OBJS}
|
||||
$(CC) $(CFLAGS) -o $(TARGET) ${OBJS} $(LDFLAGS) $(LIBS)
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .o
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) -o $@ -c $<
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET)
|
||||
rm -f $(OBJS)
|
||||
|
||||
regen: regenerate-from-asn1-source
|
||||
|
||||
regenerate-from-asn1-source:
|
||||
../../asn1c/asn1c -S ../../skeletons -pdu=ULP-PDU -pdu=SUPLINIT -fcompound-names -gen-PER ../ulp.asn1
|
||||
ASN_PROGRAM = ulp-dump
|
||||
CFLAGS += -DASN_CONVERTER_TITLE="OMA UserPlane Location Protocol decoder" -DHAVE_CONFIG_H -DJUNKTEST -D_DEFAULT_SOURCE
|
||||
begin: ULP-PDU.c maybe-wip-pause all
|
||||
|
||||
-include converter-example.mk
|
||||
|
||||
ULP-PDU.c: ../sample.makefile.regen ../ulp.asn1
|
||||
make regen-makefile
|
||||
|
@ -265,76 +11,97 @@ ULP-PDU.c: ../sample.makefile.regen ../ulp.asn1
|
|||
|
||||
regen-makefile:
|
||||
TITLE="OMA UserPlane Location Protocol decoder" \
|
||||
ASN1CMDOPTS="-pdu=SUPLINIT -fcompound-names -gen-PER" \
|
||||
ASN1MODULES="../ulp.asn1" \
|
||||
ASN1PDU=ULP-PDU \
|
||||
PROGNAME=ulp-dump \
|
||||
ASN_CMDOPTS="-pdu=SUPLINIT -fcompound-names -no-gen-OER" \
|
||||
ASN_MODULES="../ulp.asn1" \
|
||||
ASN_PDU=ULP-PDU \
|
||||
ASN_PROGRAM=ulp-dump \
|
||||
../sample.makefile.regen
|
||||
|
||||
check: ${TARGET} check-ber check-xer check-per
|
||||
check: ${ASN_PROGRAM} check-ber check-xer check-oer check-per
|
||||
@echo ================
|
||||
@echo All tests passed
|
||||
@echo ================
|
||||
|
||||
check-ber:
|
||||
@if test -f sample-ULP-PDU-1.[db]er ; then \
|
||||
for f in sample-ULP-PDU-*.[db]er; do \
|
||||
for f in sample-*-*.[db]er; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f into XER and back ($$b)..."; \
|
||||
./${TARGET} -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${TARGET} -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 4; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -iber -onull $$f || exit 5; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -iber -onull $$f || exit 6; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 5; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 6; \
|
||||
done; done; fi
|
||||
|
||||
check-xer:
|
||||
@if test -f sample-ULP-PDU-1.xer ; then \
|
||||
for f in sample-ULP-PDU-*.xer; do \
|
||||
for f in sample-*-*.xer; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f into DER and back ($$b)..."; \
|
||||
./${TARGET} -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
echo "Recoding $$f ($$pdu) into DER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
diff $$f ./.tmp.2.$$$$ || exit 4; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -ixer -onull $$f || exit 5; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -ixer -onull $$f || exit 6; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 5; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 6; \
|
||||
done; done; fi
|
||||
|
||||
check-oer:
|
||||
@if test -f sample-ULP-PDU-1.*oer ; then \
|
||||
for f in sample-*-*.*oer; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ioer -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -ooer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
diff $$f ./.tmp.2.$$$$ || exit 4; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait) ($$b) ..."; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 5; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 6; \
|
||||
done; done; fi
|
||||
|
||||
check-per:
|
||||
@if test -f sample-ULP-PDU-1-nopad.per ; then \
|
||||
for f in sample-ULP-PDU-[1-9]-nopad.per; do \
|
||||
for f in sample-*-[1-9]-nopad.per; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding non-padded $$f into DER into XER and back ($$b)..."; \
|
||||
./${TARGET} -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
./${TARGET} -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \
|
||||
echo "Recoding non-padded $$f ($$pdu) into DER into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \
|
||||
diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 5; \
|
||||
rm -f ./.tmp.[123].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -per-nopad -iper -onull $$f || exit 6; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -per-nopad -iper -onull $$f || exit 7; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 6; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 7; \
|
||||
done; done; fi
|
||||
@if test -f sample-ULP-PDU-1.per ; then \
|
||||
for f in sample-*-[1-9].per; do \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z-]+)-[0-9].*/\1/"`; \
|
||||
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
|
||||
for b in 1 17 33 980 8192; do \
|
||||
echo "Recoding $$f into DER into XER and back ($$b)..."; \
|
||||
./${TARGET} -b $$b -p $$pdu -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \
|
||||
./${TARGET} -b $$b -p $$pdu -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \
|
||||
./${TARGET} -b $$b -p $$pdu -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \
|
||||
echo "Recoding $$f ($$pdu) into DER into XER and back ($$b)..."; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \
|
||||
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \
|
||||
diff $$f ./.tmp.1.$$$$ || exit 6; \
|
||||
rm -f ./.tmp.[12].$$$$; \
|
||||
echo "Test junking $$f (please wait)..."; \
|
||||
./${TARGET} -J0.0001 -n 1000 -b $$b -iper -onull $$f || exit 7; \
|
||||
./${TARGET} -J0.001 -n 1000 -b $$b -iper -onull $$f || exit 8; \
|
||||
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 7; \
|
||||
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 8; \
|
||||
done; done; fi
|
||||
|
||||
maybe-wip-pause:
|
||||
@if [ -f WIP ]; then cat WIP; sleep 2; fi
|
||||
|
||||
distclean: clean
|
||||
rm -f $(ASN_MODULE_SOURCES)
|
||||
rm -f $(ASN_MODULE_HEADERS)
|
||||
rm -f $(ASN_CONVERTER_SOURCES) $(ASN_CONVERTER_HEADERS)
|
||||
rm -f Makefile.am.sample
|
||||
rm -f $(ASN_MODULE_SRCS)
|
||||
rm -f $(ASN_MODULE_HDRS)
|
||||
rm -f $(ASN_PROGRAM_SRCS) $(ASN_PROGRAM_HDRS)
|
||||
rm -f converter-example.mk
|
||||
|
|
|
@ -36,7 +36,7 @@ the following line
|
|||
and end with the "END" token.
|
||||
Be careful not to copy any non-ASN.1 preambles from that .DOC file.
|
||||
|
||||
After obtaining the tap3.asn1, type `make` in the directory containing
|
||||
After obtaining the ulp.asn1, type `make` in the directory containing
|
||||
this README file.
|
||||
|
||||
ulp-dump USAGE
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
@CODE_COVERAGE_RULES@
|
||||
|
||||
AM_CFLAGS = @ADD_CFLAGS@
|
||||
|
||||
noinst_LTLIBRARIES = libasn1common.la
|
||||
|
||||
libasn1common_la_SOURCES = \
|
||||
asn1_common.h asn1_ref.c asn1_ref.h \
|
||||
asn1_buffer.c asn1_buffer.h \
|
||||
asn1_namespace.c asn1_namespace.h \
|
||||
genhash.c genhash.h
|
||||
|
|
@ -0,0 +1,171 @@
|
|||
#define _GNU_SOURCE
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include "config.h"
|
||||
|
||||
#include "asn1_buffer.h"
|
||||
|
||||
#if !defined(HAVE_DECL_VASPRINTF) || (HAVE_DECL_VASPRINTF == 0)
|
||||
int vasprintf(char **ret, const char *fmt, va_list args);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Create and destroy the buffer.
|
||||
*/
|
||||
abuf *
|
||||
abuf_new() {
|
||||
abuf *ab = calloc(1, sizeof(abuf));
|
||||
assert(ab);
|
||||
ab->length = 0;
|
||||
ab->size = 32;
|
||||
ab->buffer = calloc(1, ab->size);
|
||||
assert(ab->buffer);
|
||||
return ab;
|
||||
}
|
||||
|
||||
void abuf_free(abuf *ab) {
|
||||
if(ab) {
|
||||
union {
|
||||
const char *c_buf;
|
||||
char *nc_buf;
|
||||
} const_cast;
|
||||
const_cast.c_buf = ab->buffer;
|
||||
free(const_cast.nc_buf);
|
||||
free(ab);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Erase contents of the buffer (without destroying it).
|
||||
*/
|
||||
void
|
||||
abuf_clear(abuf *ab) {
|
||||
union {
|
||||
const char *c_buf;
|
||||
char *nc_buf;
|
||||
} const_cast;
|
||||
if(!ab->buffer) {
|
||||
ab->size = 32;
|
||||
ab->buffer = calloc(1, ab->size);
|
||||
assert(ab->buffer);
|
||||
}
|
||||
const_cast.c_buf = ab->buffer;
|
||||
ab->length = 0;
|
||||
const_cast.nc_buf[0] = '\0';
|
||||
}
|
||||
|
||||
static void
|
||||
abuf_resize_by(abuf *ab, size_t size) {
|
||||
union {
|
||||
const char *c_buf;
|
||||
char *nc_buf;
|
||||
} const_cast;
|
||||
const_cast.c_buf = ab->buffer;
|
||||
|
||||
assert(!ab->buffer || ab->buffer[ab->length] == '\0');
|
||||
|
||||
size_t new_size = ab->length + size;
|
||||
char *p = realloc(const_cast.nc_buf, new_size);
|
||||
assert(p);
|
||||
if(!ab->buffer) {
|
||||
assert(ab->length == 0);
|
||||
*p = '\0';
|
||||
}
|
||||
ab->buffer = p;
|
||||
assert(ab->buffer[ab->length] == '\0');
|
||||
ab->size = new_size;
|
||||
}
|
||||
|
||||
void abuf_add_bytes(abuf *ab, const char *str, size_t size) {
|
||||
abuf_resize_by(ab, size + 1);
|
||||
union {
|
||||
const char *c_buf;
|
||||
char *nc_buf;
|
||||
} const_cast;
|
||||
const_cast.c_buf = ab->buffer;
|
||||
memcpy(&const_cast.nc_buf[ab->length], str, size);
|
||||
ab->length += size;
|
||||
const_cast.nc_buf[ab->length] = '\0';
|
||||
}
|
||||
|
||||
void abuf_str(abuf *ab, const char *str) {
|
||||
abuf_add_bytes(ab, str, strlen(str));
|
||||
}
|
||||
|
||||
void abuf_buf(abuf *ab, const abuf *buf) {
|
||||
abuf_add_bytes(ab, buf->buffer, buf->length);
|
||||
}
|
||||
|
||||
int abuf_printf(abuf *ab, const char *fmt, ...) {
|
||||
va_list ap;
|
||||
|
||||
for(;;) {
|
||||
union {
|
||||
const char *c_buf;
|
||||
char *nc_buf;
|
||||
} const_cast;
|
||||
const_cast.c_buf = ab->buffer;
|
||||
va_start(ap, fmt);
|
||||
int ret = vsnprintf(&const_cast.nc_buf[ab->length],
|
||||
ab->size - ab->length, fmt, ap);
|
||||
va_end(ap);
|
||||
assert(ret >= 0);
|
||||
if((size_t)ret < ab->size - ab->length) {
|
||||
ab->length += ret;
|
||||
assert(ab->buffer[ab->length] == '\0');
|
||||
return ret;
|
||||
}
|
||||
const_cast.nc_buf[ab->length] = '\0'; /* Restore order */
|
||||
abuf_resize_by(ab, ret + 1);
|
||||
}
|
||||
}
|
||||
|
||||
int abuf_vprintf(abuf *ab, const char *fmt, va_list ap) {
|
||||
int ret;
|
||||
char *str = 0;
|
||||
|
||||
ret = vasprintf(&str, fmt, ap);
|
||||
assert(ret >= 0);
|
||||
assert(str != NULL);
|
||||
|
||||
abuf_add_bytes(ab, str, ret);
|
||||
|
||||
free(str);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if !defined(HAVE_DECL_VASPRINTF) || (HAVE_DECL_VASPRINTF == 0)
|
||||
/* Solaris doesn't have vasprintf(3). */
|
||||
int
|
||||
vasprintf(char **ret, const char *fmt, va_list args) {
|
||||
int actual_length = -1;
|
||||
va_list copy;
|
||||
va_copy(copy, args);
|
||||
|
||||
int suggested = vsnprintf(NULL, 0, fmt, args);
|
||||
if(suggested >= 0) {
|
||||
*ret = malloc(suggested + 1);
|
||||
if(*ret) {
|
||||
int actual_length = vsnprintf(*ret, suggested + 1, fmt, copy);
|
||||
if(actual_length >= 0) {
|
||||
assert(actual_length == suggested);
|
||||
assert((*ret)[actual_length] == '\0');
|
||||
} else {
|
||||
free(*ret);
|
||||
*ret = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
*ret = NULL;
|
||||
assert(suggested >= 0); /* Can't function like this */
|
||||
}
|
||||
va_end(args);
|
||||
|
||||
return actual_length;
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,36 @@
|
|||
#ifndef ASN1_BUFFER_H
|
||||
#define ASN1_BUFFER_H
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
/*
|
||||
* Your typical dynamic character string buffer.
|
||||
*/
|
||||
typedef struct {
|
||||
const char *buffer;
|
||||
size_t length;
|
||||
size_t size;
|
||||
} abuf;
|
||||
|
||||
/*
|
||||
* Create and destroy the buffer.
|
||||
*/
|
||||
abuf *abuf_new(void);
|
||||
void abuf_free(abuf *);
|
||||
|
||||
/*
|
||||
* Erase contents of the buffer (without destroying it).
|
||||
*/
|
||||
void abuf_clear(abuf *);
|
||||
|
||||
/*
|
||||
* Add characters to the buffer.
|
||||
*/
|
||||
void abuf_str(abuf *, const char *str);
|
||||
void abuf_buf(abuf *, const abuf *);
|
||||
void abuf_add_bytes(abuf *, const char *, size_t);
|
||||
int abuf_printf(abuf *, const char *fmt, ...)
|
||||
__attribute__((format(printf, 2, 3)));
|
||||
int abuf_vprintf(abuf *, const char *fmt, va_list);
|
||||
|
||||
#endif /* ASN1_BUFFER_H */
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2005 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
/*
|
||||
* Copyright (c) 2005-2019 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -22,7 +22,6 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
|
@ -31,6 +30,8 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
@ -64,8 +65,5 @@
|
|||
#ifndef EX_OSFILE
|
||||
#define EX_OSFILE 72
|
||||
#endif
|
||||
#if defined HAVE_DECL_ALLOCA && !HAVE_DECL_ALLOCA
|
||||
#define alloca _alloca
|
||||
#endif
|
||||
#define snprintf _snprintf
|
||||
#endif /* _WIN32 */
|
|
@ -0,0 +1,148 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "asn1_ref.h"
|
||||
#include "asn1_buffer.h"
|
||||
#include "asn1_namespace.h"
|
||||
|
||||
static void (*_add_standard_namespaces_cb)(asn1_namespace_t *);
|
||||
|
||||
void
|
||||
asn1_namespace_add_standard_namespaces_callback(
|
||||
void (*cb)(asn1_namespace_t *)) {
|
||||
_add_standard_namespaces_cb = cb;
|
||||
}
|
||||
|
||||
asn1_namespace_t *
|
||||
asn1_namespace_new() {
|
||||
asn1_namespace_t *ns = calloc(1, sizeof(*ns));
|
||||
|
||||
if(_add_standard_namespaces_cb) {
|
||||
_add_standard_namespaces_cb(ns);
|
||||
}
|
||||
|
||||
return ns;
|
||||
}
|
||||
|
||||
void
|
||||
asn1_namespace_free(asn1_namespace_t *ns) {
|
||||
if(ns) {
|
||||
for(size_t i = 0; i < ns->elements_count; i++) {
|
||||
switch(ns->elements[i].selector) {
|
||||
case NAM_SPACE:
|
||||
break;
|
||||
case NAM_SYMBOL:
|
||||
free(ns->elements[i].u.symbol.identifier);
|
||||
break;
|
||||
}
|
||||
}
|
||||
free(ns->elements);
|
||||
free(ns);
|
||||
}
|
||||
}
|
||||
|
||||
asn1_namespace_t *
|
||||
asn1_namespace_clone(const asn1_namespace_t *old_ns) {
|
||||
asn1_namespace_t *new_ns = calloc(1, sizeof(*new_ns));
|
||||
|
||||
for(size_t i = 0; i < old_ns->elements_count; i++) {
|
||||
switch(old_ns->elements[i].selector) {
|
||||
case NAM_SPACE:
|
||||
asn1_namespace_add_module(new_ns,
|
||||
old_ns->elements[i].u.space.module,
|
||||
old_ns->elements[i].u.space.stop_search);
|
||||
break;
|
||||
case NAM_SYMBOL:
|
||||
asn1_namespace_add_symbol(
|
||||
new_ns, old_ns->elements[i].u.symbol.opt_governor,
|
||||
old_ns->elements[i].u.symbol.identifier,
|
||||
old_ns->elements[i].u.symbol.resolution);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return new_ns;
|
||||
}
|
||||
|
||||
static size_t
|
||||
_add_element(asn1_namespace_t *ns) {
|
||||
size_t idx = ns->elements_count;
|
||||
|
||||
if(ns->elements_count >= ns->elements_size) {
|
||||
size_t elc = ns->elements_size ? ns->elements_size * 2 : 4;
|
||||
ns->elements = realloc(ns->elements, sizeof(ns->elements[0]) * elc);
|
||||
ns->elements_size = elc;
|
||||
}
|
||||
|
||||
ns->elements_count++;
|
||||
return idx;
|
||||
}
|
||||
|
||||
void
|
||||
asn1_namespace_add_symbol(asn1_namespace_t *ns,
|
||||
struct asn1p_ref_s *opt_governor,
|
||||
const char *identifier,
|
||||
struct asn1p_expr_s *resolved_argument) {
|
||||
size_t idx = _add_element(ns);
|
||||
|
||||
ns->elements[idx].selector = NAM_SYMBOL;
|
||||
ns->elements[idx].u.symbol.opt_governor = opt_governor;
|
||||
ns->elements[idx].u.symbol.identifier = strdup(identifier);
|
||||
ns->elements[idx].u.symbol.resolution = resolved_argument;
|
||||
}
|
||||
|
||||
asn1_namespace_t *
|
||||
asn1_namespace_new_from_module(struct asn1p_module_s *module, int stop_search) {
|
||||
asn1_namespace_t *ns = asn1_namespace_new();
|
||||
asn1_namespace_add_module(ns, module, stop_search);
|
||||
return ns;
|
||||
}
|
||||
|
||||
void
|
||||
asn1_namespace_add_module(asn1_namespace_t *ns, struct asn1p_module_s *module,
|
||||
int stop_search) {
|
||||
size_t idx = _add_element(ns);
|
||||
|
||||
ns->elements[idx].selector = NAM_SPACE,
|
||||
ns->elements[idx].u.space.module = module;
|
||||
ns->elements[idx].u.space.stop_search = stop_search;
|
||||
}
|
||||
|
||||
const char *
|
||||
asn1_namespace_string(const asn1_namespace_t *ns) {
|
||||
static abuf ab;
|
||||
|
||||
abuf_clear(&ab);
|
||||
|
||||
if(ns) {
|
||||
abuf_str(&ab, "{");
|
||||
for(size_t i = 0; i < ns->elements_count; i++) {
|
||||
if(i) abuf_str(&ab, ",");
|
||||
switch(ns->elements[i].selector) {
|
||||
case NAM_SPACE:
|
||||
abuf_printf(
|
||||
&ab, "M:\"%s\"%s",
|
||||
*(const char *const *)ns->elements[i].u.space.module,
|
||||
ns->elements[i].u.space.stop_search ? "!" : "");
|
||||
break;
|
||||
case NAM_SYMBOL:
|
||||
abuf_printf(&ab, "S:\"%s%s%s\"",
|
||||
ns->elements[i].u.symbol.opt_governor
|
||||
? asn1p_ref_string(
|
||||
ns->elements[i].u.symbol.opt_governor)
|
||||
: "",
|
||||
ns->elements[i].u.symbol.opt_governor ? ":" : "",
|
||||
ns->elements[i].u.symbol.identifier);
|
||||
break;
|
||||
}
|
||||
}
|
||||
abuf_str(&ab, "}");
|
||||
return ab.buffer;
|
||||
} else {
|
||||
return "<no namespace>";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Structures and prototypes related to parameterization
|
||||
*/
|
||||
#ifndef ASN1_NAMESPACE_H
|
||||
#define ASN1_NAMESPACE_H
|
||||
|
||||
struct asn1p_ref_s; /* Forward declaration */
|
||||
struct asn1p_expr_s; /* Forward declaration */
|
||||
struct asn1p_module_s; /* Forward declaration */
|
||||
|
||||
typedef struct asn1_namespace_s {
|
||||
struct asn1_namespace_element_s {
|
||||
enum {
|
||||
NAM_SPACE, /* The whole search space (e.g. Module) */
|
||||
NAM_SYMBOL, /* A particular symbol */
|
||||
} selector;
|
||||
union {
|
||||
struct {
|
||||
struct asn1p_module_s *module;
|
||||
int stop_search; /* This module MUST contain the symbol */
|
||||
} space;
|
||||
struct {
|
||||
struct asn1p_ref_s *opt_governor; /* optional */
|
||||
char *identifier;
|
||||
struct asn1p_expr_s *resolution;
|
||||
} symbol;
|
||||
} u;
|
||||
} *elements;
|
||||
size_t elements_count;
|
||||
size_t elements_size;
|
||||
} asn1_namespace_t;
|
||||
|
||||
/*
|
||||
* Set callback used to initialize standard namespaces.
|
||||
*/
|
||||
void asn1_namespace_add_standard_namespaces_callback(
|
||||
void (*)(asn1_namespace_t *));
|
||||
|
||||
asn1_namespace_t *asn1_namespace_new(void);
|
||||
void asn1_namespace_free(asn1_namespace_t *);
|
||||
|
||||
asn1_namespace_t *asn1_namespace_clone(const asn1_namespace_t *);
|
||||
|
||||
asn1_namespace_t *asn1_namespace_new_from_module(struct asn1p_module_s *mod, int stop_search);
|
||||
|
||||
void asn1_namespace_add_module(asn1_namespace_t *,
|
||||
struct asn1p_module_s *module, int stop_search);
|
||||
|
||||
void asn1_namespace_add_symbol(asn1_namespace_t *,
|
||||
struct asn1p_ref_s *opt_governor,
|
||||
const char *identifier,
|
||||
struct asn1p_expr_s *resolved_argument);
|
||||
|
||||
/*
|
||||
* Human-readable namespace layout.
|
||||
* Returns a reference to a statically allocated string.
|
||||
*/
|
||||
const char *asn1_namespace_string(const asn1_namespace_t *);
|
||||
|
||||
/*
|
||||
* Create a new namespace by cloning (ns1) and adding (ns2) on top.
|
||||
* Destroys (ns2).
|
||||
*/
|
||||
asn1_namespace_t *asn1_namespace_new_ND(const asn1_namespace_t *ns1,
|
||||
asn1_namespace_t *ns2);
|
||||
|
||||
/*
|
||||
* Introduce and destroy namespace around the given code.
|
||||
* This aids memory management around dynamic namespaces.
|
||||
*/
|
||||
#define WITH_MODULE_NAMESPACE(mod, ns_var, code) \
|
||||
({ \
|
||||
struct asn1_namespace_s *ns_var = \
|
||||
asn1_namespace_new_from_module(mod, 1); \
|
||||
typeof(code) ret = code; \
|
||||
asn1_namespace_free(ns_var); \
|
||||
ret; \
|
||||
})
|
||||
|
||||
#endif /* ASN1_NAMESPACE_H */
|
|
@ -4,28 +4,27 @@
|
|||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "asn1parser.h"
|
||||
#include "asn1_ref.h"
|
||||
|
||||
/*
|
||||
* Construct a new empty reference.
|
||||
*/
|
||||
asn1p_ref_t *
|
||||
asn1p_ref_new(int _lineno) {
|
||||
asn1p_ref_new(int _lineno, struct asn1p_module_s *mod) {
|
||||
asn1p_ref_t *ref;
|
||||
|
||||
ref = calloc(1, sizeof *ref);
|
||||
if(ref) {
|
||||
ref->_lineno = _lineno;
|
||||
}
|
||||
ref = calloc(1, sizeof *ref);
|
||||
assert(ref);
|
||||
asn1p_ref_set_source(ref, mod, _lineno);
|
||||
|
||||
return ref;
|
||||
return ref;
|
||||
}
|
||||
|
||||
void
|
||||
asn1p_ref_free(asn1p_ref_t *ref) {
|
||||
if(ref) {
|
||||
if(ref->components) {
|
||||
int i = ref->comp_count;
|
||||
size_t i = ref->comp_count;
|
||||
while(i--) {
|
||||
free(ref->components[i].name);
|
||||
ref->components[i].name = 0;
|
||||
|
@ -38,8 +37,17 @@ asn1p_ref_free(asn1p_ref_t *ref) {
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
asn1p_ref_set_source(asn1p_ref_t *ref, struct asn1p_module_s *module,
|
||||
int lineno) {
|
||||
if(ref) {
|
||||
ref->module = module;
|
||||
ref->_lineno = lineno;
|
||||
}
|
||||
}
|
||||
|
||||
static enum asn1p_ref_lex_type_e
|
||||
asn1p_ref_name2lextype(char *name) {
|
||||
asn1p_ref_name2lextype(const char *name) {
|
||||
enum asn1p_ref_lex_type_e lex_type;
|
||||
int has_lowercase = 0;
|
||||
|
||||
|
@ -50,7 +58,7 @@ asn1p_ref_name2lextype(char *name) {
|
|||
lex_type = RLT_Amplowercase;
|
||||
}
|
||||
} else if(*name >= 'A' && *name <= 'Z') {
|
||||
char *p;
|
||||
const char *p;
|
||||
|
||||
for(p = name; *p; p++) {
|
||||
if(*p >= 'a' && *p <= 'z') {
|
||||
|
@ -77,7 +85,7 @@ asn1p_ref_name2lextype(char *name) {
|
|||
}
|
||||
|
||||
int
|
||||
asn1p_ref_add_component(asn1p_ref_t *ref, char *name, enum asn1p_ref_lex_type_e lex_type) {
|
||||
asn1p_ref_add_component(asn1p_ref_t *ref, const char *name, enum asn1p_ref_lex_type_e lex_type) {
|
||||
|
||||
if(!ref || !name
|
||||
|| (int)lex_type < RLT_UNKNOWN || lex_type >= RLT_MAX) {
|
||||
|
@ -118,10 +126,9 @@ asn1p_ref_t *
|
|||
asn1p_ref_clone(asn1p_ref_t *ref) {
|
||||
asn1p_ref_t *newref;
|
||||
|
||||
newref = asn1p_ref_new(ref->_lineno);
|
||||
newref = asn1p_ref_new(ref->_lineno, ref->module);
|
||||
if(newref) {
|
||||
int i;
|
||||
for(i = 0; i < ref->comp_count; i++) {
|
||||
for(size_t i = 0; i < ref->comp_count; i++) {
|
||||
if(asn1p_ref_add_component(newref,
|
||||
ref->components[i].name,
|
||||
ref->components[i].lex_type
|
||||
|
@ -135,3 +142,53 @@ asn1p_ref_clone(asn1p_ref_t *ref) {
|
|||
|
||||
return newref;
|
||||
}
|
||||
|
||||
int
|
||||
asn1p_ref_compare(const asn1p_ref_t *a, const asn1p_ref_t *b) {
|
||||
if(a->comp_count != b->comp_count)
|
||||
return -1;
|
||||
if(a->module != b->module)
|
||||
return -1;
|
||||
|
||||
for(size_t i = 0; i < a->comp_count; i++) {
|
||||
if(a->components[i].lex_type != b->components[i].lex_type
|
||||
|| strcmp(a->components[i].name, b->components[i].name) != 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *
|
||||
asn1p_ref_string(const asn1p_ref_t *ref) {
|
||||
static char static_buf[32];
|
||||
static char *buf = static_buf;
|
||||
static size_t buf_size = sizeof(static_buf);
|
||||
char *p = buf;
|
||||
|
||||
if(!ref) return "<no-ref>";
|
||||
|
||||
for(size_t i = 0; i < ref->comp_count; i++) {
|
||||
size_t space = buf_size - (p - buf);
|
||||
int ret =
|
||||
snprintf(p, space, "%s%s", i ? "." : "", ref->components[i].name);
|
||||
if(ret < 0 || (size_t)ret >= space) {
|
||||
i--;
|
||||
char *tmp = malloc(buf_size * 2 + 1);
|
||||
assert(tmp);
|
||||
size_t p_offset = p - buf;
|
||||
memcpy(tmp, buf, (p - buf));
|
||||
if(buf != static_buf) free(buf);
|
||||
buf_size *= 2;
|
||||
buf = tmp;
|
||||
p = tmp + p_offset;
|
||||
} else {
|
||||
p += ret;
|
||||
}
|
||||
}
|
||||
|
||||
*p = '\0';
|
||||
return buf;
|
||||
}
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
/*
|
||||
* Generic reference to the yet unknown type defined elsewhere.
|
||||
*/
|
||||
#ifndef ASN1_PARSER_REFERENCE_H
|
||||
#define ASN1_PARSER_REFERENCE_H
|
||||
#ifndef ASN1_REFERENCE_H
|
||||
#define ASN1_REFERENCE_H
|
||||
|
||||
struct asn1p_module_s;
|
||||
|
||||
typedef struct asn1p_ref_s {
|
||||
|
||||
|
@ -34,20 +36,36 @@ typedef struct asn1p_ref_s {
|
|||
char *name; /* An identifier */
|
||||
} *components;
|
||||
|
||||
int comp_count; /* Number of the components in the reference name. */
|
||||
int comp_size; /* Number of allocated structures */
|
||||
size_t comp_count; /* Number of the components in the reference name. */
|
||||
size_t comp_size; /* Number of allocated structures */
|
||||
|
||||
struct asn1p_module_s *module; /* Defined in module */
|
||||
int _lineno; /* Number of line in the file */
|
||||
} asn1p_ref_t;
|
||||
|
||||
/*
|
||||
* Constructor and destructor.
|
||||
*/
|
||||
asn1p_ref_t *asn1p_ref_new(int _lineno);
|
||||
asn1p_ref_t *asn1p_ref_new(int _lineno, struct asn1p_module_s *mod);
|
||||
void asn1p_ref_free(asn1p_ref_t *);
|
||||
|
||||
asn1p_ref_t *asn1p_ref_clone(asn1p_ref_t *ref);
|
||||
|
||||
void asn1p_ref_set_source(asn1p_ref_t *, struct asn1p_module_s *module,
|
||||
int lineno);
|
||||
|
||||
|
||||
/*
|
||||
* Lexicographically compare references.
|
||||
*/
|
||||
int asn1p_ref_compare(const asn1p_ref_t *, const asn1p_ref_t *);
|
||||
|
||||
/*
|
||||
* Return a pointer to a statically allocated buffer representing the
|
||||
* complete reference.
|
||||
*/
|
||||
const char *asn1p_ref_string(const asn1p_ref_t *);
|
||||
|
||||
/*
|
||||
* Add a new reference component to the existing reference structure.
|
||||
*
|
||||
|
@ -57,6 +75,6 @@ asn1p_ref_t *asn1p_ref_clone(asn1p_ref_t *ref);
|
|||
* -1/ENOMEM: Memory allocation failed
|
||||
*/
|
||||
int asn1p_ref_add_component(asn1p_ref_t *,
|
||||
char *name, enum asn1p_ref_lex_type_e);
|
||||
const char *name, enum asn1p_ref_lex_type_e);
|
||||
|
||||
#endif /* ASN1_PARSER_REFERENCE_H */
|
||||
#endif /* ASN1_REFERENCE_H */
|
|
@ -0,0 +1,812 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2005 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2001-2004 Netli, Inc. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: genhash.c 447 2005-06-07 06:51:10Z vlm $
|
||||
*/
|
||||
/*
|
||||
* Implementation of a hash data structure.
|
||||
* This particular implementation is supposed to be space-efficient
|
||||
* particularly in the case of tiny number of hash elements.
|
||||
* It also has an aggressive hash buckets expanding technique, which allows
|
||||
* to deal with increasing number of elements without a loss of search speed.
|
||||
*
|
||||
* Generally, one structure of type genhash_t is allocated per hash set.
|
||||
* This structure is supposed to hold all information related to the current
|
||||
* set, and also holds a tiny number of hash elements, when hash hasn't yet
|
||||
* grown up. When the number of elements reaches some point, part of the
|
||||
* genhash_t structure is reused to contain the pointers to the actual
|
||||
* hash buckets and LRU (Least Recently Used) list's head and tail.
|
||||
* Elements which were held inside genhash_t will be moved to the hash buckets.
|
||||
*
|
||||
* Said above effectively means two modes of operation: TINY and NORMAL.
|
||||
* They can be distinguished by examining the h->numbuckets value, which
|
||||
* is 0 for TINY and greater for NORMAL mode.
|
||||
*
|
||||
* In the TINY mode we use a lower part of the genhash_t structure
|
||||
* (lower 32 bytes from 64 bytes of genhash_t) to hold up to IH_VALUE (4)
|
||||
* key/value pairs.
|
||||
*
|
||||
* In the NORMAL mode we use the lower part of the genhash_t structure
|
||||
* to hold a set of pointers, including a pointer to the hash buckets.
|
||||
* We agressively expand hash buckets size when adding new elements
|
||||
* to lower the number of key comparisons.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <errno.h>
|
||||
#include "genhash.h"
|
||||
|
||||
/* 1M entries, 4M RAM */
|
||||
#define DEFAULT_MAXIMUM_HASH_BUCKETS_NUMBER (1024 * 1024)
|
||||
static int maximum_hash_buckets_number = DEFAULT_MAXIMUM_HASH_BUCKETS_NUMBER;
|
||||
|
||||
/*
|
||||
* A single hash element structure which binds a value to its key.
|
||||
*/
|
||||
typedef struct genhash_el_s {
|
||||
unsigned int key_hash; /* Saved hash of the key */
|
||||
void *key;
|
||||
void *value;
|
||||
struct genhash_el_s *hash_next; /* Collision list inside the bucket */
|
||||
struct genhash_el_s *hash_prev;
|
||||
struct genhash_el_s *lru_prev; /* Per-hash LRU list */
|
||||
struct genhash_el_s *lru_next;
|
||||
} genhash_el;
|
||||
|
||||
/*
|
||||
* A hash structure with buckets etc.
|
||||
*/
|
||||
struct genhash_s {
|
||||
int (*keycmpf) (const void *lkey1, const void *rkey2);
|
||||
unsigned int (*keyhashf) (const void *key); /* hash function */
|
||||
void (*keydestroyf) (void *key); /* key destructor */
|
||||
void (*valuedestroyf) (void *value); /* value destructor */
|
||||
|
||||
int numelements; /* Total number of hash elements */
|
||||
int numbuckets; /* 0 means "use _TINY" */
|
||||
int lru_limit; /* Must be initialized explicitly */
|
||||
genhash_iter_t *iters; /* Active iterators */
|
||||
|
||||
/* 32-byte boundary here */
|
||||
|
||||
union {
|
||||
#define IH_VALUES 4 /* Internally held key/value pairs for TINY mode */
|
||||
struct _internal_tiny_s {
|
||||
void *keys[IH_VALUES];
|
||||
void *values[IH_VALUES];
|
||||
} _TINY; /* 32-byte structure */
|
||||
struct _internal_normal_s {
|
||||
genhash_el *lru_head; /* LRU list head */
|
||||
genhash_el *lru_tail; /* LRU list tail */
|
||||
genhash_el **buckets; /* Hash buckets */
|
||||
/* void *unused; */
|
||||
} _NORMAL;
|
||||
} un;
|
||||
#define tiny_keys un._TINY.keys
|
||||
#define tiny_values un._TINY.values
|
||||
#define lru_head un._NORMAL.lru_head
|
||||
#define lru_tail un._NORMAL.lru_tail
|
||||
#define buckets un._NORMAL.buckets
|
||||
};
|
||||
|
||||
|
||||
static int
|
||||
_genhash_normal_add(genhash_t *h, genhash_el *el, void *key, void *value);
|
||||
|
||||
|
||||
genhash_t *
|
||||
genhash_new(
|
||||
int (*keycmpf) (const void *key1, const void *key2),
|
||||
unsigned int (*keyhashf) (const void *key),
|
||||
void (*keydestroyf) (void *key),
|
||||
void (*valuedestroyf) (void *value)
|
||||
) {
|
||||
genhash_t *h;
|
||||
|
||||
h = (genhash_t *)malloc(sizeof(genhash_t));
|
||||
if (!h)
|
||||
return NULL;
|
||||
|
||||
memset(h, 0, sizeof(genhash_t));
|
||||
|
||||
genhash_reinit(h, keycmpf, keyhashf, keydestroyf, valuedestroyf);
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
int
|
||||
genhash_reinit(
|
||||
genhash_t *h,
|
||||
int (*keycmpf) (const void *key1, const void *key2),
|
||||
unsigned int (*keyhashf) (const void *key),
|
||||
void (*keydestroyf) (void *key),
|
||||
void (*valuedestroyf) (void *value)
|
||||
) {
|
||||
|
||||
assert(keycmpf && keyhashf);
|
||||
|
||||
h->keycmpf = keycmpf;
|
||||
h->keyhashf = keyhashf;
|
||||
h->keydestroyf = keydestroyf;
|
||||
h->valuedestroyf = valuedestroyf;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
genhash_count(genhash_t *h) {
|
||||
if(h) {
|
||||
return h->numelements;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_remove_normal_hash_el(genhash_t *h, genhash_el *el) {
|
||||
genhash_iter_t *iter;
|
||||
void *kd_arg;
|
||||
void *vd_arg;
|
||||
|
||||
/* Remove from the collision list */
|
||||
if (el->hash_prev) {
|
||||
if((el->hash_prev->hash_next = el->hash_next))
|
||||
el->hash_next->hash_prev = el->hash_prev;
|
||||
|
||||
} else {
|
||||
if((h->buckets[el->key_hash % h->numbuckets] = el->hash_next))
|
||||
el->hash_next->hash_prev = NULL;
|
||||
}
|
||||
|
||||
/* Remove from LRU list */
|
||||
if(el->lru_prev) {
|
||||
if((el->lru_prev->lru_next = el->lru_next))
|
||||
el->lru_next->lru_prev = el->lru_prev;
|
||||
else
|
||||
h->lru_tail = el->lru_prev;
|
||||
} else {
|
||||
if(h->lru_head == el) {
|
||||
if((h->lru_head = el->lru_next) == NULL)
|
||||
h->lru_tail = NULL;
|
||||
else
|
||||
h->lru_head->lru_prev = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Remember key and value */
|
||||
kd_arg = el->key;
|
||||
vd_arg = el->value;
|
||||
|
||||
/* Move iterators off the element being deleted */
|
||||
for(iter = h->iters; iter; iter = iter->iter_next) {
|
||||
assert(iter->hash_ptr == h);
|
||||
if(iter->un.location == el) {
|
||||
iter->un.location = iter->order_lru_first
|
||||
? el->lru_prev : el->lru_next;
|
||||
}
|
||||
}
|
||||
|
||||
free(el);
|
||||
h->numelements--;
|
||||
|
||||
/* Remove key and value */
|
||||
if (h->keydestroyf) h->keydestroyf(kd_arg);
|
||||
if (h->valuedestroyf) h->valuedestroyf(vd_arg);
|
||||
}
|
||||
|
||||
static inline void
|
||||
_genhash_normal_el_move2top(genhash_t *h, genhash_el *el) {
|
||||
|
||||
/* Disable sorting if iterators are running */
|
||||
if(h->iters) return;
|
||||
|
||||
/* Move to the top of the hash bucket */
|
||||
if(el->hash_prev) {
|
||||
int bucket = el->key_hash % h->numbuckets;
|
||||
|
||||
/* Remove from the current location */
|
||||
if((el->hash_prev->hash_next = el->hash_next))
|
||||
el->hash_next->hash_prev = el->hash_prev;
|
||||
|
||||
/* Move to the top of the hash bucket */
|
||||
if((el->hash_next = h->buckets[bucket]))
|
||||
el->hash_next->hash_prev = el;
|
||||
h->buckets[bucket] = el;
|
||||
el->hash_prev = NULL;
|
||||
}
|
||||
|
||||
/* Move to the top of LRU list */
|
||||
if(h->lru_limit && el->lru_prev) {
|
||||
|
||||
/* Remove from current location */
|
||||
if((el->lru_prev->lru_next = el->lru_next))
|
||||
el->lru_next->lru_prev = el->lru_prev;
|
||||
else
|
||||
h->lru_tail = el->lru_prev;
|
||||
|
||||
/* Append to the head */
|
||||
el->lru_prev = NULL;
|
||||
h->lru_head->lru_prev = el;
|
||||
el->lru_next = h->lru_head;
|
||||
h->lru_head = el;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_expand_hash(genhash_t *h) {
|
||||
int newbuckets_count;
|
||||
genhash_el **newbuckets;
|
||||
|
||||
/*
|
||||
* Compute a new number of buckets value.
|
||||
*/
|
||||
if(h->numbuckets) {
|
||||
newbuckets_count = h->numbuckets << 2;
|
||||
/* Too big hash table */
|
||||
if(newbuckets_count > maximum_hash_buckets_number) {
|
||||
if(h->numbuckets < maximum_hash_buckets_number) {
|
||||
newbuckets_count = maximum_hash_buckets_number;
|
||||
} else {
|
||||
/* No need to set errno here. */
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* 8 buckets -> 32 bytes of memory */
|
||||
newbuckets_count = IH_VALUES << 1;
|
||||
if(newbuckets_count > maximum_hash_buckets_number) {
|
||||
if(maximum_hash_buckets_number) {
|
||||
newbuckets_count = maximum_hash_buckets_number;
|
||||
} else {
|
||||
/* Allowed to store only IH_VALUES elements */
|
||||
errno = EPERM;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate a new storage for buckets.
|
||||
*/
|
||||
newbuckets = malloc(newbuckets_count * sizeof(*newbuckets));
|
||||
if(newbuckets) {
|
||||
memset(newbuckets, 0, newbuckets_count * sizeof(*newbuckets));
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(h->numbuckets) {
|
||||
genhash_el *el;
|
||||
int bucket;
|
||||
|
||||
/*
|
||||
* Rehash elements from old h->buckets to newbuckets.
|
||||
* No need to touch LRU pointers and other stuff - it is okay.
|
||||
*/
|
||||
for(el = h->lru_tail; el; el = el->lru_prev) {
|
||||
bucket = el->key_hash % newbuckets_count;
|
||||
el->hash_prev = NULL;
|
||||
if((el->hash_next = newbuckets[bucket]))
|
||||
el->hash_next->hash_prev = el;
|
||||
newbuckets[bucket] = el;
|
||||
}
|
||||
|
||||
free(h->buckets);
|
||||
h->buckets = newbuckets;
|
||||
h->numbuckets = newbuckets_count;
|
||||
} else {
|
||||
/*
|
||||
* Moving from inline tiny storage into buckets.
|
||||
*/
|
||||
genhash_el *els[IH_VALUES] = { NULL };
|
||||
struct _internal_tiny_s tiny_substruct;
|
||||
int i;
|
||||
int saved_numelements;
|
||||
int saved_lru_limit;
|
||||
genhash_iter_t *iter;
|
||||
|
||||
/* Pre-allocate hash elements (for "undo") */
|
||||
for(i = 0; i < h->numelements; i++) {
|
||||
els[i] = (genhash_el *)malloc(sizeof(genhash_el));
|
||||
if(els[i] == NULL) {
|
||||
for(i = 0; i < h->numelements; i++)
|
||||
if(els[i])
|
||||
free(els[i]);
|
||||
free(newbuckets);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Save part of the union */
|
||||
tiny_substruct = h->un._TINY;
|
||||
/* Re-initialize this part in NORMAL model */
|
||||
memset(&h->un._NORMAL, 0, sizeof(h->un._NORMAL));
|
||||
|
||||
/* There was no allocated buckets, when in tiny hash mode. */
|
||||
h->buckets = newbuckets;
|
||||
h->numbuckets = newbuckets_count;
|
||||
|
||||
saved_numelements = h->numelements;
|
||||
saved_lru_limit = h->lru_limit;
|
||||
h->numelements = 0;
|
||||
h->lru_limit = 0; /* Disable LRU expiration for a while */
|
||||
|
||||
for(i = saved_numelements - 1; i >= 0; --i) {
|
||||
/*
|
||||
* genhash_normal_add won't fail, if we supply
|
||||
* an already allocated genhash_el *.
|
||||
*/
|
||||
(void)_genhash_normal_add(h, els[i],
|
||||
tiny_substruct.keys[i],
|
||||
tiny_substruct.values[i]);
|
||||
}
|
||||
|
||||
/* Now, scan through iterators and convert them TINY->NORMAL */
|
||||
for(iter = h->iters; iter; iter = iter->iter_next) {
|
||||
assert(iter->hash_ptr == h);
|
||||
if(iter->un.item_number < 0
|
||||
|| iter->un.item_number >= saved_numelements) {
|
||||
iter->un.location = 0;
|
||||
} else {
|
||||
iter->un.location = els[iter->un.item_number];
|
||||
}
|
||||
}
|
||||
|
||||
h->lru_limit = saved_lru_limit;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Won't return with error if el is provided.
|
||||
*/
|
||||
static int
|
||||
_genhash_normal_add(genhash_t *h, genhash_el *el, void *key, void *value) {
|
||||
genhash_el **bucket;
|
||||
|
||||
if(el == NULL) {
|
||||
el = malloc(sizeof (*el));
|
||||
if(el == NULL) {
|
||||
/* Errno will be set by malloc() */
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Maintain maximum number of entries */
|
||||
if(h->lru_limit) {
|
||||
while(h->numelements >= h->lru_limit)
|
||||
_remove_normal_hash_el(h, h->lru_tail);
|
||||
}
|
||||
|
||||
memset(el, 0, sizeof(genhash_el));
|
||||
|
||||
/* Compute the index of the collision list */
|
||||
el->key_hash = h->keyhashf(key);
|
||||
bucket = &h->buckets[el->key_hash % h->numbuckets];
|
||||
|
||||
el->key = key;
|
||||
el->value = value;
|
||||
|
||||
/*
|
||||
* Add to the collision list
|
||||
*/
|
||||
el->hash_prev = NULL;
|
||||
if((el->hash_next = *bucket))
|
||||
(*bucket)->hash_prev = el;
|
||||
*bucket = el;
|
||||
|
||||
/*
|
||||
* Add to the LRU list.
|
||||
*/
|
||||
if(h->lru_head) {
|
||||
el->lru_next = h->lru_head;
|
||||
el->lru_next->lru_prev = el;
|
||||
h->lru_head = el;
|
||||
} else {
|
||||
h->lru_head = el;
|
||||
h->lru_tail = el;
|
||||
}
|
||||
|
||||
h->numelements++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
genhash_add(genhash_t *h, void *key, void *value) {
|
||||
|
||||
if(key == NULL) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(h->numbuckets == 0) {
|
||||
|
||||
/* We have a tiny internally-held set of elements */
|
||||
if(h->numelements < IH_VALUES) {
|
||||
h->tiny_keys[h->numelements] = key;
|
||||
h->tiny_values[h->numelements] = value;
|
||||
h->numelements++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(_expand_hash(h) == -1)
|
||||
return -1;
|
||||
|
||||
} else {
|
||||
|
||||
if((h->numelements / h->numbuckets) > 2)
|
||||
(void)_expand_hash(h);
|
||||
}
|
||||
|
||||
return _genhash_normal_add(h, NULL, key, value);
|
||||
}
|
||||
|
||||
int
|
||||
genhash_addunique(genhash_t *h, void *key, void *value) {
|
||||
if(genhash_get(h, key)) {
|
||||
errno = EEXIST;
|
||||
return -1;
|
||||
}
|
||||
return genhash_add(h, key, value);
|
||||
}
|
||||
|
||||
void *
|
||||
genhash_get(genhash_t *h, const void *key) {
|
||||
|
||||
if(h->numbuckets) {
|
||||
|
||||
genhash_el *walk;
|
||||
int bucket = h->keyhashf(key) % h->numbuckets;
|
||||
|
||||
for(walk = h->buckets[bucket];
|
||||
walk; walk = walk->hash_next) {
|
||||
|
||||
if (h->keycmpf(walk->key, key) == 0) {
|
||||
_genhash_normal_el_move2top(h, walk);
|
||||
return walk->value;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
/* TINY mode */
|
||||
int i;
|
||||
|
||||
assert(h->numelements <= IH_VALUES);
|
||||
for(i = 0; i < h->numelements; i++) {
|
||||
if(h->keycmpf(h->tiny_keys[i], key) == 0)
|
||||
/* Don't reorder in TINY mode */
|
||||
return h->tiny_values[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
errno = ESRCH;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
genhash_del(genhash_t *h, void *key) {
|
||||
|
||||
if(h->numbuckets) {
|
||||
/* NORMAL mode */
|
||||
genhash_el *walk;
|
||||
int bucket;
|
||||
|
||||
if(h->numelements == 0) {
|
||||
errno = ESRCH;
|
||||
return -1; /* not found */
|
||||
}
|
||||
|
||||
bucket = h->keyhashf(key) % h->numbuckets;
|
||||
|
||||
for(walk = h->buckets[bucket]; walk; walk = walk->hash_next)
|
||||
if(h->keycmpf(walk->key, key) == 0)
|
||||
break;
|
||||
|
||||
if(walk) {
|
||||
_remove_normal_hash_el(h, walk);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
/* TINY mode */
|
||||
int i;
|
||||
|
||||
/* Look for matching key */
|
||||
for(i = 0; i < h->numelements; i++)
|
||||
if(h->keycmpf(h->tiny_keys[i], key) == 0)
|
||||
break;
|
||||
|
||||
if(i < h->numelements) {
|
||||
/* Remember values */
|
||||
void *kd_arg = h->tiny_keys[i];
|
||||
void *vd_arg = h->tiny_values[i];
|
||||
|
||||
h->numelements--;
|
||||
|
||||
if(h->iters) {
|
||||
/* If iterators are involved, we have to
|
||||
* shift elements to maintain iteration order
|
||||
* and avoid duplications */
|
||||
genhash_iter_t *iter;
|
||||
memmove(&h->tiny_keys[i],
|
||||
&h->tiny_keys[i+1],
|
||||
(h->numelements - i)
|
||||
* sizeof(h->tiny_keys[0]));
|
||||
memmove(&h->tiny_values[i],
|
||||
&h->tiny_values[i+1],
|
||||
(h->numelements - i)
|
||||
* sizeof(h->tiny_values[0]));
|
||||
/* Shift the iterator's indexes */
|
||||
for(iter = h->iters; iter;
|
||||
iter = iter->iter_next) {
|
||||
int in = iter->un.item_number;
|
||||
if(iter->order_lru_first) {
|
||||
if(in > i)
|
||||
iter->un.item_number--;
|
||||
} else {
|
||||
if(in >= i)
|
||||
iter->un.item_number--;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Substitute it with the last one */
|
||||
/* No harm if overwriting itself */
|
||||
h->tiny_keys[i] = h->tiny_keys[h->numelements];
|
||||
h->tiny_values[i] = h->tiny_values[h->numelements];
|
||||
}
|
||||
h->tiny_keys[h->numelements] = 0;
|
||||
h->tiny_values[h->numelements] = 0;
|
||||
/* Delete for real */
|
||||
if(h->keydestroyf) h->keydestroyf(kd_arg);
|
||||
if(h->valuedestroyf) h->valuedestroyf(vd_arg);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
errno = ESRCH;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize a hash iterator.
|
||||
*/
|
||||
int
|
||||
genhash_iter_init(genhash_iter_t *iter, genhash_t *h, int reverse_order) {
|
||||
|
||||
iter->hash_ptr = h;
|
||||
iter->iter_prev = 0; /* Add itself to the iterators list */
|
||||
iter->iter_next = h->iters;
|
||||
h->iters = iter;
|
||||
iter->order_lru_first = reverse_order;
|
||||
|
||||
if(h->numbuckets) {
|
||||
/* NORMAL mode */
|
||||
if(reverse_order) {
|
||||
/* Least recent first order */
|
||||
iter->un.location = h->lru_tail;
|
||||
} else {
|
||||
/* Most recent first order */
|
||||
iter->un.location = h->lru_head;
|
||||
}
|
||||
} else {
|
||||
/* TINY mode */
|
||||
if(reverse_order) {
|
||||
iter->un.item_number = 0;
|
||||
} else {
|
||||
iter->un.item_number = h->numelements - 1;
|
||||
}
|
||||
}
|
||||
|
||||
return h->numelements;
|
||||
}
|
||||
|
||||
int
|
||||
genhash_iter(genhash_iter_t *iter, void *key_p, void *val_p) {
|
||||
void **key = key_p;
|
||||
void **val = val_p;
|
||||
genhash_t *h = iter->hash_ptr;
|
||||
|
||||
if(h->numbuckets) {
|
||||
/* NORMAL mode */
|
||||
genhash_el *cur_el = iter->un.location;
|
||||
if(!cur_el)
|
||||
/* Already finished */
|
||||
return 0;
|
||||
|
||||
if(key) *key = cur_el->key;
|
||||
if(val) *val = cur_el->value;
|
||||
|
||||
/* Move pointer to the next hash element */
|
||||
iter->un.location = iter->order_lru_first
|
||||
? cur_el->lru_prev : cur_el->lru_next;
|
||||
} else {
|
||||
/* TINY mode */
|
||||
if(iter->un.item_number < 0
|
||||
|| iter->un.item_number >= h->numelements
|
||||
|| h->tiny_keys[iter->un.item_number] == 0)
|
||||
return 0;
|
||||
|
||||
if(key) *key = h->tiny_keys[iter->un.item_number];
|
||||
if(val) *val = h->tiny_values[iter->un.item_number];
|
||||
|
||||
/* Advance to the next element */
|
||||
if(iter->order_lru_first)
|
||||
iter->un.item_number++;
|
||||
else
|
||||
iter->un.item_number--;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
genhash_iter_done(genhash_iter_t *iter) {
|
||||
assert(iter->hash_ptr->iters);
|
||||
/* Remove itself from the iterators list */
|
||||
if(iter->iter_next)
|
||||
iter->iter_next->iter_prev = iter->iter_prev;
|
||||
if(iter->iter_prev)
|
||||
iter->iter_prev->iter_next = iter->iter_next;
|
||||
else
|
||||
iter->hash_ptr->iters = iter->iter_next; /* Shift the head */
|
||||
iter->hash_ptr = (void *)0xdeadbeef;
|
||||
}
|
||||
|
||||
int
|
||||
genhash_set_lru_limit(genhash_t *h, int value) {
|
||||
if(h) {
|
||||
int prev_limit = h->lru_limit;
|
||||
if(value >= 0)
|
||||
h->lru_limit = value;
|
||||
return prev_limit;
|
||||
} else {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
genhash_set_buckets_limit(int value) {
|
||||
int prev_limit = maximum_hash_buckets_number;
|
||||
if(value > 0) {
|
||||
maximum_hash_buckets_number = value;
|
||||
}
|
||||
return prev_limit;
|
||||
}
|
||||
|
||||
void
|
||||
genhash_destroy(genhash_t *h) {
|
||||
if(h) {
|
||||
assert(h->iters == 0); /* All iterators MUST be _done(). */
|
||||
genhash_empty(h, 1, 1);
|
||||
free(h);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
genhash_empty(genhash_t *h, int freekeys, int freevalues) {
|
||||
genhash_iter_t *iter;
|
||||
|
||||
if(h == NULL) return;
|
||||
|
||||
/*
|
||||
* Don't free what could not be freed.
|
||||
*/
|
||||
if(h->keydestroyf == NULL) freekeys = 0;
|
||||
if(h->valuedestroyf == NULL) freevalues = 0;
|
||||
|
||||
if(h->numbuckets == 0) {
|
||||
while(h->numelements > 0) {
|
||||
int n = --h->numelements;
|
||||
void *kd_arg = h->tiny_keys[n];
|
||||
void *vd_arg = h->tiny_values[n];
|
||||
|
||||
if (freekeys) h->keydestroyf(kd_arg);
|
||||
if (freevalues) h->valuedestroyf(vd_arg);
|
||||
}
|
||||
} else {
|
||||
genhash_el *el, *el_next;
|
||||
|
||||
for(el = h->lru_head; el; el = el_next) {
|
||||
void *kd_arg = el->key;
|
||||
void *vd_arg = el->value;
|
||||
el_next = el->lru_next;
|
||||
free(el);
|
||||
|
||||
h->numelements --;
|
||||
|
||||
if (freekeys) h->keydestroyf(kd_arg);
|
||||
if (freevalues) h->valuedestroyf(vd_arg);
|
||||
}
|
||||
free(h->buckets);
|
||||
h->numbuckets = 0; /* Move back to TINY model */
|
||||
}
|
||||
memset(&h->un, 0, sizeof(h->un));
|
||||
|
||||
/* Invalidate iterators in TINY model */
|
||||
for(iter = h->iters; iter; iter = iter->iter_next) {
|
||||
assert(iter->hash_ptr == h);
|
||||
iter->un.item_number = -1;
|
||||
}
|
||||
|
||||
assert(h->numelements == 0);
|
||||
}
|
||||
|
||||
|
||||
/*----- Simple hash and compare functions for common data types ------*/
|
||||
|
||||
unsigned int
|
||||
hashf_int (const void *key) {
|
||||
return (*(const ptrdiff_t *)key ^ (*(const ptrdiff_t *)key >> 16));
|
||||
}
|
||||
|
||||
int
|
||||
cmpf_int (const void *key1, const void *key2) {
|
||||
return (*(const int *)key1 != *(const int *)key2);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
hashf_void (const void *key) {
|
||||
return ((ptrdiff_t)key ^ ((ptrdiff_t)key >> 16));
|
||||
}
|
||||
|
||||
int
|
||||
cmpf_void (const void *key1, const void *key2) {
|
||||
return (key1 != key2);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Phong's linear congruential hash
|
||||
*/
|
||||
#define dcharhash(h, c) ((h) = 0x63c63cd9*(h) + 0x9c39c33d + (c))
|
||||
|
||||
unsigned int
|
||||
hashf_string(const void *keyarg) {
|
||||
register const unsigned char *key;
|
||||
register unsigned int h;
|
||||
register unsigned char c;
|
||||
|
||||
key = keyarg;
|
||||
for (h = 0; (c = *key++);)
|
||||
dcharhash(h, c);
|
||||
|
||||
return (h);
|
||||
}
|
||||
|
||||
int
|
||||
cmpf_string(const void *key1, const void *key2) {
|
||||
return strcmp((const char *)key1, (const char *)key2);
|
||||
}
|
||||
|
|
@ -0,0 +1,230 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2005 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2001-2004 Netli, Inc. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: genhash.h 447 2005-06-07 06:51:10Z vlm $
|
||||
*/
|
||||
#ifndef __GENHASH_H__
|
||||
#define __GENHASH_H__
|
||||
|
||||
/*
|
||||
* General purpose hashing framework.
|
||||
* Refer to the corresponding .c source file for the detailed description.
|
||||
*
|
||||
* WARNING: Generally, functions don't allow NULL's to be passed
|
||||
* as the genhash_t pointers, if not explicitly stated otherwise.
|
||||
*/
|
||||
|
||||
typedef struct genhash_s genhash_t;
|
||||
|
||||
/*
|
||||
* Create a new hash table
|
||||
* keycmpf : function which returns 0 if keys are equal, else !0
|
||||
* keyhashf : function which computes the hash value of a key
|
||||
* keydestroyf : function for destroying keys, can be NULL for no destructor
|
||||
* valuedestroyf: function for destroying values, can be NULL for no destructor
|
||||
*/
|
||||
genhash_t *genhash_new(
|
||||
int (*keycmpf) (const void *key1, const void *key2),
|
||||
unsigned int (*keyhashf) (const void *key),
|
||||
void (*keydestroyf) (void *key),
|
||||
void (*valuedestroyf) (void *value));
|
||||
|
||||
/*
|
||||
* Re-initialize genhash structure with new callback functions.
|
||||
* (Rarely ever used).
|
||||
*/
|
||||
int genhash_reinit(
|
||||
genhash_t *hash,
|
||||
int (*keycmpf) (const void *key1, const void *key2),
|
||||
unsigned int (*keyhashf) (const void *key),
|
||||
void (*keydestroyf) (void *key),
|
||||
void (*valuedestroyf) (void *value));
|
||||
|
||||
/*
|
||||
* Initialize the LRU-driven elements count limiting
|
||||
* and/or set a new Least Recently Used list size limit.
|
||||
* If a new entry is being added to the hash, the least recently used entry
|
||||
* (one at the bottom of the LRU list) will be automatically deleted.
|
||||
* The deletion may be skipped if the hash is very small
|
||||
* (currently, "small" means no longer than 4 entries).
|
||||
* This function is immune to NULL argument.
|
||||
*
|
||||
* RETURN VALUES:
|
||||
* The previous LRU limit, or -1/EINVAL when h is NULL.
|
||||
* EXAMPLE:
|
||||
* genhash_set_lru_limit(h, 1500); // Maximum 1500 entries in the hash
|
||||
*/
|
||||
int genhash_set_lru_limit(genhash_t *h, int new_lru_limit);
|
||||
|
||||
/*
|
||||
* Set the system-wide (!!!) limit on maximum number of buckets.
|
||||
* If the value is 0, the hash is allowed to store only 4 elements inline
|
||||
* (buckets allocation is suppressed).
|
||||
* If the value is 1, the hash turns out into a linked list.
|
||||
* The default limit is about 1M buckets.
|
||||
* RETURN VALUES:
|
||||
* The previous buckets number limit.
|
||||
*/
|
||||
int genhash_set_buckets_limit(int new_max_number_of_buckets);
|
||||
|
||||
/*
|
||||
* destroys a hash, freeing each key and/or value.
|
||||
* Keys are always destroyed before values using the destructors
|
||||
* specified upon hash creation.
|
||||
* This function is immune to NULL argument.
|
||||
*/
|
||||
void genhash_destroy(genhash_t *h);
|
||||
|
||||
/*
|
||||
* Delete all elements from the hash, retaining the hash structure itself.
|
||||
* Optionally, it may be told to invoke, or not invoke the corresponding
|
||||
* key/value destructors.
|
||||
* This function is immune to NULL argument.
|
||||
*
|
||||
* EXAMPLE:
|
||||
* genhash_empty(h, 1, 1); // Remove all entries, invoking destructors
|
||||
*/
|
||||
void genhash_empty(genhash_t *h, int freekeys, int freevalues);
|
||||
|
||||
/*
|
||||
* Add, returns 0 on success, -1 on failure (ENOMEM). Note, you CAN add
|
||||
* records with duplicate keys. No guarantees about order preservations.
|
||||
*
|
||||
* EXAMPLE:
|
||||
* char *key_str = strdup("key");
|
||||
* char *val_str = strdup("arbitrary value");
|
||||
* if(genhash_add(h, key_str, val_str) != 0) {
|
||||
* free(key_str);
|
||||
* free(val_str);
|
||||
* perror("genhash_add failed");
|
||||
* exit(EX_SOFTWARE);
|
||||
* }
|
||||
*/
|
||||
int genhash_add(genhash_t *h, void *key, void *value);
|
||||
|
||||
/*
|
||||
* Add, but only if a mapping is not there already.
|
||||
* RETURN VALUES:
|
||||
* 0: Element added successfully.
|
||||
* -1/EINVAL: Invalid arguments (key == NULL).
|
||||
* -1/EEXIST: Duplicate entry is found.
|
||||
* -1/ENOMEM: Memory allocation failed
|
||||
*/
|
||||
int genhash_addunique(genhash_t *h, void *key, void *value);
|
||||
|
||||
/*
|
||||
* Fetch - returns pointer to a value, NULL/ESRCH if not found
|
||||
*/
|
||||
void *genhash_get(genhash_t *h, const void *key);
|
||||
|
||||
/*
|
||||
* Delete - returns 0 on success, -1/ESRCH if not found.
|
||||
* Keys are always destroyed before values using the destructors
|
||||
* specified upon hash creation.
|
||||
*/
|
||||
int genhash_del(genhash_t *h, void *key);
|
||||
|
||||
/*
|
||||
* Return the number of elements in a hash.
|
||||
* This function is immune to NULL argument.
|
||||
*/
|
||||
int genhash_count(genhash_t *h);
|
||||
|
||||
/*
|
||||
* External iterator structure for using with iterator-based walking functions.
|
||||
* This declaration is NOT INTENDED TO BE USED BY AN APPLICATION DIRECTLY
|
||||
* The pointer to the already allocated structure must be passed to
|
||||
* genhash_iter*() functions.
|
||||
*/
|
||||
typedef struct genhash_iter_s {
|
||||
genhash_t *hash_ptr;
|
||||
union {
|
||||
int item_number;
|
||||
void *location;
|
||||
} un;
|
||||
int order_lru_first;
|
||||
struct genhash_iter_s *iter_prev;
|
||||
struct genhash_iter_s *iter_next;
|
||||
} genhash_iter_t;
|
||||
|
||||
/*
|
||||
* Initialize the iterator for walking through the hash.
|
||||
* The memory block to be used as iterator is provided by the (*iter) pointer.
|
||||
* This memory must be allocated (possibly, on the stack) by the caller.
|
||||
* OWNERSHIP:
|
||||
* The initialized iterator must be disposed of by calling
|
||||
* genhash_iter_done().
|
||||
* ORDER:
|
||||
* By default, the elements are iterated in the "most recent first" order,
|
||||
* use reverse_order to change that. For very small number of entries
|
||||
* (currently, 4) the order may be IGNORED.
|
||||
* RETURN VALUES:
|
||||
* number of entries the hash had at the moment.
|
||||
*/
|
||||
int genhash_iter_init(genhash_iter_t *iter,
|
||||
genhash_t *hash_to_use, int reverse_order);
|
||||
|
||||
/*
|
||||
* Returns the key and value of each element in optional (key) and (value),
|
||||
* which must be passed as the pointers to pointers (hence these ***'s).
|
||||
* OWNERSHIP:
|
||||
* The key and value are pointers to the internally manageed locations.
|
||||
* RETURN VALUES:
|
||||
* 0 if no more elements will be returned, otherwise 1.
|
||||
* EXAMPLE:
|
||||
* key_type_t *key; // Pointer to key
|
||||
* value_type_t *val; // Pointer to value
|
||||
* genhash_iter_t iter; // Iterator structure
|
||||
* genhash_iter_init(&iter, hash_ptr, 0); // Prepare iterator
|
||||
* while(genhash_iter(&iter, &key, &val)) // Iterate over hash elements
|
||||
* print_keyval(key, val); // Use key and value
|
||||
* genhash_iter_done(&iter); // Done iterations.
|
||||
*/
|
||||
int genhash_iter(genhash_iter_t *iter, void */***/key, void */***/val);
|
||||
|
||||
/*
|
||||
* Dispose of the iterator.
|
||||
* After this operations, the iterator contents unusable
|
||||
* and shall not be accesed. (genhash_iter_init() is OK).
|
||||
*/
|
||||
void genhash_iter_done(genhash_iter_t *iter);
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/*
|
||||
* The following hashing and comparison functions are provided for
|
||||
* you, or you may supply your own.
|
||||
*/
|
||||
unsigned int hashf_int (const void *key); /* Key is an int * */
|
||||
int cmpf_int (const void *key1, const void *key2);
|
||||
|
||||
unsigned int hashf_void (const void *key);
|
||||
int cmpf_void (const void *key1, const void *key2);
|
||||
|
||||
unsigned int hashf_string (const void *key);
|
||||
int cmpf_string (const void *key1, const void *key2);
|
||||
|
||||
#endif /* __GENHASH_H__ */
|
|
@ -1,20 +1,24 @@
|
|||
|
||||
AM_CFLAGS = @ADD_CFLAGS@
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/libasn1parser \
|
||||
-I$(top_srcdir)/libasn1fix
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/libasn1common \
|
||||
-I$(top_srcdir)/libasn1parser \
|
||||
-I$(top_srcdir)/libasn1print \
|
||||
-I$(top_srcdir)/libasn1fix
|
||||
|
||||
noinst_LTLIBRARIES = libasn1compiler.la
|
||||
|
||||
libasn1compiler_la_SOURCES = \
|
||||
asn1compiler.c asn1compiler.h \
|
||||
asn1c_misc.c asn1c_misc.h \
|
||||
asn1c_out.c asn1c_out.h \
|
||||
asn1c_lang.c asn1c_lang.h \
|
||||
asn1c_save.c asn1c_save.h \
|
||||
asn1c_C.c asn1c_C.h \
|
||||
asn1c_constraint.c asn1c_constraint.h \
|
||||
asn1c_compat.c asn1c_compat.h \
|
||||
asn1c_fdeps.c asn1c_fdeps.h \
|
||||
asn1c_internal.h
|
||||
libasn1compiler_la_SOURCES = \
|
||||
asn1compiler.c asn1compiler.h \
|
||||
asn1c_misc.c asn1c_misc.h \
|
||||
asn1c_out.c asn1c_out.h \
|
||||
asn1c_lang.c asn1c_lang.h \
|
||||
asn1c_naming.c asn1c_naming.h \
|
||||
asn1c_save.c asn1c_save.h \
|
||||
asn1c_C.c asn1c_C.h \
|
||||
asn1c_constraint.c asn1c_constraint.h \
|
||||
asn1c_compat.c asn1c_compat.h \
|
||||
asn1c_ioc.c asn1c_ioc.h \
|
||||
asn1c_fdeps.c asn1c_fdeps.h \
|
||||
asn1c_internal.h
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,10 +1,6 @@
|
|||
#include "asn1c_internal.h"
|
||||
#include "asn1c_compat.h"
|
||||
|
||||
#ifndef MAXPATHLEN
|
||||
#define MAXPATHLEN 1024
|
||||
#endif
|
||||
|
||||
/* Normally file permissions are (DEFFILEMODE & ~umask(2)) */
|
||||
#ifndef DEFFILEMODE /* Normally in <sys/stat.h> */
|
||||
|
||||
|
@ -40,13 +36,13 @@ int mkstemp(char *template) {
|
|||
#endif
|
||||
|
||||
FILE *
|
||||
asn1c_open_file(const char *name, const char *ext, char **opt_tmpname) {
|
||||
asn1c_open_file(const char *destdir, const char *name, const char *ext,
|
||||
char **opt_tmpname) {
|
||||
char fname[PATH_MAX];
|
||||
int created = 1;
|
||||
#ifndef _WIN32
|
||||
struct stat sb;
|
||||
#endif
|
||||
char *fname;
|
||||
size_t len;
|
||||
FILE *fp;
|
||||
int ret;
|
||||
int fd;
|
||||
|
@ -54,20 +50,20 @@ asn1c_open_file(const char *name, const char *ext, char **opt_tmpname) {
|
|||
/*
|
||||
* Compute filenames.
|
||||
*/
|
||||
len = strlen(name) + strlen(ext) + sizeof(".XXXXXX");
|
||||
fname = alloca(len);
|
||||
ret = snprintf(fname, len, "%s%s%s", name, ext,
|
||||
opt_tmpname ? ".XXXXXX" : "");
|
||||
assert(ret > 0 && ret < (ssize_t)len);
|
||||
ret = snprintf(fname, sizeof(fname), "%s%s%s%s", destdir ? destdir : "",
|
||||
name, ext, opt_tmpname ? ".XXXXXX" : "");
|
||||
assert(ret > 0 && ret < (ssize_t)sizeof(fname));
|
||||
|
||||
if(opt_tmpname) {
|
||||
if(opt_tmpname) {
|
||||
/*
|
||||
* Create temporary file.
|
||||
*/
|
||||
fd = mkstemp(fname);
|
||||
#ifndef _WIN32
|
||||
/* fchmod() does not respect umask */
|
||||
(void)fchmod(fd, REASONABLE_FILE_MODE);
|
||||
if(fd != -1) {
|
||||
/* fchmod() does not respect umask */
|
||||
(void)fchmod(fd, REASONABLE_FILE_MODE);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
/*
|
||||
|
@ -80,8 +76,14 @@ asn1c_open_file(const char *name, const char *ext, char **opt_tmpname) {
|
|||
}
|
||||
}
|
||||
if(fd == -1) {
|
||||
perror(fname);
|
||||
return NULL;
|
||||
struct stat st;
|
||||
if(destdir && stat(destdir, &st) == -1) {
|
||||
fprintf(stderr, "%s: No such directory\n", destdir);
|
||||
return NULL;
|
||||
} else {
|
||||
perror(fname);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
|
@ -130,16 +132,21 @@ asn1c_open_file(const char *name, const char *ext, char **opt_tmpname) {
|
|||
return fp;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
a1c_basename(const char *path) {
|
||||
static char strbuf[MAXPATHLEN];
|
||||
const char *
|
||||
a1c_basename(const char *path, const char *destdir) {
|
||||
static char strbuf[PATH_MAX];
|
||||
const char *pend;
|
||||
const char *name;
|
||||
char *sbuf = strbuf;
|
||||
|
||||
if(destdir) {
|
||||
strncpy(strbuf, destdir, PATH_MAX - 1);
|
||||
strbuf[PATH_MAX - 1] = '\0';
|
||||
sbuf = strbuf + strlen(strbuf);
|
||||
}
|
||||
pend = path + strlen(path);
|
||||
if(pend == path) {
|
||||
strcpy(strbuf, ".");
|
||||
strcpy(sbuf, ".");
|
||||
return strbuf;
|
||||
}
|
||||
|
||||
|
@ -147,7 +154,7 @@ a1c_basename(const char *path) {
|
|||
for(pend--; pend > path && *pend == '/'; pend--);
|
||||
|
||||
if(pend == path && *path == '/') {
|
||||
strcpy(strbuf, "/");
|
||||
strcpy(sbuf, "/");
|
||||
return strbuf;
|
||||
}
|
||||
|
||||
|
@ -158,16 +165,16 @@ a1c_basename(const char *path) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
memcpy(strbuf, name, pend - name + 1);
|
||||
strbuf[pend - name + 1] = '\0';
|
||||
memcpy(sbuf, name, pend - name + 1);
|
||||
sbuf[pend - name + 1] = '\0';
|
||||
|
||||
return strbuf;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
const char *
|
||||
a1c_dirname(const char *path) {
|
||||
static char strbuf[MAXPATHLEN];
|
||||
static char strbuf[PATH_MAX];
|
||||
const char *pend;
|
||||
const char *last = 0;
|
||||
int in_slash = 0;
|
||||
|
|
|
@ -7,14 +7,14 @@
|
|||
* its name returned in (*opt_tmpname).
|
||||
* The (*opt_tmpname) should then be subsequently freed by free(3).
|
||||
*/
|
||||
FILE *asn1c_open_file(const char *base_part, const char *extension,
|
||||
FILE *asn1c_open_file(const char *destdir, const char *base_part, const char *extension,
|
||||
char **opt_tmpname);
|
||||
|
||||
/*
|
||||
* Obtain base name and directory name of a path.
|
||||
* Some systems have them in <libgen.h> as dirname(3) and basename(3).
|
||||
*/
|
||||
char *a1c_basename(const char *path);
|
||||
char *a1c_dirname(const char *path);
|
||||
const char *a1c_basename(const char *path, const char* destdir);
|
||||
const char *a1c_dirname(const char *path);
|
||||
|
||||
#endif /* ASN1C_COMPAT_H */
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "asn1c_constraint.h"
|
||||
#include "asn1c_misc.h"
|
||||
#include "asn1c_out.h"
|
||||
#include "asn1c_naming.h"
|
||||
|
||||
#include <asn1fix_crange.h> /* constraint groker from libasn1fix */
|
||||
#include <asn1fix_export.h> /* other exportables from libasn1fix */
|
||||
|
@ -11,17 +12,20 @@ static int emit_alphabet_check_loop(arg_t *arg, asn1cnst_range_t *range);
|
|||
static int emit_value_determination_code(arg_t *arg, asn1p_expr_type_e etype, asn1cnst_range_t *r_value);
|
||||
static int emit_size_determination_code(arg_t *arg, asn1p_expr_type_e etype);
|
||||
static asn1p_expr_type_e _find_terminal_type(arg_t *arg);
|
||||
static int emit_range_comparison_code(arg_t *arg, asn1cnst_range_t *range, const char *varname, asn1c_integer_t natural_start, asn1c_integer_t natural_stop);
|
||||
static int native_long_sign(asn1cnst_range_t *r); /* -1, 0, 1 */
|
||||
static abuf *emit_range_comparison_code(asn1cnst_range_t *range,
|
||||
const char *varname,
|
||||
asn1c_integer_t natural_start,
|
||||
asn1c_integer_t natural_stop);
|
||||
static int native_long_sign(arg_t *arg, asn1cnst_range_t *r); /* -1, 0, 1 */
|
||||
|
||||
static int
|
||||
ulong_optimization(asn1p_expr_type_e etype, asn1cnst_range_t *r_size,
|
||||
ulong_optimization(arg_t *arg, asn1p_expr_type_e etype, asn1cnst_range_t *r_size,
|
||||
asn1cnst_range_t *r_value)
|
||||
{
|
||||
return (!r_size && r_value
|
||||
&& (etype == ASN_BASIC_INTEGER
|
||||
|| etype == ASN_BASIC_ENUMERATED)
|
||||
&& native_long_sign(r_value) == 0);
|
||||
&& native_long_sign(arg, r_value) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -31,10 +35,11 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
|
|||
asn1p_expr_t *expr = arg->expr;
|
||||
asn1p_expr_type_e etype;
|
||||
asn1p_constraint_t *ct;
|
||||
int got_something = 0;
|
||||
int alphabet_table_compiled;
|
||||
int produce_st = 0;
|
||||
int ulong_optimize = 0;
|
||||
int value_unsigned = 0;
|
||||
int ret = 0;
|
||||
|
||||
ct = expr->combined_constraints;
|
||||
if(ct == NULL)
|
||||
|
@ -42,8 +47,8 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
|
|||
|
||||
etype = _find_terminal_type(arg);
|
||||
|
||||
r_value=asn1constraint_compute_PER_range(etype, ct, ACT_EL_RANGE,0,0,0);
|
||||
r_size =asn1constraint_compute_PER_range(etype, ct, ACT_CT_SIZE, 0,0,0);
|
||||
r_value=asn1constraint_compute_constraint_range(expr->Identifier, etype, ct, ACT_EL_RANGE,0,0,0);
|
||||
r_size =asn1constraint_compute_constraint_range(expr->Identifier, etype, ct, ACT_CT_SIZE, 0,0,0);
|
||||
if(r_value) {
|
||||
if(r_value->incompatible
|
||||
|| r_value->empty_constraint
|
||||
|
@ -78,8 +83,9 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
|
|||
produce_st = 1;
|
||||
break;
|
||||
case ASN_BASIC_REAL:
|
||||
if((arg->flags & A1C_USE_WIDE_TYPES))
|
||||
produce_st = 1;
|
||||
if((arg->flags & A1C_USE_WIDE_TYPES)
|
||||
&& asn1c_REAL_fits(arg, arg->expr) == RL_NOTFIT)
|
||||
produce_st = 1;
|
||||
break;
|
||||
case ASN_BASIC_BIT_STRING:
|
||||
case ASN_BASIC_OCTET_STRING:
|
||||
|
@ -91,7 +97,7 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
|
|||
break;
|
||||
}
|
||||
if(produce_st) {
|
||||
char *tname = asn1c_type_name(arg, arg->expr, TNF_SAFE);
|
||||
const char *tname = asn1c_type_name(arg, arg->expr, TNF_SAFE);
|
||||
OUT("const %s_t *st = (const %s_t *)sptr;\n", tname, tname);
|
||||
}
|
||||
|
||||
|
@ -103,9 +109,10 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
|
|||
switch(etype) {
|
||||
case ASN_BASIC_INTEGER:
|
||||
case ASN_BASIC_ENUMERATED:
|
||||
if(native_long_sign(r_value) >= 0) {
|
||||
ulong_optimize = ulong_optimization(etype, r_size, r_value);
|
||||
if(native_long_sign(arg, r_value) >= 0) {
|
||||
ulong_optimize = ulong_optimization(arg, etype, r_size, r_value);
|
||||
if(!ulong_optimize) {
|
||||
value_unsigned = 1;
|
||||
OUT("unsigned long value;\n");
|
||||
}
|
||||
} else {
|
||||
|
@ -113,7 +120,7 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
|
|||
}
|
||||
break;
|
||||
case ASN_BASIC_REAL:
|
||||
OUT("double value;\n");
|
||||
OUT("%s value;\n", c_name(arg).type.constrained_c_name);
|
||||
break;
|
||||
case ASN_BASIC_BOOLEAN:
|
||||
OUT("BOOLEAN_t value;\n");
|
||||
|
@ -158,55 +165,75 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
|
|||
OUT("\n");
|
||||
OUT("/* Constraint check succeeded */\n");
|
||||
OUT("return 0;\n");
|
||||
return 0;
|
||||
goto end;
|
||||
}
|
||||
|
||||
/*
|
||||
* Here is an if() {} else {} consrtaint checking code.
|
||||
*/
|
||||
int got_something = 0;
|
||||
int value_unused = 0;
|
||||
OUT("\n");
|
||||
OUT("if(");
|
||||
INDENT(+1);
|
||||
if(r_size) {
|
||||
if(got_something++) { OUT("\n"); OUT(" && "); }
|
||||
OUT("(");
|
||||
emit_range_comparison_code(arg, r_size, "size", 0, -1);
|
||||
OUT(")");
|
||||
abuf *ab = emit_range_comparison_code(r_size, "size", 0, -1);
|
||||
if(ab->length) {
|
||||
OUT("(%s)", ab->buffer);
|
||||
got_something++;
|
||||
}
|
||||
abuf_free(ab);
|
||||
}
|
||||
if(r_value) {
|
||||
if(got_something++) { OUT("\n"); OUT(" && "); }
|
||||
OUT("(");
|
||||
if(etype == ASN_BASIC_BOOLEAN)
|
||||
emit_range_comparison_code(arg, r_value,
|
||||
"value", 0, 1);
|
||||
else
|
||||
emit_range_comparison_code(arg, r_value,
|
||||
"value", -1, -1);
|
||||
OUT(")");
|
||||
if(got_something) { OUT("\n"); OUT(" && "); }
|
||||
abuf *ab;
|
||||
if(etype == ASN_BASIC_BOOLEAN)
|
||||
ab = emit_range_comparison_code(r_value, "value", 0, 1);
|
||||
else
|
||||
ab = emit_range_comparison_code(r_value, "value",
|
||||
value_unsigned ? 0 : -1, -1);
|
||||
if(ab->length) {
|
||||
OUT("(%s)", ab->buffer);
|
||||
got_something++;
|
||||
} else {
|
||||
value_unused = 1;
|
||||
}
|
||||
abuf_free(ab);
|
||||
}
|
||||
if(alphabet_table_compiled) {
|
||||
if(got_something++) { OUT("\n"); OUT(" && "); }
|
||||
if(got_something) { OUT("\n"); OUT(" && "); }
|
||||
OUT("!check_permitted_alphabet_%d(%s)",
|
||||
arg->expr->_type_unique_index,
|
||||
produce_st ? "st" : "sptr");
|
||||
}
|
||||
got_something++;
|
||||
}
|
||||
if(!got_something) {
|
||||
OUT("1 /* No applicable constraints whatsoever */");
|
||||
OUT(") {\n");
|
||||
INDENT(-1);
|
||||
if(produce_st) {
|
||||
INDENTED(OUT("(void)st; /* Unused variable */\n"));
|
||||
}
|
||||
if(value_unused) {
|
||||
INDENTED(OUT("(void)value; /* Unused variable */\n"));
|
||||
}
|
||||
INDENTED(OUT("/* Nothing is here. See below */\n"));
|
||||
OUT("}\n");
|
||||
OUT("\n");
|
||||
return 1;
|
||||
ret = 1;
|
||||
goto end;
|
||||
}
|
||||
INDENT(-1);
|
||||
OUT(") {\n");
|
||||
INDENT(+1);
|
||||
switch(etype) {
|
||||
case ASN_CONSTR_SEQUENCE_OF:
|
||||
OUT("/* Perform validation of the inner elements */\n");
|
||||
OUT("return SEQUENCE_OF_constraint(td, sptr, ctfailcb, app_key);\n");
|
||||
break;
|
||||
case ASN_CONSTR_SET_OF:
|
||||
OUT("/* Perform validation of the inner elements */\n");
|
||||
OUT("return td->check_constraints(td, sptr, ctfailcb, app_key);\n");
|
||||
OUT("return SET_OF_constraint(td, sptr, ctfailcb, app_key);\n");
|
||||
break;
|
||||
default:
|
||||
OUT("/* Constraint check succeeded */\n");
|
||||
|
@ -222,7 +249,11 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
|
|||
INDENT(-1);
|
||||
OUT("}\n");
|
||||
|
||||
return 0;
|
||||
end:
|
||||
if (r_value) asn1constraint_range_free(r_value);
|
||||
if (r_size) asn1constraint_range_free(r_size);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -242,7 +273,7 @@ asn1c_emit_constraint_tables(arg_t *arg, int got_size) {
|
|||
|
||||
etype = _find_terminal_type(arg);
|
||||
|
||||
range = asn1constraint_compute_PER_range(etype, ct, ACT_CT_FROM, 0,0,0);
|
||||
range = asn1constraint_compute_constraint_range(arg->expr->Identifier, etype, ct, ACT_CT_FROM, 0,0,0);
|
||||
if(!range) return 0;
|
||||
|
||||
if(range->incompatible
|
||||
|
@ -261,6 +292,7 @@ asn1c_emit_constraint_tables(arg_t *arg, int got_size) {
|
|||
*/
|
||||
assert(range->el_count == 0);
|
||||
/* The full range is specified. Ignore it. */
|
||||
asn1constraint_range_free(range);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -417,9 +449,9 @@ static int
|
|||
emit_alphabet_check_loop(arg_t *arg, asn1cnst_range_t *range) {
|
||||
asn1c_integer_t natural_stop;
|
||||
asn1p_expr_t *terminal;
|
||||
char *tname;
|
||||
const char *tname;
|
||||
|
||||
terminal = asn1f_find_terminal_type_ex(arg->asn, arg->expr);
|
||||
terminal = asn1f_find_terminal_type_ex(arg->asn, arg->ns, arg->expr);
|
||||
if(terminal) {
|
||||
OUT("/* The underlying type is %s */\n",
|
||||
ASN_EXPR_TYPE2STR(terminal->expr_type));
|
||||
|
@ -479,9 +511,12 @@ emit_alphabet_check_loop(arg_t *arg, asn1cnst_range_t *range) {
|
|||
}
|
||||
|
||||
if(range) {
|
||||
OUT("if(!(");
|
||||
emit_range_comparison_code(arg, range, "cv", 0, natural_stop);
|
||||
OUT(")) return -1;\n");
|
||||
abuf *ab = emit_range_comparison_code(range, "cv", 0, natural_stop);
|
||||
if(ab->length) {
|
||||
OUT("if(!(%s)) return -1;\n", ab->buffer);
|
||||
} else {
|
||||
OUT("(void)cv; /* Unused variable */\n");
|
||||
}
|
||||
} else {
|
||||
OUT("if(!table[cv]) return -1;\n");
|
||||
}
|
||||
|
@ -492,58 +527,68 @@ emit_alphabet_check_loop(arg_t *arg, asn1cnst_range_t *range) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
emit_range_comparison_code(arg_t *arg, asn1cnst_range_t *range, const char *varname, asn1c_integer_t natural_start, asn1c_integer_t natural_stop) {
|
||||
int ignore_left;
|
||||
int ignore_right;
|
||||
int generated_something = 0;
|
||||
int i;
|
||||
static void
|
||||
abuf_oint(abuf *ab, asn1c_integer_t v) {
|
||||
if(v == (-2147483647L - 1)) {
|
||||
abuf_printf(ab, "(-2147483647L - 1)");
|
||||
} else {
|
||||
abuf_printf(ab, "%s", asn1p_itoa(v));
|
||||
}
|
||||
}
|
||||
|
||||
for(i = -1; i < range->el_count; i++) {
|
||||
asn1cnst_range_t *r;
|
||||
if(i == -1) {
|
||||
if(range->el_count) continue;
|
||||
r = range;
|
||||
} else {
|
||||
if(i) OUT(" || ");
|
||||
r = range->elements[i];
|
||||
}
|
||||
static abuf *
|
||||
emit_range_comparison_code(asn1cnst_range_t *range, const char *varname,
|
||||
asn1c_integer_t natural_start,
|
||||
asn1c_integer_t natural_stop) {
|
||||
abuf *ab = abuf_new();
|
||||
|
||||
if(r != range) OUT("(");
|
||||
if(range->el_count == 0) {
|
||||
int ignore_left =
|
||||
(range->left.type == ARE_MIN)
|
||||
|| (natural_start != -1 && range->left.value <= natural_start);
|
||||
int ignore_right =
|
||||
(range->right.type == ARE_MAX)
|
||||
|| (natural_stop != -1 && range->right.value >= natural_stop);
|
||||
|
||||
ignore_left = (r->left.type == ARE_MIN)
|
||||
|| (natural_start != -1
|
||||
&& r->left.value <= natural_start);
|
||||
ignore_right = (r->right.type == ARE_MAX)
|
||||
|| (natural_stop != -1
|
||||
&& r->right.value >= natural_stop);
|
||||
if(ignore_left && ignore_right) {
|
||||
OUT("1 /* Constraint matches natural range of %s */",
|
||||
varname);
|
||||
continue;
|
||||
}
|
||||
if(ignore_left && ignore_right) {
|
||||
/* Empty constraint comparison */
|
||||
} else if(ignore_left) {
|
||||
abuf_printf(ab, "%s <= ", varname);
|
||||
abuf_oint(ab, range->right.value);
|
||||
} else if(ignore_right) {
|
||||
abuf_printf(ab, "%s >= ", varname);
|
||||
abuf_oint(ab, range->left.value);
|
||||
} else if(range->left.value == range->right.value) {
|
||||
abuf_printf(ab, "%s == ", varname);
|
||||
abuf_oint(ab, range->right.value);
|
||||
} else {
|
||||
abuf_printf(ab, "%s >= ", varname);
|
||||
abuf_oint(ab, range->left.value);
|
||||
abuf_printf(ab, " && ");
|
||||
abuf_printf(ab, "%s <= ", varname);
|
||||
abuf_oint(ab, range->right.value);
|
||||
}
|
||||
} else {
|
||||
for(int i = 0; i < range->el_count; i++) {
|
||||
asn1cnst_range_t *r = range->elements[i];
|
||||
|
||||
if(ignore_left) {
|
||||
OUT("%s <= ", varname);
|
||||
OINT(r->right.value);
|
||||
} else if(ignore_right) {
|
||||
OUT("%s >= ", varname);
|
||||
OINT(r->left.value);
|
||||
} else if(r->left.value == r->right.value) {
|
||||
OUT("%s == ", varname);
|
||||
OINT(r->right.value);
|
||||
} else {
|
||||
OUT("%s >= ", varname);
|
||||
OINT(r->left.value);
|
||||
OUT(" && ");
|
||||
OUT("%s <= ", varname);
|
||||
OINT(r->right.value);
|
||||
}
|
||||
if(r != range) OUT(")");
|
||||
generated_something = 1;
|
||||
}
|
||||
abuf *rec = emit_range_comparison_code(r, varname, natural_start,
|
||||
natural_stop);
|
||||
if(rec->length) {
|
||||
if(ab->length) {
|
||||
abuf_str(ab, " || ");
|
||||
}
|
||||
abuf_str(ab, "(");
|
||||
abuf_buf(ab, rec);
|
||||
abuf_str(ab, ")");
|
||||
} else {
|
||||
/* Ignore this part */
|
||||
}
|
||||
abuf_free(rec);
|
||||
}
|
||||
}
|
||||
|
||||
return generated_something;
|
||||
return ab;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -633,7 +678,7 @@ emit_value_determination_code(arg_t *arg, asn1p_expr_type_e etype, asn1cnst_rang
|
|||
break;
|
||||
}
|
||||
|
||||
if(native_long_sign(r_value) >= 0) {
|
||||
if(native_long_sign(arg, r_value) >= 0) {
|
||||
/* Special case for treating unsigned longs */
|
||||
OUT("if(asn_INTEGER2ulong(st, &value)) {\n");
|
||||
INDENT(+1);
|
||||
|
@ -666,7 +711,7 @@ emit_value_determination_code(arg_t *arg, asn1p_expr_type_e etype, asn1cnst_rang
|
|||
INDENT(-1);
|
||||
OUT("}\n");
|
||||
} else {
|
||||
OUT("value = *(const double *)sptr;\n");
|
||||
OUT("value = *(const %s *)sptr;\n", c_name(arg).type.c_name);
|
||||
}
|
||||
break;
|
||||
case ASN_BASIC_BOOLEAN:
|
||||
|
@ -694,13 +739,18 @@ emit_value_determination_code(arg_t *arg, asn1p_expr_type_e etype, asn1cnst_rang
|
|||
static asn1p_expr_type_e
|
||||
_find_terminal_type(arg_t *arg) {
|
||||
asn1p_expr_t *expr;
|
||||
expr = asn1f_find_terminal_type_ex(arg->asn, arg->expr);
|
||||
expr = asn1f_find_terminal_type_ex(arg->asn, arg->ns, arg->expr);
|
||||
if(expr) return expr->expr_type;
|
||||
return A1TC_INVALID;
|
||||
}
|
||||
|
||||
static int
|
||||
native_long_sign(asn1cnst_range_t *r) {
|
||||
native_long_sign(arg_t *arg, asn1cnst_range_t *r) {
|
||||
if(!(arg->flags & A1C_USE_WIDE_TYPES) && r->left.type == ARE_VALUE
|
||||
&& r->left.value >= 0 && r->left.value <= 2147483647
|
||||
&& r->right.type == ARE_MAX) {
|
||||
return 1;
|
||||
}
|
||||
if(r->left.type == ARE_VALUE
|
||||
&& r->left.value >= 0
|
||||
&& r->right.type == ARE_VALUE
|
||||
|
|
|
@ -1,77 +1,84 @@
|
|||
#include "asn1c_internal.h"
|
||||
#include "asn1c_fdeps.h"
|
||||
|
||||
static asn1c_fdeps_t *asn1c_new_dep(const char *filename);
|
||||
static int asn1c_dep_add(asn1c_fdeps_t *deps, asn1c_fdeps_t *d);
|
||||
static asn1c_dep_filename *asn1c_dep_filename_new(const char *filename);
|
||||
static void asn1c_dep_add(asn1c_dep_chain *dlist, const char *filename,
|
||||
int lineno, int column);
|
||||
static asn1c_dep_chain *asn1c_dep_chain_new(void);
|
||||
|
||||
int
|
||||
asn1c_activate_dependency(asn1c_fdeps_t *deps, asn1c_fdeps_t *cur, const char *data) {
|
||||
const char *fname;
|
||||
int i;
|
||||
static asn1c_dep_chain *
|
||||
asn1c_dep_chains_add_new(asn1c_dep_chainset *deps,
|
||||
enum asn1c_dep_section section, int active) {
|
||||
asn1c_dep_chain *dc = asn1c_dep_chain_new();
|
||||
asn1c_tagged_dep_chain *tc = calloc(1, sizeof(*tc));
|
||||
tc->chain = dc;
|
||||
tc->section = section;
|
||||
tc->activated.active = active;
|
||||
|
||||
if(!deps || !data || !*data)
|
||||
return 0;
|
||||
if(!cur) cur = deps;
|
||||
deps->chains = realloc(deps->chains,
|
||||
sizeof(deps->chains[0]) * (deps->chains_count + 1));
|
||||
assert(deps->chains);
|
||||
deps->chains[deps->chains_count] = tc;
|
||||
deps->chains_count++;
|
||||
|
||||
if(cur->usage > FDEP_NOTUSED)
|
||||
return 1; /* Already activated */
|
||||
|
||||
fname = data;
|
||||
if(*data == '#') {
|
||||
const char *start = data;
|
||||
const char *end = 0;
|
||||
|
||||
start = strchr(data, '<');
|
||||
if(start) {
|
||||
start++;
|
||||
end = strchr(start, '>');
|
||||
} else if((start = strchr(data, '\"'))) {
|
||||
start++;
|
||||
end = strchr(start, '\"');
|
||||
}
|
||||
if(end) {
|
||||
char *p = alloca((end - start) + 1);
|
||||
memcpy(p, start, end - start);
|
||||
p[end-start] = '\0';
|
||||
fname = p;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(cur->filename && strcmp(cur->filename, fname) == 0) {
|
||||
cur->usage = FDEP_REFERRED;
|
||||
|
||||
/* Activate subdependencies */
|
||||
for(i = 0; i < cur->el_count; i++) {
|
||||
asn1c_activate_dependency(deps,
|
||||
cur->elements[i],
|
||||
cur->elements[i]->filename);
|
||||
}
|
||||
|
||||
/*
|
||||
* This might be a link to someplace else.
|
||||
*/
|
||||
return asn1c_activate_dependency(deps, NULL, fname);
|
||||
} else {
|
||||
for(i = 0; i < cur->el_count; i++) {
|
||||
asn1c_activate_dependency(deps,
|
||||
cur->elements[i], fname);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return dc;
|
||||
}
|
||||
|
||||
asn1c_fdeps_t *
|
||||
void
|
||||
asn1c_activate_dependency(asn1c_dep_chainset *deps, const char *data,
|
||||
const char *by) {
|
||||
char fname_scratch[PATH_MAX];
|
||||
|
||||
if(!deps || !data || !*data) {
|
||||
return;
|
||||
}
|
||||
|
||||
assert(deps->chains_count);
|
||||
|
||||
const char *fname = data;
|
||||
if(*data == '#') {
|
||||
const char *start = data;
|
||||
const char *end = 0;
|
||||
|
||||
start = strchr(data, '<');
|
||||
if(start) {
|
||||
start++;
|
||||
end = strchr(start, '>');
|
||||
} else if((start = strchr(data, '\"'))) {
|
||||
start++;
|
||||
end = strchr(start, '\"');
|
||||
}
|
||||
if(end) {
|
||||
assert((end-start) + 1 < (ssize_t)sizeof(fname_scratch));
|
||||
memcpy(fname_scratch, start, end - start);
|
||||
fname_scratch[end-start] = '\0';
|
||||
fname = fname_scratch;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for(size_t i = 0; i < deps->chains_count; i++) {
|
||||
asn1c_tagged_dep_chain *ch = deps->chains[i];
|
||||
if(!ch->activated.active && ch->chain->deps_count > 0
|
||||
&& strcmp(ch->chain->deps[0]->filename, fname) == 0) {
|
||||
ch->activated.by = strdup(by);
|
||||
ch->activated.active = 1;
|
||||
|
||||
for(size_t j = 0; j < ch->chain->deps_count; j++) {
|
||||
asn1c_activate_dependency(deps, ch->chain->deps[j]->filename,
|
||||
by);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
asn1c_dep_chainset *
|
||||
asn1c_read_file_dependencies(arg_t *arg, const char *datadir) {
|
||||
char buf[4096];
|
||||
asn1c_fdeps_t *deps;
|
||||
asn1c_fdeps_t *cur;
|
||||
asn1c_dep_chainset *deps;
|
||||
FILE *f;
|
||||
enum fdep_usage special_section = FDEP_NOTUSED;
|
||||
|
||||
(void)arg;
|
||||
int lineno = 0;
|
||||
|
||||
if(!datadir || strlen(datadir) > sizeof(buf) / 2) {
|
||||
errno = EINVAL;
|
||||
|
@ -83,115 +90,162 @@ asn1c_read_file_dependencies(arg_t *arg, const char *datadir) {
|
|||
f = fopen(buf, "r");
|
||||
if(!f) return NULL;
|
||||
|
||||
deps = asn1c_new_dep(0);
|
||||
deps = calloc(1, sizeof(*deps));
|
||||
assert(deps);
|
||||
enum asn1c_dep_section section = FDEP_COMMON_FILES;
|
||||
int activate = 0;
|
||||
|
||||
while(fgets(buf, sizeof(buf), f)) {
|
||||
while(fgets(buf, sizeof(buf), f)) {
|
||||
char *p = strchr(buf, '#');
|
||||
if(p) *p = '\0'; /* Remove comments */
|
||||
|
||||
cur = deps;
|
||||
for(p = strtok(buf, " \t\r\n"); p;
|
||||
lineno++;
|
||||
|
||||
asn1c_dep_chain *dc = asn1c_dep_chains_add_new(deps, section, activate);
|
||||
|
||||
for(p = strtok(buf, " \t\r\n"); p;
|
||||
p = strtok(NULL, " \t\r\n")) {
|
||||
asn1c_fdeps_t *d;
|
||||
|
||||
/*
|
||||
* Special "prefix" section.
|
||||
*/
|
||||
if(strchr(p, ':')) {
|
||||
special_section = FDEP_IGNORE;
|
||||
if(strcmp(p, "COMMON-FILES:") == 0) {
|
||||
special_section = FDEP_COMMON_FILES;
|
||||
section = FDEP_COMMON_FILES;
|
||||
activate = 1;
|
||||
} else if(strcmp(p, "CONVERTER:") == 0) {
|
||||
special_section = FDEP_CONVERTER;
|
||||
activate = 1;
|
||||
section = FDEP_CONVERTER;
|
||||
} else if((arg->flags & A1C_GEN_OER)
|
||||
&& strcmp(p, "CODEC-OER:") == 0) {
|
||||
activate = 0;
|
||||
section = FDEP_CODEC_OER;
|
||||
} else if((arg->flags & A1C_GEN_PER)
|
||||
&& strcmp(p, "CODEC-PER:") == 0) {
|
||||
special_section = FDEP_CODEC_PER;
|
||||
}
|
||||
break;
|
||||
activate = 0;
|
||||
section = FDEP_CODEC_PER;
|
||||
} else {
|
||||
section = FDEP_IGNORE;
|
||||
activate = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(special_section == FDEP_IGNORE)
|
||||
continue;
|
||||
|
||||
d = asn1c_new_dep(p);
|
||||
d->usage = special_section;
|
||||
|
||||
if(asn1c_dep_add(cur, d) == 1)
|
||||
cur = d;
|
||||
}
|
||||
asn1c_dep_add(dc, p, lineno, p - buf);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
|
||||
/* A single filename by itself means that we should include that */
|
||||
for(size_t i = 0; i < deps->chains_count; i++) {
|
||||
asn1c_tagged_dep_chain *ch = deps->chains[i];
|
||||
if(!ch->activated.active && ch->chain->deps_count == 1) {
|
||||
asn1c_activate_dependency(deps, ch->chain->deps[0]->filename,
|
||||
"implicit");
|
||||
}
|
||||
}
|
||||
|
||||
return deps;
|
||||
}
|
||||
|
||||
static asn1c_fdeps_t *
|
||||
asn1c_new_dep(const char *filename) {
|
||||
asn1c_fdeps_t *d;
|
||||
static asn1c_dep_filename *
|
||||
asn1c_dep_filename_new(const char *filename) {
|
||||
asn1c_dep_filename *d;
|
||||
|
||||
d = calloc(1, sizeof(*d));
|
||||
if(filename) {
|
||||
d->filename = strdup(filename);
|
||||
if(!d->filename) return NULL;
|
||||
}
|
||||
assert(filename);
|
||||
|
||||
d = calloc(1, sizeof(*d));
|
||||
assert(d);
|
||||
d->filename = strdup(filename);
|
||||
assert(d->filename);
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
static int
|
||||
asn1c_dep_add(asn1c_fdeps_t *deps, asn1c_fdeps_t *d) {
|
||||
int n;
|
||||
|
||||
/* Check for duplicates */
|
||||
for(n = 0; n < deps->el_count; n++) {
|
||||
if(strcmp(deps->elements[n]->filename, d->filename) == 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(deps->el_count == deps->el_size) {
|
||||
void *p;
|
||||
n = deps->el_size?deps->el_size << 2:16;
|
||||
p = realloc(deps->elements,
|
||||
n * sizeof(deps->elements[0]));
|
||||
assert(p);
|
||||
deps->elements = p;
|
||||
deps->el_size = n;
|
||||
}
|
||||
|
||||
deps->elements[deps->el_count++] = d;
|
||||
return 1;
|
||||
static asn1c_dep_chain *
|
||||
asn1c_dep_chain_new() {
|
||||
return calloc(1, sizeof(asn1c_dep_chain));
|
||||
}
|
||||
|
||||
asn1c_fdeps_t *
|
||||
asn1c_deps_makelist(asn1c_fdeps_t *deps) {
|
||||
asn1c_fdeps_t *dlist;
|
||||
asn1c_fdeps_t *d;
|
||||
int i;
|
||||
static void
|
||||
asn1c_dep_add(asn1c_dep_chain *dlist, const char *filename, int lineno, int column) {
|
||||
asn1c_dep_filename *df = asn1c_dep_filename_new(filename);
|
||||
df->lineno = lineno;
|
||||
df->column = column;
|
||||
|
||||
dlist->deps =
|
||||
realloc(dlist->deps, (dlist->deps_count + 1) * sizeof(dlist->deps[0]));
|
||||
assert(dlist->deps);
|
||||
dlist->deps[dlist->deps_count] = df;
|
||||
dlist->deps_count += 1;
|
||||
}
|
||||
|
||||
static int
|
||||
asn1c_dep_has_filename(const asn1c_dep_chain *dlist, const char *filename) {
|
||||
for(size_t i = 0; i < dlist->deps_count; i++) {
|
||||
if(strcmp(dlist->deps[i]->filename, filename) == 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
asn1c_dep_chain *
|
||||
asn1c_deps_flatten(const asn1c_dep_chainset *deps,
|
||||
enum asn1c_dep_section include_section) {
|
||||
asn1c_dep_chain *dlist;
|
||||
|
||||
if(!deps) {
|
||||
errno = EINVAL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
dlist = asn1c_new_dep(0);
|
||||
dlist = asn1c_dep_chain_new();
|
||||
|
||||
if(deps->filename && deps->usage != FDEP_NOTUSED) {
|
||||
d = asn1c_new_dep(deps->filename);
|
||||
d->usage = deps->usage;
|
||||
asn1c_dep_add(dlist, d);
|
||||
}
|
||||
for(size_t i = 0; i < deps->chains_count; i++) {
|
||||
asn1c_tagged_dep_chain *tc = deps->chains[i];
|
||||
asn1c_dep_chain *dc = tc->chain;
|
||||
|
||||
for(i = 0; i < deps->el_count; i++) {
|
||||
int j;
|
||||
d = asn1c_deps_makelist(deps->elements[i]);
|
||||
assert(!d->filename);
|
||||
for(j = 0; j < d->el_count; j++) {
|
||||
asn1c_dep_add(dlist, d->elements[j]);
|
||||
}
|
||||
}
|
||||
if(!tc->activated.active) {
|
||||
continue;
|
||||
}
|
||||
if((tc->section & include_section) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for(size_t j = 0; j < dc->deps_count; j++) {
|
||||
if(!asn1c_dep_has_filename(dlist, dc->deps[j]->filename)) {
|
||||
asn1c_dep_add(dlist, dc->deps[j]->filename, dc->deps[j]->lineno,
|
||||
dc->deps[j]->column);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dlist;
|
||||
}
|
||||
|
||||
void
|
||||
asn1c_dep_chain_free(asn1c_dep_chain *dc) {
|
||||
if(dc) {
|
||||
for(size_t i = 0; i < dc->deps_count; i++) {
|
||||
asn1c_dep_filename *df = dc->deps[i];
|
||||
free(df->filename);
|
||||
free(df);
|
||||
}
|
||||
free(dc->deps);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
asn1c_dep_chainset_free(asn1c_dep_chainset *deps) {
|
||||
if(deps) {
|
||||
for(size_t i = 0; i < deps->chains_count; i++) {
|
||||
asn1c_dep_chain_free(deps->chains[i]->chain);
|
||||
free(deps->chains[i]->activated.by);
|
||||
free(deps->chains[i]);
|
||||
}
|
||||
free(deps->chains);
|
||||
free(deps);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,29 +1,61 @@
|
|||
#ifndef ASN1C_FDEPS_H
|
||||
#define ASN1C_FDEPS_H
|
||||
|
||||
typedef struct asn1c_fdeps_s {
|
||||
char *filename; /* Or 0, if root. */
|
||||
typedef struct {
|
||||
char *filename;
|
||||
int lineno;
|
||||
int column;
|
||||
} asn1c_dep_filename;
|
||||
|
||||
enum fdep_usage {
|
||||
FDEP_IGNORE = -1, /* Ignore contents of the section */
|
||||
FDEP_NOTUSED = 0,
|
||||
FDEP_REFERRED = 1, /* Dynamic list of dependencies */
|
||||
FDEP_CONVERTER = 2, /* Name of the int main() file */
|
||||
FDEP_COMMON_FILES = 3, /* Section for mandatory dependencies */
|
||||
FDEP_CODEC_PER = 4, /* Use contents only if -gen-PER */
|
||||
} usage; /* Some file refers to it */
|
||||
|
||||
struct asn1c_fdeps_s **elements;
|
||||
int el_size;
|
||||
int el_count;
|
||||
} asn1c_fdeps_t;
|
||||
/*
|
||||
* Format:
|
||||
* <observed-name> [<dependent-name> ...]
|
||||
*/
|
||||
typedef struct {
|
||||
asn1c_dep_filename **deps;
|
||||
size_t deps_count;
|
||||
} asn1c_dep_chain;
|
||||
|
||||
asn1c_fdeps_t *asn1c_read_file_dependencies(arg_t *arg, const char *datadir);
|
||||
/*
|
||||
* A single dependency chain, marked with the usage tag and activation tag.
|
||||
*/
|
||||
typedef struct {
|
||||
enum asn1c_dep_section {
|
||||
FDEP_IGNORE = 0, /* Section is not used */
|
||||
FDEP_DEFAULT = (1 << 1), /* Default dependency list */
|
||||
FDEP_REFERRED = (1 << 2), /* Dynamic list of dependencies */
|
||||
FDEP_CONVERTER = (1 << 3), /* Name of the file with int main() */
|
||||
FDEP_COMMON_FILES = (1 << 4), /* Section for mandatory dependencies */
|
||||
FDEP_CODEC_OER = (1 << 5), /* Use contents only if -gen-OER */
|
||||
FDEP_CODEC_PER = (1 << 6), /* Use contents only if -gen-PER */
|
||||
} section; /* Some file refers to it */
|
||||
|
||||
/* Whether this chain is alive and has to be present in the output */
|
||||
struct {
|
||||
int active;
|
||||
char *by;
|
||||
} activated;
|
||||
|
||||
asn1c_dep_chain *chain;
|
||||
} asn1c_tagged_dep_chain;
|
||||
|
||||
typedef struct {
|
||||
asn1c_tagged_dep_chain **chains;
|
||||
size_t chains_count;
|
||||
} asn1c_dep_chainset;
|
||||
|
||||
asn1c_dep_chainset *asn1c_read_file_dependencies(arg_t *arg,
|
||||
const char *datadir);
|
||||
|
||||
/* Data may be a filename or an "#include <>" string. */
|
||||
int asn1c_activate_dependency(asn1c_fdeps_t *deps, asn1c_fdeps_t *cur,
|
||||
const char *data);
|
||||
void asn1c_activate_dependency(asn1c_dep_chainset *deps, const char *data,
|
||||
const char *by);
|
||||
|
||||
asn1c_fdeps_t *asn1c_deps_makelist(asn1c_fdeps_t *deps);
|
||||
asn1c_dep_chain *asn1c_deps_flatten(const asn1c_dep_chainset *deps,
|
||||
enum asn1c_dep_section);
|
||||
|
||||
void asn1c_dep_chain_free(asn1c_dep_chain *);
|
||||
void asn1c_dep_chainset_free(asn1c_dep_chainset *);
|
||||
|
||||
#endif /* ASN1C_FDEPS_H */
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <string.h> /* for strlen(3) and memset(3) */
|
||||
#include <ctype.h> /* for isalnum(3) */
|
||||
#include <sys/types.h> /* for fstat(2) */
|
||||
#include <limits.h> /* for PATH_MAX */
|
||||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
@ -22,6 +23,10 @@
|
|||
#include <unistd.h> /* for unlink(2) */
|
||||
#endif
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 1024
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#include <malloc.h>
|
||||
|
@ -35,11 +40,10 @@
|
|||
#endif
|
||||
#include <fcntl.h> /* for open(2) */
|
||||
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h> /* For MAXPATHLEN */
|
||||
#endif
|
||||
|
||||
#include "asn1compiler.h"
|
||||
#include "asn1_namespace.h"
|
||||
|
||||
struct asn1c_ioc_table_and_objset_s;
|
||||
|
||||
typedef struct arg_s {
|
||||
|
||||
|
@ -47,14 +51,15 @@ typedef struct arg_s {
|
|||
|
||||
void (*logger_cb)(int _severity, const char *fmt, ...);
|
||||
|
||||
int (*default_cb)(struct arg_s *);
|
||||
int (*default_cb)(struct arg_s *, const struct asn1c_ioc_table_and_objset_s *opt);
|
||||
|
||||
struct compiler_streams *target;
|
||||
|
||||
asn1p_t *asn;
|
||||
asn1p_expr_t *expr;
|
||||
asn1p_t *asn;
|
||||
asn1_namespace_t *ns;
|
||||
asn1p_expr_t *expr;
|
||||
|
||||
int embed;
|
||||
int embed;
|
||||
} arg_t;
|
||||
|
||||
/*
|
||||
|
|
|
@ -0,0 +1,292 @@
|
|||
#include "asn1c_internal.h"
|
||||
#include "asn1c_ioc.h"
|
||||
#include "asn1c_out.h"
|
||||
#include "asn1c_misc.h"
|
||||
#include <asn1fix_export.h>
|
||||
#include <asn1print.h>
|
||||
|
||||
#define MKID(expr) asn1c_make_identifier(0, (expr), 0)
|
||||
|
||||
/*
|
||||
* Given the table constraint or component relation constraint
|
||||
* ({ObjectSetName}{...}) returns "ObjectSetName" as a reference.
|
||||
*/
|
||||
const asn1p_ref_t *
|
||||
asn1c_get_information_object_set_reference_from_constraint(arg_t *arg,
|
||||
const asn1p_constraint_t *ct) {
|
||||
|
||||
if(!ct) return NULL;
|
||||
assert(ct->type == ACT_CA_CRC);
|
||||
assert(ct->el_count >= 1);
|
||||
|
||||
DEBUG("Component Relation Constraint: %s", asn1p_constraint_string(ct));
|
||||
|
||||
assert(ct->elements[0]->type == ACT_EL_VALUE);
|
||||
|
||||
asn1p_value_t *val = ct->elements[0]->value;
|
||||
if(val->type == ATV_VALUESET && val->value.constraint->type == ACT_EL_TYPE) {
|
||||
asn1p_value_t *csub = val->value.constraint->containedSubtype;
|
||||
if(!csub) {
|
||||
/* Ignore */
|
||||
} else if(csub->type == ATV_REFERENCED) {
|
||||
return csub->value.reference;
|
||||
} else if(csub->type == ATV_TYPE) {
|
||||
if(csub->value.v_type->expr_type == A1TC_REFERENCE) {
|
||||
assert(csub->value.v_type->reference);
|
||||
return csub->value.v_type->reference;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(val->type != ATV_REFERENCED) {
|
||||
FATAL("Set reference: %s", asn1f_printable_value(val));
|
||||
assert(val->type == ATV_REFERENCED);
|
||||
}
|
||||
|
||||
return val->value.reference;
|
||||
}
|
||||
|
||||
static asn1c_ioc_table_and_objset_t
|
||||
asn1c_get_ioc_table_from_objset(arg_t *arg, const asn1p_ref_t *objset_ref, asn1p_expr_t *objset) {
|
||||
asn1c_ioc_table_and_objset_t ioc_tao = { 0, 0, 1 };
|
||||
|
||||
(void)objset_ref;
|
||||
|
||||
if(objset->ioc_table) {
|
||||
ioc_tao.ioct = objset->ioc_table;
|
||||
ioc_tao.objset = objset;
|
||||
ioc_tao.fatal_error = 0;
|
||||
} else {
|
||||
FATAL("Information Object Set %s contains no objects at line %d",
|
||||
objset->Identifier, objset->_lineno);
|
||||
}
|
||||
|
||||
return ioc_tao;
|
||||
}
|
||||
|
||||
asn1c_ioc_table_and_objset_t
|
||||
asn1c_get_ioc_table(arg_t *arg) {
|
||||
asn1p_expr_t *expr = arg->expr;
|
||||
asn1p_expr_t *memb;
|
||||
asn1p_expr_t *objset = 0;
|
||||
const asn1p_ref_t *objset_ref = NULL;
|
||||
asn1c_ioc_table_and_objset_t safe_ioc_tao = {0, 0, 0};
|
||||
asn1c_ioc_table_and_objset_t failed_ioc_tao = { 0, 0, 1 };
|
||||
|
||||
TQ_FOR(memb, &(expr->members), next) {
|
||||
const asn1p_constraint_t *cr_ct =
|
||||
asn1p_get_component_relation_constraint(memb->constraints);
|
||||
const asn1p_ref_t *tmpref =
|
||||
asn1c_get_information_object_set_reference_from_constraint(arg,
|
||||
cr_ct);
|
||||
if(tmpref) {
|
||||
if(objset_ref && asn1p_ref_compare(objset_ref, tmpref) != 0) {
|
||||
FATAL(
|
||||
"Object set reference on line %d differs from object set "
|
||||
"reference on line %d",
|
||||
objset_ref->_lineno, tmpref->_lineno);
|
||||
return failed_ioc_tao;
|
||||
}
|
||||
objset_ref = tmpref;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!objset_ref) {
|
||||
return safe_ioc_tao;
|
||||
}
|
||||
|
||||
objset = WITH_MODULE_NAMESPACE(
|
||||
arg->expr->module, expr_ns,
|
||||
asn1f_lookup_symbol_ex(arg->asn, expr_ns, arg->expr, objset_ref));
|
||||
if(!objset) {
|
||||
FATAL("Cannot found %s", asn1p_ref_string(objset_ref));
|
||||
return failed_ioc_tao;
|
||||
}
|
||||
|
||||
return asn1c_get_ioc_table_from_objset(arg, objset_ref, objset);
|
||||
}
|
||||
|
||||
static int
|
||||
emit_ioc_value(arg_t *arg, struct asn1p_ioc_cell_s *cell) {
|
||||
|
||||
if(cell->value && cell->value->meta_type == AMT_VALUE) {
|
||||
const char *prim_type = NULL;
|
||||
int primitive_representation = 0;
|
||||
|
||||
asn1p_expr_t *cv_type =
|
||||
asn1f_find_terminal_type_ex(arg->asn, arg->ns, cell->value);
|
||||
|
||||
switch(cv_type->expr_type) {
|
||||
case ASN_BASIC_INTEGER:
|
||||
case ASN_BASIC_ENUMERATED:
|
||||
switch(asn1c_type_fits_long(arg, cell->value /* sic */)) {
|
||||
case FL_NOTFIT:
|
||||
GEN_INCLUDE_STD("INTEGER");
|
||||
prim_type = "INTEGER_t";
|
||||
break;
|
||||
case FL_PRESUMED:
|
||||
case FL_FITS_SIGNED:
|
||||
primitive_representation = 1;
|
||||
prim_type = "long";
|
||||
break;
|
||||
case FL_FITS_UNSIGN:
|
||||
prim_type = "unsigned long";
|
||||
primitive_representation = 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case ASN_BASIC_OBJECT_IDENTIFIER:
|
||||
prim_type = "OBJECT_IDENTIFIER_t";
|
||||
break;
|
||||
case ASN_BASIC_RELATIVE_OID:
|
||||
prim_type = "RELATIVE_OID_t";
|
||||
break;
|
||||
default: {
|
||||
char *p = strdup(MKID(cell->value));
|
||||
FATAL("Unsupported type %s for value %s",
|
||||
asn1c_type_name(arg, cell->value, TNF_UNMODIFIED), p);
|
||||
free(p);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
OUT("static const %s asn_VAL_%d_%s = ", prim_type,
|
||||
cell->value->_type_unique_index, MKID(cell->value));
|
||||
|
||||
asn1p_expr_t *expr_value = cell->value;
|
||||
while(expr_value->value->type == ATV_REFERENCED) {
|
||||
expr_value = WITH_MODULE_NAMESPACE(
|
||||
expr_value->module, expr_ns,
|
||||
asn1f_lookup_symbol_ex(arg->asn, expr_ns, expr_value,
|
||||
expr_value->value->value.reference));
|
||||
if(!expr_value) {
|
||||
FATAL("Unrecognized value type for %s", MKID(cell->value));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if(!primitive_representation) OUT("{ ");
|
||||
|
||||
switch(expr_value->value->type) {
|
||||
case ATV_INTEGER:
|
||||
if(primitive_representation) {
|
||||
OUT("%s", asn1p_itoa(expr_value->value->value.v_integer));
|
||||
break;
|
||||
} else {
|
||||
asn1c_integer_t v = expr_value->value->value.v_integer;
|
||||
if(v >= 0) {
|
||||
if(v <= 127) {
|
||||
OUT("\"\\x%02x\", 1", (int)v);
|
||||
break;
|
||||
} else if(v <= 32767) {
|
||||
OUT("\"\\x%02x\\x%02x\", 2", (int)(v >> 8), (int)(v & 0xff));
|
||||
break;
|
||||
}
|
||||
}
|
||||
FATAL("Unsupported value %s range for type %s",
|
||||
asn1f_printable_value(expr_value->value),
|
||||
MKID(cell->value));
|
||||
return -1;
|
||||
}
|
||||
case ATV_UNPARSED:
|
||||
OUT("\"not supported\", 0 };\n");
|
||||
FATAL("Inappropriate value %s for type %s",
|
||||
asn1f_printable_value(expr_value->value), MKID(cell->value));
|
||||
return 0; /* TEMPORARY FIXME FIXME */
|
||||
default:
|
||||
FATAL("Inappropriate value %s for type %s",
|
||||
asn1f_printable_value(expr_value->value), MKID(cell->value));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(primitive_representation) {
|
||||
OUT(";\n");
|
||||
} else {
|
||||
OUT(" };");
|
||||
OUT(" /* %s */\n", asn1f_printable_value(expr_value->value));
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
emit_ioc_cell(arg_t *arg, struct asn1p_ioc_cell_s *cell) {
|
||||
OUT("{ \"%s\", ", cell->field->Identifier);
|
||||
|
||||
if(!cell->value) {
|
||||
/* Ignore */
|
||||
} else if(cell->value->meta_type == AMT_VALUE) {
|
||||
GEN_INCLUDE(asn1c_type_name(arg, cell->value, TNF_INCLUDE));
|
||||
OUT("aioc__value, ");
|
||||
OUT("&asn_DEF_%s, ", asn1c_type_name(arg, cell->value, TNF_SAFE));
|
||||
OUT("&asn_VAL_%d_%s", cell->value->_type_unique_index,
|
||||
MKID(cell->value));
|
||||
|
||||
} else if(cell->value->meta_type == AMT_TYPEREF) {
|
||||
GEN_INCLUDE(asn1c_type_name(arg, cell->value, TNF_INCLUDE));
|
||||
OUT("aioc__type, &asn_DEF_%s", MKID(cell->value));
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
OUT(" }");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Refer to skeletons/asn_ioc.h
|
||||
*/
|
||||
int
|
||||
emit_ioc_table(arg_t *arg, asn1p_expr_t *context, asn1c_ioc_table_and_objset_t ioc_tao) {
|
||||
size_t columns = 0;
|
||||
|
||||
(void)context;
|
||||
GEN_INCLUDE_STD("asn_ioc");
|
||||
|
||||
REDIR(OT_IOC_TABLES);
|
||||
|
||||
/* Emit values that are used in the Information Object Set table first */
|
||||
for(size_t rn = 0; rn < ioc_tao.ioct->rows; rn++) {
|
||||
asn1p_ioc_row_t *row = ioc_tao.ioct->row[rn];
|
||||
for(size_t cn = 0; cn < row->columns; cn++) {
|
||||
if(emit_ioc_value(arg, &row->column[cn])) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Emit the Information Object Set */
|
||||
OUT("static const asn_ioc_cell_t asn_IOS_%s_%d_rows[] = {\n",
|
||||
MKID(ioc_tao.objset), ioc_tao.objset->_type_unique_index);
|
||||
INDENT(+1);
|
||||
|
||||
for(size_t rn = 0; rn < ioc_tao.ioct->rows; rn++) {
|
||||
asn1p_ioc_row_t *row = ioc_tao.ioct->row[rn];
|
||||
columns = columns ? columns : row->columns;
|
||||
if(columns != row->columns) {
|
||||
FATAL("Information Object Set %s row column mismatch on line %d",
|
||||
ioc_tao.objset->Identifier, ioc_tao.objset->_lineno);
|
||||
return -1;
|
||||
}
|
||||
for(size_t cn = 0; cn < row->columns; cn++) {
|
||||
if(rn || cn) OUT(",\n");
|
||||
emit_ioc_cell(arg, &row->column[cn]);
|
||||
}
|
||||
}
|
||||
OUT("\n");
|
||||
|
||||
INDENT(-1);
|
||||
OUT("};\n");
|
||||
|
||||
OUT("static const asn_ioc_set_t asn_IOS_%s_%d[] = {\n",
|
||||
MKID(ioc_tao.objset), ioc_tao.objset->_type_unique_index);
|
||||
INDENT(+1);
|
||||
OUT("%zu, %zu, asn_IOS_%s_%d_rows\n", ioc_tao.ioct->rows, columns,
|
||||
MKID(ioc_tao.objset), ioc_tao.objset->_type_unique_index);
|
||||
INDENT(-1);
|
||||
OUT("};\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef ASN1_IOC_H
|
||||
#define ASN1_IOC_H
|
||||
|
||||
#include "asn1compiler.h"
|
||||
#include "asn1p_class.h"
|
||||
|
||||
typedef struct asn1c_ioc_table_and_objset_s {
|
||||
asn1p_ioc_table_t *ioct;
|
||||
asn1p_expr_t *objset;
|
||||
int fatal_error; /* if ioct == NULL then specifies error or 0. */
|
||||
} asn1c_ioc_table_and_objset_t;
|
||||
|
||||
asn1c_ioc_table_and_objset_t asn1c_get_ioc_table(arg_t *arg);
|
||||
|
||||
int emit_ioc_table(arg_t *arg, asn1p_expr_t *context,
|
||||
asn1c_ioc_table_and_objset_t);
|
||||
|
||||
const asn1p_ref_t *asn1c_get_information_object_set_reference_from_constraint(
|
||||
arg_t *arg, const asn1p_constraint_t *ct);
|
||||
|
||||
|
||||
#endif /* ASN1_IOC_H */
|
|
@ -5,24 +5,28 @@
|
|||
#include <asn1fix_export.h> /* other exportable stuff from libasn1fix */
|
||||
|
||||
/*
|
||||
* Checks that the given string is not a reserved C/C++ keyword.
|
||||
* ISO/IEC 9899:1999 (C99), A.1.2
|
||||
* Checks that the given string is not a reserved C/C++ keyword [1],[2].
|
||||
* _* keywords not included, since asn1 identifiers cannot begin with hyphen [3]
|
||||
* [1] ISO/IEC 9899:2011 (C11), 6.4.1
|
||||
* [2] ISO/IEC 14882:2014 (C++14), 2.12
|
||||
* [3] ISO/IEC 8824-1:2003 (asn1) 11.3
|
||||
*/
|
||||
static char *res_kwd[] = {
|
||||
"auto", "break", "case", "char", "const", "continue", "default",
|
||||
"do", "double", "else", "enum", "extern", "float", "for", "goto",
|
||||
"if", "inline", "int", "long", "register", "restrict", "return",
|
||||
"short", "signed", "sizeof", "static", "struct", "switch", "typedef",
|
||||
"union", "unsigned", "void", "volatile", "while",
|
||||
"_Bool", "_Complex", "_Imaginary",
|
||||
/* C++ */
|
||||
"class", "explicit", "bool", "mutable",
|
||||
"template", "typeid", "typename", "and", "and_eq",
|
||||
"or", "or_eq", "xor", "xor_eq", "not", "not_eq",
|
||||
"bitor", "compl", "bitand",
|
||||
"const_cast", "dynamic_cast", "reinterpret_cast",
|
||||
"static_cast", "true", "false", "namespace", "using",
|
||||
"throw", "try", "catch"
|
||||
/* C */
|
||||
"auto", "break", "case", "char", "const", "continue", "default", "do",
|
||||
"double", "else", "enum", "extern", "float", "for", "goto", "if",
|
||||
"inline", "int", "long", "register", "restrict", "return", "short",
|
||||
"signed", "sizeof", "static", "struct", "switch", "typedef", "union",
|
||||
"unsigned", "void", "volatile", "while",
|
||||
/* C++ */
|
||||
"alignas", "alignof", "and", "and_eq", "asm", "bitand", "bitor", "bool",
|
||||
"catch", "char16_t", "char32_t", "class", "compl", "const_cast",
|
||||
"constexpr", "decltype", "delete", "delete", "dynamic_cast",
|
||||
"explicit", "export", "false", "friend", "mutable", "namespace", "new",
|
||||
"noexcept", "not", "not_eq", "nullptr", "operator", "or", "or_eq",
|
||||
"private", "protected", "public", "reinterpret_cast", "static_assert",
|
||||
"static_cast", "template", "this", "thread_local", "throw", "true", "try",
|
||||
"typeid", "typename", "using", "virtual", "wchar_t", "xor", "xor_eq"
|
||||
};
|
||||
static int
|
||||
reserved_keyword(const char *str) {
|
||||
|
@ -38,7 +42,7 @@ reserved_keyword(const char *str) {
|
|||
* Construct identifier from multiple parts.
|
||||
* Convert unsafe characters to underscores.
|
||||
*/
|
||||
char *
|
||||
const char *
|
||||
asn1c_make_identifier(enum ami_flags_e flags, asn1p_expr_t *expr, ...) {
|
||||
static char *storage;
|
||||
static int storage_size;
|
||||
|
@ -47,9 +51,11 @@ asn1c_make_identifier(enum ami_flags_e flags, asn1p_expr_t *expr, ...) {
|
|||
char *str;
|
||||
char *nextstr;
|
||||
char *first = 0;
|
||||
char *second = 0;
|
||||
ssize_t size;
|
||||
ssize_t size = 0;
|
||||
char *p;
|
||||
char *prefix = NULL;
|
||||
char *sptr[4], **psptr = &sptr[0];
|
||||
int sptr_cnt = 0;
|
||||
|
||||
if(expr) {
|
||||
/*
|
||||
|
@ -57,16 +63,26 @@ asn1c_make_identifier(enum ami_flags_e flags, asn1p_expr_t *expr, ...) {
|
|||
*/
|
||||
if(expr->Identifier == NULL)
|
||||
return "Member";
|
||||
size = strlen(expr->Identifier);
|
||||
/*
|
||||
* Add MODULE name to resolve clash
|
||||
*/
|
||||
if(expr->_mark & TM_NAMECLASH) {
|
||||
size += strlen(expr->module->ModuleName) + 2;
|
||||
sptr[sptr_cnt++] = expr->module->ModuleName;
|
||||
}
|
||||
sptr[sptr_cnt++] = expr->Identifier;
|
||||
|
||||
size += strlen(expr->Identifier);
|
||||
if(expr->spec_index != -1) {
|
||||
static char buf[32];
|
||||
second = buf;
|
||||
size += 1 + snprintf(buf, sizeof buf, "%dP%d",
|
||||
expr->_lineno, expr->spec_index);
|
||||
sptr[sptr_cnt++] = (char *)&buf;
|
||||
}
|
||||
} else {
|
||||
size = -1;
|
||||
}
|
||||
sptr[sptr_cnt++] = (char *)0;
|
||||
|
||||
va_start(ap, expr);
|
||||
while((str = va_arg(ap, char *)))
|
||||
|
@ -74,18 +90,20 @@ asn1c_make_identifier(enum ami_flags_e flags, asn1p_expr_t *expr, ...) {
|
|||
va_end(ap);
|
||||
if(size == -1) return NULL;
|
||||
|
||||
if(prefix)
|
||||
size += 1 + strlen(prefix);
|
||||
/*
|
||||
* Make sure we have this amount of storage.
|
||||
* Make sure we have the required amount of storage.
|
||||
*/
|
||||
if(storage_size <= size) {
|
||||
free(storage);
|
||||
storage = malloc(size + 1);
|
||||
if(storage) {
|
||||
storage_size = size;
|
||||
} else {
|
||||
storage_size = 0;
|
||||
return NULL;
|
||||
}
|
||||
char *tmp = malloc(size + 1);
|
||||
if(tmp) {
|
||||
free(storage);
|
||||
storage = tmp;
|
||||
storage_size = size + 1;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -93,20 +111,19 @@ asn1c_make_identifier(enum ami_flags_e flags, asn1p_expr_t *expr, ...) {
|
|||
*/
|
||||
va_start(ap, expr);
|
||||
p = storage;
|
||||
if(prefix) {
|
||||
strcpy(storage, prefix);
|
||||
p += strlen(prefix);
|
||||
}
|
||||
nextstr = "";
|
||||
for(p = storage, str = 0; str || nextstr; str = nextstr) {
|
||||
for(str = 0; str || nextstr; str = nextstr) {
|
||||
int subst_made = 0;
|
||||
nextstr = second ? second : va_arg(ap, char *);
|
||||
nextstr = *(psptr) ? *(psptr++) : va_arg(ap, char *);
|
||||
|
||||
if(str == 0) {
|
||||
if(expr) {
|
||||
str = expr->Identifier;
|
||||
first = str;
|
||||
second = 0;
|
||||
} else {
|
||||
first = nextstr;
|
||||
continue;
|
||||
}
|
||||
str = first = nextstr;
|
||||
nextstr = *(psptr) ? *(psptr++) : va_arg(ap, char *);
|
||||
if (!first) continue;
|
||||
}
|
||||
|
||||
if(str[0] == ' ' && str[1] == '\0') {
|
||||
|
@ -151,13 +168,13 @@ asn1c_make_identifier(enum ami_flags_e flags, asn1p_expr_t *expr, ...) {
|
|||
return storage;
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) {
|
||||
asn1p_expr_t *exprid = 0;
|
||||
asn1p_expr_t *top_parent;
|
||||
asn1p_expr_t *terminal;
|
||||
asn1p_expr_t *terminal = 0;
|
||||
int stdname = 0;
|
||||
char *typename;
|
||||
const char *typename;
|
||||
|
||||
/* Rewind to the topmost parent expression */
|
||||
if((top_parent = expr->parent_expr))
|
||||
|
@ -178,22 +195,29 @@ asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) {
|
|||
* This is a reference to a type defined in a class.
|
||||
* Resolve it and use instead.
|
||||
*/
|
||||
tmp.expr = asn1f_class_access_ex(arg->asn,
|
||||
arg->expr->module, arg->expr, expr->rhs_pspecs, expr->reference);
|
||||
if(!tmp.expr) return NULL;
|
||||
tmp.expr = WITH_MODULE_NAMESPACE(
|
||||
arg->expr->module, expr_ns,
|
||||
asn1f_class_access_ex(arg->asn, arg->expr->module, expr_ns,
|
||||
arg->expr, expr->rhs_pspecs,
|
||||
expr->reference));
|
||||
if(!tmp.expr) return NULL;
|
||||
|
||||
return asn1c_type_name(&tmp, tmp.expr, _format);
|
||||
}
|
||||
|
||||
terminal = asn1f_find_terminal_type_ex(arg->asn, expr);
|
||||
terminal = WITH_MODULE_NAMESPACE(
|
||||
expr->module, expr_ns,
|
||||
(expr->meta_type == AMT_TYPEREF) ?
|
||||
asn1f_lookup_symbol_ex(arg->asn, expr_ns, expr, expr->reference) :
|
||||
asn1f_find_terminal_type_ex(arg->asn, expr_ns, expr));
|
||||
|
||||
if(_format == TNF_RSAFE) {
|
||||
if(_format == TNF_RSAFE) {
|
||||
if(terminal && terminal->expr_type & ASN_CONSTR_MASK) {
|
||||
typename = terminal->Identifier;
|
||||
}
|
||||
}
|
||||
|
||||
if(_format == TNF_CTYPE) {
|
||||
if(_format == TNF_CTYPE || _format == TNF_CONSTYPE) {
|
||||
/*
|
||||
* If the component references the type itself,
|
||||
* switch to a recursion-safe type naming
|
||||
|
@ -204,7 +228,7 @@ asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) {
|
|||
}
|
||||
}
|
||||
|
||||
if(terminal && terminal->spec_index != -1) {
|
||||
if(_format != TNF_RSAFE && terminal && ((terminal->spec_index != -1) || (terminal->_mark & TM_NAMECLASH))) {
|
||||
exprid = terminal;
|
||||
typename = 0;
|
||||
}
|
||||
|
@ -213,19 +237,38 @@ asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) {
|
|||
case ASN_BASIC_INTEGER:
|
||||
case ASN_BASIC_ENUMERATED:
|
||||
case ASN_BASIC_REAL:
|
||||
if((expr->expr_type == ASN_BASIC_REAL
|
||||
&& !(arg->flags & A1C_USE_WIDE_TYPES))
|
||||
|| asn1c_type_fits_long(arg, expr)) {
|
||||
switch(_format) {
|
||||
case TNF_CTYPE:
|
||||
case TNF_RSAFE:
|
||||
if(expr->expr_type == ASN_BASIC_REAL)
|
||||
return "double";
|
||||
else if(asn1c_type_fits_long(arg, expr) == FL_FITS_UNSIGN)
|
||||
return "unsigned long";
|
||||
else
|
||||
return "long";
|
||||
default:
|
||||
if((expr->expr_type == ASN_BASIC_REAL
|
||||
&& (_format == TNF_CONSTYPE || !(arg->flags & A1C_USE_WIDE_TYPES)
|
||||
|| asn1c_REAL_fits(arg, expr) != RL_NOTFIT))
|
||||
|| asn1c_type_fits_long(arg, expr)) {
|
||||
switch(_format) {
|
||||
case TNF_CONSTYPE:
|
||||
if(expr->expr_type == ASN_BASIC_REAL) {
|
||||
return "double";
|
||||
} else if(asn1c_type_fits_long(arg, expr) == FL_FITS_UNSIGN) {
|
||||
return "unsigned long";
|
||||
} else {
|
||||
return "long";
|
||||
}
|
||||
case TNF_CTYPE:
|
||||
case TNF_RSAFE:
|
||||
if(expr->expr_type == ASN_BASIC_REAL) {
|
||||
asn1cnst_range_t *range = asn1constraint_compute_OER_range(
|
||||
expr->Identifier, ASN_BASIC_REAL,
|
||||
expr->combined_constraints, ACT_EL_RANGE, 0, 0, 0);
|
||||
if(range->narrowing == NARROW_FLOAT32) {
|
||||
asn1constraint_range_free(range);
|
||||
return "float";
|
||||
} else {
|
||||
asn1constraint_range_free(range);
|
||||
return "double";
|
||||
}
|
||||
} else if(asn1c_type_fits_long(arg, expr) == FL_FITS_UNSIGN) {
|
||||
return "unsigned long";
|
||||
} else {
|
||||
return "long";
|
||||
}
|
||||
default:
|
||||
typename = 0;
|
||||
switch(expr->expr_type) {
|
||||
case ASN_BASIC_INTEGER:
|
||||
|
@ -262,30 +305,66 @@ asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) {
|
|||
|
||||
switch(_format) {
|
||||
case TNF_UNMODIFIED:
|
||||
return asn1c_make_identifier(AMI_MASK_ONLY_SPACES,
|
||||
0, exprid ? exprid->Identifier : typename, 0);
|
||||
return asn1c_make_identifier(AMI_MASK_ONLY_SPACES | AMI_NODELIMITER,
|
||||
0, MODULE_NAME_OF(exprid), exprid ? exprid->Identifier : typename, (char*)0);
|
||||
case TNF_INCLUDE:
|
||||
return asn1c_make_identifier(
|
||||
AMI_MASK_ONLY_SPACES | AMI_NODELIMITER,
|
||||
0, ((!stdname || (arg->flags & A1C_INCLUDES_QUOTED))
|
||||
? "\"" : "<"),
|
||||
MODULE_NAME_OF(exprid),
|
||||
exprid ? exprid->Identifier : typename,
|
||||
((!stdname || (arg->flags & A1C_INCLUDES_QUOTED))
|
||||
? ".h\"" : ".h>"), 0);
|
||||
? ".h\"" : ".h>"), (char*)0);
|
||||
case TNF_SAFE:
|
||||
return asn1c_make_identifier(0, exprid, typename, 0);
|
||||
return asn1c_make_identifier(0, exprid, typename, (char*)0);
|
||||
case TNF_CTYPE: /* C type */
|
||||
case TNF_CONSTYPE: /* C type */
|
||||
return asn1c_make_identifier(0, exprid,
|
||||
exprid?"t":typename, exprid?0:"t", 0);
|
||||
exprid?"t":typename, exprid?0:"t", (char*)0);
|
||||
case TNF_RSAFE: /* Recursion-safe type */
|
||||
return asn1c_make_identifier(AMI_CHECK_RESERVED, 0,
|
||||
"struct", " ", typename, 0);
|
||||
return asn1c_make_identifier(AMI_CHECK_RESERVED | AMI_NODELIMITER, 0,
|
||||
"struct", " ", MODULE_NAME_OF(exprid), typename, (char*)0);
|
||||
}
|
||||
|
||||
assert(!"unreachable");
|
||||
return typename;
|
||||
}
|
||||
|
||||
static asn1p_expr_type_e
|
||||
expr_get_type(arg_t *arg, asn1p_expr_t *expr) {
|
||||
asn1p_expr_t *terminal;
|
||||
terminal = asn1f_find_terminal_type_ex(arg->asn, arg->ns, expr);
|
||||
if(terminal) return terminal->expr_type;
|
||||
return A1TC_INVALID;
|
||||
}
|
||||
|
||||
enum asn1c_fitsfloat_e
|
||||
asn1c_REAL_fits(arg_t *arg, asn1p_expr_t *expr) {
|
||||
asn1p_expr_type_e etype = expr_get_type(arg, arg->expr);
|
||||
if(etype == ASN_BASIC_REAL) {
|
||||
asn1cnst_range_t *range = asn1constraint_compute_OER_range(
|
||||
expr->Identifier, etype, expr->combined_constraints, ACT_EL_RANGE,
|
||||
0, 0, 0);
|
||||
enum asn1c_fitsfloat_e fits;
|
||||
switch(range->narrowing) {
|
||||
case NARROW_FLOAT32:
|
||||
fits = RL_FITS_FLOAT32;
|
||||
break;
|
||||
case NARROW_DOUBLE64:
|
||||
fits = RL_FITS_DOUBLE64;
|
||||
break;
|
||||
default:
|
||||
fits = RL_NOTFIT;
|
||||
break;
|
||||
}
|
||||
asn1constraint_range_free(range);
|
||||
return fits;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check whether the specified INTEGER or ENUMERATED type can be represented
|
||||
* using the generic 'long' or 'unsigned long' type.
|
||||
|
@ -309,8 +388,10 @@ asn1c_type_fits_long(arg_t *arg, asn1p_expr_t *expr) {
|
|||
#define LEFTMIN (-RIGHTMAX-1) /* of 32-bit integer type */
|
||||
|
||||
/* Descend to the terminal type */
|
||||
expr = asn1f_find_terminal_type_ex(arg->asn, expr);
|
||||
if(expr == 0) return FL_NOTFIT;
|
||||
expr = WITH_MODULE_NAMESPACE(
|
||||
expr->module, expr_ns,
|
||||
asn1f_find_terminal_type_ex(arg->asn, expr_ns, expr));
|
||||
if(expr == 0) return FL_NOTFIT;
|
||||
|
||||
/* The "fits into long" operation is relevant only for integer types */
|
||||
switch(expr->expr_type) {
|
||||
|
@ -341,7 +422,8 @@ asn1c_type_fits_long(arg_t *arg, asn1p_expr_t *expr) {
|
|||
* applied (non-standard! but we can deal with this) to the type.
|
||||
* Check the range.
|
||||
*/
|
||||
range = asn1constraint_compute_PER_range(expr->expr_type,
|
||||
range = asn1constraint_compute_constraint_range(expr->Identifier,
|
||||
expr->expr_type,
|
||||
expr->combined_constraints, ACT_CT_SIZE, 0, 0,
|
||||
CPR_simulate_fbless_SIZE);
|
||||
if(range) {
|
||||
|
@ -357,7 +439,7 @@ asn1c_type_fits_long(arg_t *arg, asn1p_expr_t *expr) {
|
|||
/*
|
||||
* Third, pull up the PER visible range of the INTEGER.
|
||||
*/
|
||||
range = asn1constraint_compute_PER_range(expr->expr_type,
|
||||
range = asn1constraint_compute_PER_range(expr->Identifier, expr->expr_type,
|
||||
expr->combined_constraints, ACT_EL_RANGE, 0, 0, 0);
|
||||
|
||||
if(!range
|
||||
|
@ -380,7 +462,12 @@ asn1c_type_fits_long(arg_t *arg, asn1p_expr_t *expr) {
|
|||
asn1constraint_range_free(range);
|
||||
|
||||
/* Special case for unsigned */
|
||||
if(left.type == ARE_VALUE
|
||||
if(!(arg->flags & A1C_USE_WIDE_TYPES) && left.type == ARE_VALUE
|
||||
&& left.value >= 0 && left.value <= 2147483647
|
||||
&& right.type == ARE_MAX) {
|
||||
return FL_FITS_UNSIGN;
|
||||
}
|
||||
if(left.type == ARE_VALUE
|
||||
&& left.value >= 0
|
||||
&& right.type == ARE_VALUE
|
||||
&& right.value > 2147483647
|
||||
|
|
|
@ -7,23 +7,27 @@
|
|||
* with safe ones.
|
||||
*/
|
||||
enum ami_flags_e {
|
||||
AMI_MASK_ONLY_SPACES = 1, /* Mask only spaces, everything else's safe */
|
||||
AMI_CHECK_RESERVED = 2, /* Check against reserved keywords */
|
||||
AMI_NODELIMITER = 4, /* Do not put delimiter, just concatenate */
|
||||
AMI_MASK_ONLY_SPACES = 1, /* Mask only spaces, everything else's safe */
|
||||
AMI_CHECK_RESERVED = 2, /* Check against reserved keywords */
|
||||
AMI_NODELIMITER = 4, /* Do not put delimiter, just concatenate */
|
||||
AMI_USE_PREFIX = 8, /* Use Prefix when generating identifier */
|
||||
};
|
||||
char *asn1c_make_identifier(enum ami_flags_e, asn1p_expr_t *expr, ...);
|
||||
const char *asn1c_make_identifier(enum ami_flags_e, asn1p_expr_t *expr, ...);
|
||||
|
||||
/*
|
||||
* Return the type name of the specified expression.
|
||||
* The returned string is a pointer to a statically allocated buffer which is
|
||||
* going to be clobbered by the subsequent invocation of this function.
|
||||
*/
|
||||
enum tnfmt {
|
||||
TNF_UNMODIFIED = 0x10, /* Return unmodified type name */
|
||||
TNF_INCLUDE = 0x20, /* Format for #include <> */
|
||||
TNF_CTYPE = 0x30, /* Format as normal C-ish type (append "_t") */
|
||||
TNF_SAFE = 0x40, /* Replace unsafe characters with _ */
|
||||
TNF_RSAFE = 0x50, /* Recursion-safe C type format */
|
||||
TNF_CONSTYPE = 0x40, /* Replace unsafe characters with _ */
|
||||
TNF_SAFE = 0x50, /* Replace unsafe characters with _ */
|
||||
TNF_RSAFE = 0x60, /* Recursion-safe C type format */
|
||||
};
|
||||
char *asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format);
|
||||
const char *asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format);
|
||||
|
||||
/*
|
||||
* Check whether the specified INTEGER or ENUMERATED type can be represented
|
||||
|
@ -42,4 +46,11 @@ enum asn1c_fitslong_e {
|
|||
};
|
||||
enum asn1c_fitslong_e asn1c_type_fits_long(arg_t *arg, asn1p_expr_t *expr);
|
||||
|
||||
enum asn1c_fitsfloat_e {
|
||||
RL_NOTFIT,
|
||||
RL_FITS_FLOAT32,
|
||||
RL_FITS_DOUBLE64
|
||||
};
|
||||
enum asn1c_fitsfloat_e asn1c_REAL_fits(arg_t *arg, asn1p_expr_t *expr);
|
||||
|
||||
#endif /* ASN1_COMPILER_MISC_H */
|
||||
|
|
|
@ -0,0 +1,312 @@
|
|||
#include "asn1c_internal.h"
|
||||
#include "asn1c_naming.h"
|
||||
#include "asn1c_misc.h"
|
||||
#include "asn1c_misc.h"
|
||||
#include <asn1_buffer.h>
|
||||
#include <genhash.h>
|
||||
|
||||
struct intl_name {
|
||||
asn1p_expr_t *expr;
|
||||
asn1p_expr_t *clashes_with;
|
||||
const char *name;
|
||||
TQ_ENTRY(struct intl_name) next;
|
||||
};
|
||||
|
||||
genhash_t *used_names_hash;
|
||||
|
||||
static void
|
||||
name_entry_destroy(void *np) {
|
||||
struct intl_name *n = np;
|
||||
|
||||
union {
|
||||
const char *c_buf;
|
||||
char *nc_buf;
|
||||
} const_cast;
|
||||
|
||||
asn1p_expr_free(n->expr);
|
||||
asn1p_expr_free(n->clashes_with);
|
||||
const_cast.c_buf = n->name;
|
||||
free(const_cast.nc_buf);
|
||||
free(n);
|
||||
}
|
||||
|
||||
void
|
||||
c_name_clash_finder_init() {
|
||||
assert(used_names_hash == NULL);
|
||||
used_names_hash =
|
||||
genhash_new(cmpf_string, hashf_string, NULL, name_entry_destroy);
|
||||
assert(used_names_hash);
|
||||
}
|
||||
|
||||
void
|
||||
c_name_clash_finder_destroy() {
|
||||
genhash_destroy(used_names_hash);
|
||||
used_names_hash = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
register_global_name(asn1p_expr_t *expr, const char *name) {
|
||||
struct intl_name *n;
|
||||
|
||||
n = genhash_get(used_names_hash, (const void *)name);
|
||||
if(n) {
|
||||
if(!(expr->_mark & TM_NAMEGIVEN) && (expr != n->expr)) {
|
||||
n->clashes_with = expr;
|
||||
expr->ref_cnt++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(expr->_mark & TM_NAMEGIVEN)
|
||||
return;
|
||||
|
||||
char *name_copy = strdup(name);
|
||||
|
||||
n = calloc(1, sizeof(*n));
|
||||
assert(n);
|
||||
n->expr = expr;
|
||||
expr->ref_cnt++;
|
||||
n->name = name_copy;
|
||||
int ret = genhash_add(used_names_hash, name_copy, n);
|
||||
assert(ret == 0);
|
||||
}
|
||||
|
||||
int
|
||||
c_name_clash(arg_t *arg) {
|
||||
struct intl_name *n;
|
||||
size_t n_clashes = 0;
|
||||
const size_t max_clashes = 5;
|
||||
|
||||
genhash_iter_t iter;
|
||||
|
||||
genhash_iter_init(&iter, used_names_hash, 0);
|
||||
while(genhash_iter(&iter, NULL, (void *)&n)) {
|
||||
if(n->clashes_with) {
|
||||
if(n_clashes++ > max_clashes) continue;
|
||||
FATAL(
|
||||
"Name \"%s\" is generated by %s.%s at line %s:%d and "
|
||||
"%s.%s at line %s:%d",
|
||||
n->name, n->expr->module->ModuleName, n->expr->Identifier,
|
||||
n->expr->module->source_file_name, n->expr->_lineno,
|
||||
n->clashes_with->module->ModuleName,
|
||||
n->clashes_with->Identifier,
|
||||
n->clashes_with->module->source_file_name,
|
||||
n->clashes_with->_lineno);
|
||||
}
|
||||
}
|
||||
|
||||
genhash_iter_done(&iter);
|
||||
|
||||
if(n_clashes > max_clashes) {
|
||||
FATAL("... %zu more name clashes not shown", n_clashes - max_clashes);
|
||||
}
|
||||
|
||||
return n_clashes > 0;
|
||||
}
|
||||
|
||||
|
||||
static abuf *
|
||||
construct_base_name(abuf *buf, asn1p_expr_t *expr, int compound_names,
|
||||
int avoid_keywords) {
|
||||
const char *id;
|
||||
|
||||
assert(buf);
|
||||
|
||||
if(compound_names && expr->parent_expr) {
|
||||
construct_base_name(buf, expr->parent_expr, compound_names, 0);
|
||||
if(buf->length) {
|
||||
abuf_str(buf, "__"); /* component separator */
|
||||
}
|
||||
}
|
||||
|
||||
id = asn1c_make_identifier(
|
||||
((avoid_keywords && !buf->length) ? AMI_CHECK_RESERVED : 0), expr, 0);
|
||||
|
||||
abuf_str(buf, id);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
static struct c_names
|
||||
c_name_impl(arg_t *arg, asn1p_expr_t *expr, int avoid_keywords) {
|
||||
asn1p_expr_type_e expr_type = expr->expr_type;
|
||||
struct c_names names;
|
||||
int compound_names = 0;
|
||||
|
||||
static abuf b_type_asn_name;
|
||||
static abuf b_type_part_name;
|
||||
static abuf b_type_base_name;
|
||||
static abuf b_type_c_name;
|
||||
static abuf b_type_constrained_c_name;
|
||||
static abuf b_asn_name;
|
||||
static abuf b_part_name;
|
||||
static abuf b_base_name;
|
||||
static abuf b_short_name;
|
||||
static abuf b_full_name;
|
||||
static abuf b_as_member;
|
||||
static abuf b_presence_enum;
|
||||
static abuf b_presence_name;
|
||||
static abuf b_members_enum;
|
||||
static abuf b_members_name;
|
||||
|
||||
abuf_clear(&b_type_asn_name);
|
||||
abuf_clear(&b_type_part_name);
|
||||
abuf_clear(&b_type_base_name);
|
||||
abuf_clear(&b_type_c_name);
|
||||
abuf_clear(&b_type_constrained_c_name);
|
||||
abuf_clear(&b_asn_name);
|
||||
abuf_clear(&b_base_name);
|
||||
abuf_clear(&b_part_name);
|
||||
abuf_clear(&b_short_name);
|
||||
abuf_clear(&b_full_name);
|
||||
abuf_clear(&b_as_member);
|
||||
abuf_clear(&b_presence_enum);
|
||||
abuf_clear(&b_presence_name);
|
||||
abuf_clear(&b_members_enum);
|
||||
abuf_clear(&b_members_name);
|
||||
|
||||
|
||||
abuf_str(&b_type_asn_name, asn1c_type_name(arg, expr, TNF_UNMODIFIED));
|
||||
abuf_str(&b_type_part_name, asn1c_type_name(arg, expr, TNF_SAFE));
|
||||
abuf_str(&b_type_base_name, asn1c_type_name(arg, expr, TNF_SAFE));
|
||||
abuf_str(&b_type_c_name, asn1c_type_name(arg, expr, TNF_CTYPE));
|
||||
abuf_str(&b_type_constrained_c_name,
|
||||
asn1c_type_name(arg, expr, TNF_CONSTYPE));
|
||||
|
||||
|
||||
if((arg->flags & A1C_COMPOUND_NAMES)) {
|
||||
if((expr_type & ASN_CONSTR_MASK)
|
||||
|| expr_type == ASN_BASIC_ENUMERATED
|
||||
|| ((expr_type == ASN_BASIC_INTEGER
|
||||
|| expr_type == ASN_BASIC_BIT_STRING))) {
|
||||
compound_names = 1;
|
||||
}
|
||||
}
|
||||
|
||||
construct_base_name(&b_asn_name, expr, 0, 0);
|
||||
construct_base_name(&b_part_name, expr, 0, 0);
|
||||
construct_base_name(&b_base_name, expr, compound_names, avoid_keywords);
|
||||
construct_base_name(&b_as_member, expr, 0, 1);
|
||||
|
||||
static abuf tmp_compoundable_part_name;
|
||||
static abuf compound_part_name;
|
||||
abuf_clear(&tmp_compoundable_part_name);
|
||||
abuf_clear(&compound_part_name);
|
||||
construct_base_name(&tmp_compoundable_part_name, expr, compound_names, 0);
|
||||
construct_base_name(&compound_part_name, expr, 1, 0);
|
||||
|
||||
if(!expr->_anonymous_type) {
|
||||
if(arg->embed) {
|
||||
abuf_printf(&b_short_name, "%s", b_as_member.buffer);
|
||||
} else {
|
||||
abuf_printf(&b_short_name, "%s_t", b_as_member.buffer);
|
||||
}
|
||||
}
|
||||
abuf_printf(&b_full_name, "struct %s", b_base_name.buffer);
|
||||
abuf_printf(&b_presence_enum, "enum %s_PR", tmp_compoundable_part_name.buffer);
|
||||
abuf_printf(&b_presence_name, "%s_PR", tmp_compoundable_part_name.buffer);
|
||||
abuf_printf(&b_members_enum, "enum %s", b_base_name.buffer);
|
||||
abuf_printf(&b_members_name, "e_%s", tmp_compoundable_part_name.buffer);
|
||||
|
||||
names.type.asn_name = b_type_asn_name.buffer;
|
||||
names.type.base_name = b_type_base_name.buffer;
|
||||
names.type.part_name = b_type_part_name.buffer;
|
||||
names.type.c_name = b_type_c_name.buffer;
|
||||
names.type.constrained_c_name = b_type_constrained_c_name.buffer;
|
||||
names.asn_name = b_asn_name.buffer;
|
||||
names.part_name = b_part_name.buffer;
|
||||
names.base_name = b_base_name.buffer;
|
||||
names.short_name = b_short_name.buffer;
|
||||
names.full_name = b_full_name.buffer;
|
||||
names.as_member = b_as_member.buffer;
|
||||
names.presence_enum = b_presence_enum.buffer;
|
||||
names.presence_name = b_presence_name.buffer;
|
||||
names.members_enum = b_members_enum.buffer;
|
||||
names.members_name = b_members_name.buffer;
|
||||
names.compound_name = compound_part_name.buffer;
|
||||
|
||||
/* A _subset_ of names is checked against being globally unique */
|
||||
register_global_name(expr, names.base_name);
|
||||
register_global_name(expr, names.full_name);
|
||||
register_global_name(expr, names.presence_enum);
|
||||
register_global_name(expr, names.presence_name);
|
||||
register_global_name(expr, names.members_enum);
|
||||
register_global_name(expr, names.members_name);
|
||||
|
||||
expr->_mark |= TM_NAMEGIVEN;
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
struct c_names
|
||||
c_name(arg_t *arg) {
|
||||
return c_name_impl(arg, arg->expr, 1);
|
||||
}
|
||||
|
||||
struct c_names
|
||||
c_expr_name(arg_t *arg, asn1p_expr_t *expr) {
|
||||
return c_name_impl(arg, expr, 1);
|
||||
}
|
||||
|
||||
const char *
|
||||
c_member_name(arg_t *arg, asn1p_expr_t *expr) {
|
||||
static abuf ab;
|
||||
|
||||
abuf_clear(&ab);
|
||||
|
||||
/* NB: do not use part_name, doesn't work for -fcompound-names */
|
||||
abuf_str(&ab, c_name_impl(arg, arg->expr, 0).base_name);
|
||||
abuf_str(&ab, "_");
|
||||
abuf_str(&ab, asn1c_make_identifier(0, expr, 0));
|
||||
|
||||
return ab.buffer;
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
c_presence_name(arg_t *arg, asn1p_expr_t *expr) {
|
||||
static abuf ab;
|
||||
|
||||
abuf_clear(&ab);
|
||||
|
||||
if(expr) {
|
||||
/* NB: do not use part_name, doesn't work for -fcompound-names */
|
||||
abuf_str(&ab, c_name_impl(arg, arg->expr, 0).base_name);
|
||||
abuf_str(&ab, "_PR_");
|
||||
abuf_str(&ab, asn1c_make_identifier(0, expr, 0));
|
||||
} else {
|
||||
abuf_printf(&ab, "%s_PR_NOTHING",
|
||||
c_name_impl(arg, arg->expr, 0).base_name);
|
||||
}
|
||||
|
||||
return ab.buffer;
|
||||
}
|
||||
|
||||
const char *
|
||||
c_names_format(struct c_names ns) {
|
||||
static abuf nbuf;
|
||||
abuf_clear(&nbuf);
|
||||
|
||||
#define FMT_COMPONENT(x) abuf_printf(&nbuf, " ." #x "=\"%s\",", ns.x);
|
||||
|
||||
abuf_str(&nbuf, "{");
|
||||
FMT_COMPONENT(type.asn_name);
|
||||
FMT_COMPONENT(type.part_name);
|
||||
FMT_COMPONENT(type.base_name);
|
||||
FMT_COMPONENT(type.c_name);
|
||||
FMT_COMPONENT(type.constrained_c_name);
|
||||
FMT_COMPONENT(asn_name);
|
||||
FMT_COMPONENT(part_name);
|
||||
FMT_COMPONENT(base_name);
|
||||
FMT_COMPONENT(full_name);
|
||||
FMT_COMPONENT(short_name);
|
||||
FMT_COMPONENT(full_name);
|
||||
FMT_COMPONENT(as_member);
|
||||
FMT_COMPONENT(presence_enum);
|
||||
FMT_COMPONENT(presence_name);
|
||||
FMT_COMPONENT(members_enum);
|
||||
FMT_COMPONENT(members_name);
|
||||
abuf_printf(&nbuf, " .members_name=\"%s\" }", ns.members_name);
|
||||
return nbuf.buffer;
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
#ifndef ASN1_COMPILER_NAMING_H
|
||||
#define ASN1_COMPILER_NAMING_H
|
||||
|
||||
|
||||
/*
|
||||
* A member or a field name.
|
||||
*/
|
||||
struct c_names {
|
||||
struct {
|
||||
const char *asn_name; /* "T-Rex" */
|
||||
const char *part_name; /* "T_Rex" */
|
||||
const char *base_name; /* "T_Rex" */
|
||||
const char *c_name; /* "T_Rex_t" */
|
||||
const char *constrained_c_name; /* "long" */
|
||||
} type;
|
||||
const char *asn_name; /* "foo" */
|
||||
const char *part_name; /* "foo", "signed" */
|
||||
const char *base_name; /* "foo" if not, "parent_foo" if compound */
|
||||
const char *short_name; /* "foo_t", "e_foo" */
|
||||
const char *full_name; /* "struct foo", "enum foo" */
|
||||
const char *as_member; /* "foo" (not compounded) */
|
||||
const char *presence_enum; /* "enum foo_PR" */
|
||||
const char *presence_name; /* "foo_PR" */
|
||||
const char *members_enum; /* "enum foo" */
|
||||
const char *members_name; /* "e_foo" */
|
||||
const char *compound_name; /* always contain "parent_foo" */
|
||||
};
|
||||
|
||||
struct c_names c_name(arg_t *);
|
||||
struct c_names c_expr_name(arg_t *, asn1p_expr_t *);
|
||||
const char *c_member_name(arg_t *, asn1p_expr_t *); /* %s_%s */
|
||||
const char *c_presence_name(arg_t *, asn1p_expr_t *); /* %s_PR_%s */
|
||||
|
||||
const char *c_names_format(struct c_names); /* For debugging */
|
||||
|
||||
/*
|
||||
* Returns 0 if no C name clashes have been encountered.
|
||||
* Returns 1 if C name clashes have been encountered.
|
||||
* Prints out the clashing items and suggests -fcompound-names.
|
||||
*/
|
||||
int c_name_clash(arg_t *arg);
|
||||
|
||||
void c_name_clash_finder_init(void);
|
||||
|
||||
void c_name_clash_finder_destroy(void);
|
||||
|
||||
#endif /* ASN1_COMPILER_NAMING_H */
|
|
@ -6,7 +6,8 @@
|
|||
* into appropriate output stream.
|
||||
*/
|
||||
int
|
||||
asn1c_compiled_output(arg_t *arg, const char *fmt, ...) {
|
||||
asn1c_compiled_output(arg_t *arg, const char *source, int lineno, const char *func, const char *fmt,
|
||||
...) {
|
||||
struct compiler_stream_destination_s *dst;
|
||||
const char *p;
|
||||
int lf_found;
|
||||
|
@ -38,15 +39,26 @@ asn1c_compiled_output(arg_t *arg, const char *fmt, ...) {
|
|||
*/
|
||||
if(dst->indented == 0) {
|
||||
int i = dst->indent_level;
|
||||
if (i < 0) {
|
||||
/* fatal error */
|
||||
fprintf(stderr, "target %d : Indent level %d ?!\n", arg->target->target, i);
|
||||
exit(1);
|
||||
}
|
||||
dst->indented = 1;
|
||||
while(i--) {
|
||||
ret = asn1c_compiled_output(arg, "\t");
|
||||
ret = asn1c_compiled_output(arg, source, lineno, func, "\t");
|
||||
if(ret == -1) return -1;
|
||||
}
|
||||
}
|
||||
if(lf_found)
|
||||
dst->indented = 0;
|
||||
|
||||
size_t debug_reserve_size = 0;
|
||||
if(lf_found && (arg->flags & A1C_DEBUG_OUTPUT_ORIGIN_LINES)) {
|
||||
debug_reserve_size =
|
||||
sizeof("\t// :100000 ()") + strlen(source) + strlen(func);
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate buffer.
|
||||
*/
|
||||
|
@ -57,7 +69,7 @@ asn1c_compiled_output(arg_t *arg, const char *fmt, ...) {
|
|||
do {
|
||||
void *tmp;
|
||||
m->len <<= 2;
|
||||
tmp = realloc(m->buf, m->len);
|
||||
tmp = realloc(m->buf, m->len + debug_reserve_size);
|
||||
if(tmp) {
|
||||
m->buf = (char *)tmp;
|
||||
} else {
|
||||
|
@ -72,6 +84,15 @@ asn1c_compiled_output(arg_t *arg, const char *fmt, ...) {
|
|||
|
||||
m->len = ret;
|
||||
|
||||
/* Print out the origin of the lines */
|
||||
if(lf_found && (arg->flags & A1C_DEBUG_OUTPUT_ORIGIN_LINES)) {
|
||||
assert(m->buf[m->len - 1] == '\n');
|
||||
ret = snprintf(m->buf + m->len - 1, debug_reserve_size,
|
||||
"\t// %s:%03d %s()\n", source, lineno, func);
|
||||
assert(ret > 0 && (size_t)ret < debug_reserve_size);
|
||||
m->len = m->len - 1 + ret;
|
||||
}
|
||||
|
||||
if(arg->target->target == OT_INCLUDES
|
||||
|| arg->target->target == OT_FWD_DECLS
|
||||
|| arg->target->target == OT_POST_INCLUDE) {
|
||||
|
|
|
@ -17,9 +17,11 @@ typedef struct compiler_streams {
|
|||
OT_INCLUDES, /* #include files */
|
||||
OT_DEPS, /* Dependencies (other than #includes) */
|
||||
OT_FWD_DECLS, /* Forward declarations */
|
||||
OT_FWD_DEFS, /* Forward definitions */
|
||||
OT_TYPE_DECLS, /* Type declarations */
|
||||
OT_FUNC_DECLS, /* Function declarations */
|
||||
OT_POST_INCLUDE,/* #include after type definition */
|
||||
OT_IOC_TABLES, /* Information Object Class tables */
|
||||
OT_CTABLES, /* Constraint tables */
|
||||
OT_CODE, /* Some code */
|
||||
OT_CTDEFS, /* Constraint definitions */
|
||||
|
@ -35,9 +37,11 @@ typedef struct compiler_streams {
|
|||
} compiler_streams_t;
|
||||
|
||||
static char *_compiler_stream2str[] __attribute__ ((unused))
|
||||
= { "IGNORE", "INCLUDES", "DEPS", "FWD-DECLS", "TYPE-DECLS", "FUNC-DECLS", "POST-INCLUDE", "CTABLES", "CODE", "CTDEFS", "STAT-DEFS" };
|
||||
= { "IGNORE", "INCLUDES", "DEPS", "FWD-DECLS", "FWD-DEFS", "TYPE-DECLS", "FUNC-DECLS", "POST-INCLUDE", "IOC-TABLES", "CTABLES", "CODE", "CTDEFS", "STAT-DEFS" };
|
||||
|
||||
int asn1c_compiled_output(arg_t *arg, const char *fmt, ...);
|
||||
int asn1c_compiled_output(arg_t *arg, const char *file, int lineno,
|
||||
const char *func, const char *fmt, ...)
|
||||
__attribute__((format(printf, 5, 6)));
|
||||
|
||||
|
||||
/*****************************************************************
|
||||
|
@ -55,23 +59,31 @@ int asn1c_compiled_output(arg_t *arg, const char *fmt, ...);
|
|||
INDENT(-1); \
|
||||
} while(0)
|
||||
|
||||
#define EMBED(ev) do { \
|
||||
int saved_target = arg->target->target; \
|
||||
REDIR(OT_TYPE_DECLS); \
|
||||
arg->embed++; \
|
||||
INDENTED(arg_t _tmp = *arg; \
|
||||
_tmp.expr = ev; \
|
||||
_tmp.default_cb(&_tmp); \
|
||||
); \
|
||||
arg->embed--; \
|
||||
if(ev->expr_type != A1TC_EXTENSIBLE) \
|
||||
OUT(";\n"); \
|
||||
assert(arg->target->target == OT_TYPE_DECLS); \
|
||||
REDIR(saved_target); \
|
||||
} while(0)
|
||||
#define EMBED(ev) \
|
||||
do { \
|
||||
arg->embed++; \
|
||||
INDENTED(arg_t _tmp = *arg; _tmp.expr = ev; \
|
||||
_tmp.default_cb(&_tmp, NULL);); \
|
||||
arg->embed--; \
|
||||
if(ev->expr_type != A1TC_EXTENSIBLE) OUT(";\n"); \
|
||||
assert(arg->target->target == OT_TYPE_DECLS \
|
||||
|| arg->target->target == OT_FWD_DEFS); \
|
||||
} while(0)
|
||||
|
||||
#define EMBED_WITH_IOCT(ev, ioc) \
|
||||
do { \
|
||||
arg->embed++; \
|
||||
INDENTED(arg_t _tmp = *arg; _tmp.expr = ev; \
|
||||
_tmp.default_cb(&_tmp, ((ioc).ioct ? &ioc : 0));); \
|
||||
arg->embed--; \
|
||||
if(ev->expr_type != A1TC_EXTENSIBLE) OUT(";\n"); \
|
||||
assert(arg->target->target == OT_TYPE_DECLS \
|
||||
|| arg->target->target == OT_FWD_DEFS); \
|
||||
} while(0)
|
||||
|
||||
/* Output a piece of text into a default stream */
|
||||
#define OUT(fmt, args...) asn1c_compiled_output(arg, fmt, ##args)
|
||||
#define OUT(fmt, args...) \
|
||||
asn1c_compiled_output(arg, __FILE__, __LINE__, __func__, fmt, ##args)
|
||||
#define OUT_NOINDENT(fmt, args...) do { \
|
||||
int _saved_indent = INDENT_LEVEL; \
|
||||
INDENT_LEVEL = 0; \
|
||||
|
@ -105,29 +117,41 @@ int asn1c_compiled_output(arg_t *arg, const char *fmt, ...);
|
|||
} while(0)
|
||||
|
||||
/* Generate ASN.1 type declaration */
|
||||
#define GEN_DECLARE(expr) do { \
|
||||
int saved_target = arg->target->target; \
|
||||
REDIR(OT_FUNC_DECLS); \
|
||||
OUT_NOINDENT("extern asn_TYPE_descriptor_t " \
|
||||
"asn_DEF_%s;\n", MKID(expr)); \
|
||||
REDIR(saved_target); \
|
||||
#define GEN_DECLARE(type_name, expr) do { \
|
||||
int saved_target = arg->target->target; \
|
||||
REDIR(OT_FUNC_DECLS); \
|
||||
OUT_NOINDENT("extern asn_TYPE_descriptor_t " \
|
||||
"asn_DEF_%s;\n", MKID(expr)); \
|
||||
if (expr->_type_referenced) { \
|
||||
OUT_NOINDENT("extern asn_%s_specifics_t " \
|
||||
"asn_SPC_%s_specs_%d;\n", type_name, \
|
||||
MKID(expr), expr->_type_unique_index); \
|
||||
if(expr_elements_count(arg, expr)) \
|
||||
OUT_NOINDENT("extern asn_TYPE_member_t " \
|
||||
"asn_MBR_%s_%d[%d];\n", \
|
||||
MKID(expr), expr->_type_unique_index, \
|
||||
expr_elements_count(arg, expr)); \
|
||||
} \
|
||||
REDIR(saved_target); \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
* Format LONG_MIN according to C90 rules.
|
||||
*/
|
||||
#define OINT(iv) do { \
|
||||
if(iv == (-2147483647L - 1)) \
|
||||
OUT("(-2147483647L - 1)"); \
|
||||
else \
|
||||
OUT("%" PRIdASN, iv); \
|
||||
} while(0)
|
||||
#define OINT(iv) \
|
||||
do { \
|
||||
if(iv == (-2147483647L - 1)) \
|
||||
OUT("(-2147483647L - 1)"); \
|
||||
else \
|
||||
OUT("%s", asn1p_itoa(iv)); \
|
||||
} while(0)
|
||||
|
||||
#define OINTS(iv) do { \
|
||||
if(iv == (-2147483647L - 1)) \
|
||||
OUT("(-2147483647L - 1)"); \
|
||||
else \
|
||||
OUT("% " PRIdASN, iv); \
|
||||
} while(0)
|
||||
#define OINTS(iv) \
|
||||
do { \
|
||||
if(iv == (-2147483647L - 1)) \
|
||||
OUT("(-2147483647L - 1)"); \
|
||||
else \
|
||||
OUT("%s%s", (iv >= 0) ? " " : "", asn1p_itoa(iv)); \
|
||||
} while(0)
|
||||
|
||||
#endif /* ASN1_COMPILED_OUTPUT_H */
|
||||
|
|
|
@ -32,179 +32,423 @@ static size_t safe_fwrite(const void *ptr, size_t size, size_t nitems, FILE *str
|
|||
? safe_fprintf(fp_h, "#include \"%s\"\n", s) \
|
||||
: safe_fprintf(fp_h, "#include <%s>\n", s)) \
|
||||
|
||||
static int asn1c_dump_streams(arg_t *arg, asn1c_fdeps_t *, int, char **);
|
||||
enum include_type_result {
|
||||
TI_NOT_INCLUDED,
|
||||
TI_INCLUDED_FROM_BULK,
|
||||
TI_INCLUDED_FROM_CMDLINE
|
||||
};
|
||||
|
||||
static int asn1c_dump_streams(arg_t *arg, asn1c_dep_chainset *, const char *, int, char **);
|
||||
static int asn1c_print_streams(arg_t *arg);
|
||||
static int asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *, int, char **);
|
||||
static int asn1c_copy_over(arg_t *arg, char *path);
|
||||
static int asn1c_save_streams(arg_t *arg, asn1c_dep_chainset *, const char *,
|
||||
int, char **);
|
||||
static int asn1c_copy_over(arg_t *arg, const char *destdir, const char *path,
|
||||
const char *msg);
|
||||
static int identical_files(const char *fname1, const char *fname2);
|
||||
static int need_to_generate_pdu_collection(arg_t *arg);
|
||||
static int generate_pdu_collection_file(arg_t *arg);
|
||||
static abuf *generate_pdu_collection(arg_t *arg);
|
||||
static int generate_pdu_collection_file(arg_t *arg, const char *destdir);
|
||||
static int generate_preamble(arg_t *, FILE *, int optc, char **argv);
|
||||
static int include_type_to_pdu_collection(arg_t *arg);
|
||||
static void pdu_collection_print_unused_types(arg_t *arg);
|
||||
static enum include_type_result include_type_to_pdu_collection(arg_t *arg);
|
||||
static int pdu_collection_has_unused_types(arg_t *arg);
|
||||
static const char *generate_pdu_C_definition(void);
|
||||
static void asn1c__cleanup_pdu_type(void);
|
||||
static int asn1c__pdu_type_lookup(const char *typename);
|
||||
|
||||
int
|
||||
asn1c_save_compiled_output(arg_t *arg, const char *datadir,
|
||||
int argc, int optc, char **argv) {
|
||||
asn1c_fdeps_t *deps = 0;
|
||||
asn1c_fdeps_t *dlist;
|
||||
asn1p_module_t *mod;
|
||||
FILE *mkf; /* Makefile.am.sample */
|
||||
int i;
|
||||
static int
|
||||
asn1c__save_library_makefile(arg_t *arg, const asn1c_dep_chainset *deps,
|
||||
const char *datadir, const char *destdir,
|
||||
const char *makefile_name) {
|
||||
asn1p_module_t *mod;
|
||||
FILE *mkf;
|
||||
|
||||
deps = asn1c_read_file_dependencies(arg, datadir);
|
||||
if(!deps && datadir) {
|
||||
WARNING("Cannot read file-dependencies information "
|
||||
"from %s\n", datadir);
|
||||
}
|
||||
|
||||
TQ_FOR(mod, &(arg->asn->modules), mod_next) {
|
||||
TQ_FOR(arg->expr, &(mod->members), next) {
|
||||
if(asn1_lang_map[arg->expr->meta_type]
|
||||
[arg->expr->expr_type].type_cb) {
|
||||
if(asn1c_dump_streams(arg, deps, optc, argv))
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Dump out the Makefile template and the rest of the support code.
|
||||
*/
|
||||
if((arg->flags & A1C_PRINT_COMPILED)
|
||||
|| (arg->flags & A1C_OMIT_SUPPORT_CODE)) {
|
||||
return 0; /* Finished */
|
||||
}
|
||||
|
||||
mkf = asn1c_open_file("Makefile.am", ".sample", 0);
|
||||
mkf = asn1c_open_file(destdir, makefile_name, "", 0);
|
||||
if(mkf == NULL) {
|
||||
perror("Makefile.am.sample");
|
||||
perror(makefile_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
safe_fprintf(mkf, "ASN_MODULE_SOURCES=");
|
||||
safe_fprintf(mkf, "ASN_MODULE_SRCS=");
|
||||
TQ_FOR(mod, &(arg->asn->modules), mod_next) {
|
||||
TQ_FOR(arg->expr, &(mod->members), next) {
|
||||
if(asn1_lang_map[arg->expr->meta_type]
|
||||
[arg->expr->expr_type].type_cb) {
|
||||
safe_fprintf(mkf, "\t\\\n\t%s.c",
|
||||
arg->expr->Identifier);
|
||||
safe_fprintf(mkf, "\t\\\n\t%s%s.c", destdir,
|
||||
asn1c_make_identifier(AMI_MASK_ONLY_SPACES, arg->expr, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
safe_fprintf(mkf, "\n\nASN_MODULE_HEADERS=");
|
||||
safe_fprintf(mkf, "\n\nASN_MODULE_HDRS=");
|
||||
TQ_FOR(mod, &(arg->asn->modules), mod_next) {
|
||||
TQ_FOR(arg->expr, &(mod->members), next) {
|
||||
if(asn1_lang_map[arg->expr->meta_type]
|
||||
[arg->expr->expr_type].type_cb) {
|
||||
safe_fprintf(mkf, "\t\\\n\t%s.h",
|
||||
arg->expr->Identifier);
|
||||
}
|
||||
safe_fprintf(
|
||||
mkf, "\t\\\n\t%s%s.h", destdir,
|
||||
asn1c_make_identifier(AMI_MASK_ONLY_SPACES, arg->expr, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
safe_fprintf(mkf, "\n\n");
|
||||
|
||||
/*
|
||||
* Move necessary skeleton files and add them to Makefile.am.sample.
|
||||
* Move necessary skeleton files and add them to Makefile.am.targets.
|
||||
*/
|
||||
dlist = asn1c_deps_makelist(deps);
|
||||
if(dlist) {
|
||||
char buf[8129];
|
||||
asn1c_dep_chain *dlist = asn1c_deps_flatten(deps, ~FDEP_CONVERTER);
|
||||
if(dlist) {
|
||||
char dstpath[PATH_MAX];
|
||||
char *dir_end;
|
||||
size_t dlen = strlen(datadir);
|
||||
|
||||
assert(dlen < (sizeof(buf) / 2 - 2));
|
||||
memcpy(buf, datadir, dlen);
|
||||
dir_end = buf + dlen;
|
||||
assert(dlen < (sizeof(dstpath) / 2 - 2));
|
||||
memcpy(dstpath, datadir, dlen);
|
||||
dir_end = dstpath + dlen;
|
||||
*dir_end++ = '/';
|
||||
|
||||
for(i = 0; i < dlist->el_count; i++) {
|
||||
char *what_class; /* MODULE or CONVERTER */
|
||||
char *what_kind; /* HEADERS or SOURCES */
|
||||
char *fname = dlist->elements[i]->filename;
|
||||
for(size_t i = 0; i < dlist->deps_count; i++) {
|
||||
char where[32]; /* Location of the */
|
||||
char *what_kind; /* HDRS or SRCS */
|
||||
const asn1c_dep_filename *dep_file = dlist->deps[i];
|
||||
char *fname = dep_file->filename;
|
||||
char *dotH;
|
||||
|
||||
assert(strlen(fname) < (sizeof(buf) / 2));
|
||||
assert(strlen(fname) < (sizeof(dstpath) / 2));
|
||||
strcpy(dir_end, fname);
|
||||
|
||||
if(asn1c_copy_over(arg, buf) == -1) {
|
||||
safe_fprintf(mkf, ">>>ABORTED<<<");
|
||||
if(arg->flags & A1C_DEBUG) {
|
||||
snprintf(where, sizeof(where), "(line %d col %d)",
|
||||
dep_file->lineno, dep_file->column);
|
||||
} else {
|
||||
where[0] = '\0';
|
||||
}
|
||||
|
||||
if(asn1c_copy_over(arg, destdir, dstpath, where) == -1) {
|
||||
safe_fprintf(mkf, ">>>ABORTED<<<");
|
||||
fclose(mkf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* MODULE data versus CONVERTER data */
|
||||
switch(dlist->elements[i]->usage) {
|
||||
case FDEP_CONVERTER: what_class = "CONVERTER"; break;
|
||||
default: what_class= "MODULE"; break;
|
||||
}
|
||||
|
||||
/* HEADERS versus SOURCES */
|
||||
/* HDRS versus SRCS */
|
||||
dotH = strrchr(fname, 'h');
|
||||
if(dotH && fname<dotH && dotH[-1] == '.' && !dotH[1])
|
||||
what_kind = "HEADERS";
|
||||
else
|
||||
what_kind = "SOURCES";
|
||||
safe_fprintf(mkf, "ASN_%s_%s+=%s\n",
|
||||
what_class, what_kind, fname);
|
||||
if(dotH && fname < dotH && dotH[-1] == '.' && !dotH[1]) {
|
||||
what_kind = "HDRS";
|
||||
} else {
|
||||
what_kind = "SRCS";
|
||||
}
|
||||
safe_fprintf(mkf, "ASN_MODULE_%s+=%s%s\n", what_kind, destdir,
|
||||
fname);
|
||||
}
|
||||
|
||||
asn1c_dep_chain_free(dlist);
|
||||
}
|
||||
|
||||
safe_fprintf(
|
||||
mkf,
|
||||
"\n"
|
||||
"ASN_MODULE_CFLAGS=%s%s",
|
||||
(arg->flags & A1C_GEN_OER) ? "" : "-DASN_DISABLE_OER_SUPPORT ",
|
||||
(arg->flags & A1C_GEN_PER) ? "" : "-DASN_DISABLE_PER_SUPPORT ");
|
||||
|
||||
safe_fprintf(
|
||||
mkf,
|
||||
"\n\n"
|
||||
"lib_LTLIBRARIES+=libasncodec.la\n"
|
||||
"libasncodec_la_SOURCES="
|
||||
"$(ASN_MODULE_SRCS) $(ASN_MODULE_HDRS)\n"
|
||||
"libasncodec_la_CPPFLAGS=-I$(top_srcdir)/%s\n"
|
||||
"libasncodec_la_CFLAGS=$(ASN_MODULE_CFLAGS)\n"
|
||||
"libasncodec_la_LDFLAGS=-lm\n", destdir);
|
||||
fclose(mkf);
|
||||
safe_fprintf(stderr, "Generated %s%s\n", destdir, makefile_name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
asn1c__save_example_mk_makefile(arg_t *arg, const asn1c_dep_chainset *deps,
|
||||
const char *datadir, const char *destdir,
|
||||
const char *makefile_name,
|
||||
const char *library_makefile_name, int argc,
|
||||
char **argv) {
|
||||
FILE *mkf;
|
||||
asn1c_dep_chain *dlist = asn1c_deps_flatten(deps, FDEP_CONVERTER);
|
||||
|
||||
/* Generate converter-example.mk snippet */
|
||||
mkf = asn1c_open_file(destdir, makefile_name, "", 0);
|
||||
if(mkf == NULL) {
|
||||
perror(makefile_name);
|
||||
return -1;
|
||||
}
|
||||
safe_fprintf(
|
||||
mkf,
|
||||
"include %s%s\n\n"
|
||||
"LIBS += -lm\n"
|
||||
"CFLAGS += $(ASN_MODULE_CFLAGS) %s%s-I.\n"
|
||||
"ASN_LIBRARY ?= libasncodec.a\n"
|
||||
"ASN_PROGRAM ?= converter-example\n"
|
||||
"ASN_PROGRAM_SRCS ?= ",
|
||||
destdir, library_makefile_name,
|
||||
(arg->flags & A1C_PDU_TYPE) ? generate_pdu_C_definition() : "",
|
||||
need_to_generate_pdu_collection(arg) ? "-DASN_PDU_COLLECTION " : "");
|
||||
|
||||
if(dlist) {
|
||||
for(size_t i = 0; i < dlist->deps_count; i++) {
|
||||
char dstpath[PATH_MAX];
|
||||
int ret = snprintf(dstpath, sizeof(dstpath), "%s/%s", datadir,
|
||||
dlist->deps[i]->filename);
|
||||
assert(ret > 0 && (size_t)ret < sizeof(dstpath));
|
||||
if(asn1c_copy_over(arg, destdir, dstpath, "implicit") == -1) {
|
||||
safe_fprintf(mkf, ">>>ABORTED<<<");
|
||||
fclose(mkf);
|
||||
return -1;
|
||||
}
|
||||
safe_fprintf(mkf, "\\\n\t%s%s", destdir, dlist->deps[i]->filename);
|
||||
}
|
||||
asn1c_dep_chain_free(dlist);
|
||||
}
|
||||
|
||||
if(need_to_generate_pdu_collection(arg)) {
|
||||
safe_fprintf(mkf, "\\\n\t%spdu_collection.c", destdir);
|
||||
if(generate_pdu_collection_file(arg, destdir)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
safe_fprintf(
|
||||
mkf,
|
||||
"\n\nall: $(ASN_PROGRAM)\n"
|
||||
"\n$(ASN_PROGRAM): $(ASN_LIBRARY) $(ASN_PROGRAM_SRCS:.c=.o)"
|
||||
"\n\t$(CC) $(CFLAGS) $(CPPFLAGS) -o $(ASN_PROGRAM) "
|
||||
"$(ASN_PROGRAM_SRCS:.c=.o) $(LDFLAGS) $(ASN_LIBRARY) $(LIBS)\n"
|
||||
"\n$(ASN_LIBRARY): $(ASN_MODULE_SRCS:.c=.o)"
|
||||
"\n\t$(AR) rcs $@ $(ASN_MODULE_SRCS:.c=.o)\n"
|
||||
"\n.SUFFIXES:"
|
||||
"\n.SUFFIXES: .c .o\n"
|
||||
"\n.c.o:"
|
||||
"\n\t$(CC) $(CFLAGS) -o $@ -c $<\n"
|
||||
"\nclean:"
|
||||
"\n\trm -f $(ASN_PROGRAM) $(ASN_LIBRARY)"
|
||||
"\n\trm -f $(ASN_MODULE_SRCS:.c=.o) $(ASN_PROGRAM_SRCS:.c=.o)\n"
|
||||
"\nregen: regenerate-from-asn1-source\n"
|
||||
"\nregenerate-from-asn1-source:\n\t");
|
||||
|
||||
for(int i = 0; i < argc; i++)
|
||||
safe_fprintf(mkf, "%s%s", i ? " " : "", argv[i]);
|
||||
safe_fprintf(mkf, "\n\n");
|
||||
|
||||
fclose(mkf);
|
||||
safe_fprintf(stderr, "Generated %s%s\n", destdir, makefile_name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
asn1c__save_example_am_makefile(arg_t *arg, const asn1c_dep_chainset *deps, const char *datadir,
|
||||
const char *destdir, const char *makefile_name,
|
||||
const char *library_makefile_name, int argc,
|
||||
char **argv) {
|
||||
FILE *mkf;
|
||||
asn1c_dep_chain *dlist = asn1c_deps_flatten(deps, FDEP_CONVERTER);
|
||||
|
||||
/* Generate example.am snippet */
|
||||
mkf = asn1c_open_file(destdir, makefile_name, "", 0);
|
||||
if(mkf == NULL) {
|
||||
return -1;
|
||||
}
|
||||
safe_fprintf(mkf,
|
||||
"include %s%s\n\n"
|
||||
"bin_PROGRAMS += asn1convert\n"
|
||||
"asn1convert_CFLAGS = $(ASN_MODULE_CFLAGS) %s%s\n"
|
||||
"asn1convert_CPPFLAGS = -I$(top_srcdir)/%s\n"
|
||||
"asn1convert_LDADD = libasncodec.la\n"
|
||||
"asn1convert_SOURCES = ",
|
||||
destdir, library_makefile_name,
|
||||
(arg->flags & A1C_PDU_TYPE) ? generate_pdu_C_definition() : "",
|
||||
need_to_generate_pdu_collection(arg) ? "-DASN_PDU_COLLECTION " : "", destdir);
|
||||
|
||||
if(dlist) {
|
||||
for(size_t i = 0; i < dlist->deps_count; i++) {
|
||||
char dstpath[PATH_MAX];
|
||||
int ret = snprintf(dstpath, sizeof(dstpath), "%s/%s", datadir,
|
||||
dlist->deps[i]->filename);
|
||||
assert(ret > 0 && (size_t)ret < sizeof(dstpath));
|
||||
if(asn1c_copy_over(arg, destdir, dstpath, "implicit") == -1) {
|
||||
safe_fprintf(mkf, ">>>ABORTED<<<");
|
||||
fclose(mkf);
|
||||
return -1;
|
||||
}
|
||||
safe_fprintf(mkf, "\\\n\t%s%s", destdir, dlist->deps[i]->filename);
|
||||
}
|
||||
asn1c_dep_chain_free(dlist);
|
||||
}
|
||||
|
||||
if(need_to_generate_pdu_collection(arg)) {
|
||||
safe_fprintf(mkf, "ASN_CONVERTER_SOURCES+=pdu_collection.c\n");
|
||||
if(generate_pdu_collection_file(arg))
|
||||
safe_fprintf(mkf, "\\\n\t%spdu_collection.c", destdir);
|
||||
if(generate_pdu_collection_file(arg, destdir))
|
||||
return -1;
|
||||
}
|
||||
|
||||
safe_fprintf(mkf, "\n\n"
|
||||
"lib_LTLIBRARIES=libsomething.la\n"
|
||||
"libsomething_la_SOURCES="
|
||||
"$(ASN_MODULE_SOURCES) $(ASN_MODULE_HEADERS)\n"
|
||||
"\n"
|
||||
"# This file may be used as an input for make(3)\n"
|
||||
"# Remove the lines below to convert it into a pure .am file\n"
|
||||
"TARGET = progname\n"
|
||||
"CFLAGS +=%s%s -I.\n"
|
||||
"OBJS=${ASN_MODULE_SOURCES:.c=.o}"
|
||||
" ${ASN_CONVERTER_SOURCES:.c=.o}\n"
|
||||
"\nall: $(TARGET)\n"
|
||||
"\n$(TARGET): ${OBJS}"
|
||||
"\n\t$(CC) $(CFLAGS) -o $(TARGET) ${OBJS} $(LDFLAGS) $(LIBS)\n"
|
||||
"\n.SUFFIXES:"
|
||||
"\n.SUFFIXES: .c .o\n"
|
||||
"\n.c.o:"
|
||||
"\n\t$(CC) $(CFLAGS) -o $@ -c $<\n"
|
||||
"\nclean:"
|
||||
"\n\trm -f $(TARGET)"
|
||||
"\n\trm -f $(OBJS)\n"
|
||||
"\nregen: regenerate-from-asn1-source\n"
|
||||
"\nregenerate-from-asn1-source:\n\t"
|
||||
, (arg->flags & A1C_PDU_TYPE)
|
||||
? generate_pdu_C_definition() : ""
|
||||
, need_to_generate_pdu_collection(arg)
|
||||
? " -DASN_PDU_COLLECTION" : ""
|
||||
);
|
||||
safe_fprintf(mkf,
|
||||
"\nregen: regenerate-from-asn1-source\n"
|
||||
"\nregenerate-from-asn1-source:\n\t");
|
||||
|
||||
for(i = 0; i < argc; i++)
|
||||
for(int i = 0; i < argc; i++)
|
||||
safe_fprintf(mkf, "%s%s", i ? " " : "", argv[i]);
|
||||
safe_fprintf(mkf, "\n\n");
|
||||
|
||||
fclose(mkf);
|
||||
safe_fprintf(stderr, "Generated Makefile.am.sample\n");
|
||||
safe_fprintf(stderr, "Generated %s%s\n", destdir, makefile_name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
asn1c__save_autotools_example(const char *destdir,
|
||||
const char *program_makefile_name) {
|
||||
FILE *fd;
|
||||
const char* confac = "configure.ac";
|
||||
const char* makeam = "Makefile.am";
|
||||
|
||||
if ((access(confac, F_OK) != -1)
|
||||
|| (access(makeam, F_OK) != -1))
|
||||
{
|
||||
safe_fprintf(stderr, "Refusing to overwrite existing '%s' or '%s'\n", confac, makeam);
|
||||
return -1;
|
||||
}
|
||||
|
||||
fd = asn1c_open_file("", confac, "", 0);
|
||||
if(fd == NULL) {
|
||||
perror(confac);
|
||||
return -1;
|
||||
}
|
||||
|
||||
safe_fprintf(fd,
|
||||
"AC_INIT([asn1convert],[0.1])\n"
|
||||
"AM_INIT_AUTOMAKE([-Werror foreign subdir-objects])\n"
|
||||
"AC_PREREQ([2.62])\n"
|
||||
"AC_PROG_CC\n"
|
||||
"LT_INIT\n"
|
||||
"AM_SILENT_RULES([yes])\n"
|
||||
"AC_CONFIG_FILES([Makefile])\n"
|
||||
"AC_OUTPUT\n");
|
||||
fclose(fd);
|
||||
safe_fprintf(stderr, "Generated minimal example %s\n", confac);
|
||||
|
||||
fd = asn1c_open_file("", makeam, "", 0);
|
||||
if(fd == NULL) {
|
||||
perror(makeam);
|
||||
return -1;
|
||||
}
|
||||
|
||||
safe_fprintf(fd,
|
||||
"bin_PROGRAMS =\n"
|
||||
"lib_LTLIBRARIES =\n"
|
||||
"include %s%s\n\n",
|
||||
destdir, program_makefile_name);
|
||||
|
||||
fclose(fd);
|
||||
safe_fprintf(stderr, "Generated minimal example %s\n", makeam);
|
||||
safe_fprintf(stderr, "\nRun the following to generate a configure script:\n");
|
||||
safe_fprintf(stderr, "$ autoreconf --force --install\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
can_generate_pdu_collection(arg_t *arg) {
|
||||
abuf *buf = generate_pdu_collection(arg);
|
||||
if(!buf) {
|
||||
return -1;
|
||||
}
|
||||
abuf_free(buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
asn1c_save_compiled_output(arg_t *arg, const char *datadir, const char *destdir,
|
||||
int argc, int optc, char **argv) {
|
||||
int ret = -1;
|
||||
|
||||
const char* example_am_makefile = "Makefile.am.asn1convert";
|
||||
const char* program_makefile = "converter-example.mk";
|
||||
const char* library_makefile = "Makefile.am.libasncodec";
|
||||
|
||||
/*
|
||||
* Early check that we can properly generate PDU collection.
|
||||
*/
|
||||
if(can_generate_pdu_collection(arg) == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
asn1c_dep_chainset *deps;
|
||||
do {
|
||||
asn1p_module_t *mod;
|
||||
|
||||
deps = asn1c_read_file_dependencies(arg, datadir);
|
||||
if(!deps && datadir) {
|
||||
WARNING(
|
||||
"Cannot read file-dependencies information "
|
||||
"from %s\n",
|
||||
datadir);
|
||||
}
|
||||
|
||||
TQ_FOR(mod, &(arg->asn->modules), mod_next) {
|
||||
TQ_FOR(arg->expr, &(mod->members), next) {
|
||||
if(asn1_lang_map[arg->expr->meta_type][arg->expr->expr_type]
|
||||
.type_cb) {
|
||||
ret = asn1c_dump_streams(arg, deps, destdir, optc, argv);
|
||||
if(ret) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Dump out the Makefile template and the rest of the support code.
|
||||
*/
|
||||
if((arg->flags & A1C_PRINT_COMPILED)
|
||||
|| (arg->flags & A1C_OMIT_SUPPORT_CODE)) {
|
||||
ret = 0; /* Success */
|
||||
break;
|
||||
}
|
||||
|
||||
if(ret) break;
|
||||
|
||||
ret = asn1c__save_library_makefile(arg, deps, datadir, destdir,
|
||||
library_makefile);
|
||||
if(ret) break;
|
||||
|
||||
if(arg->flags & A1C_GEN_EXAMPLE) {
|
||||
ret = asn1c__save_example_mk_makefile(arg, deps, datadir, destdir,
|
||||
program_makefile,
|
||||
library_makefile, argc, argv);
|
||||
if(ret) break;
|
||||
ret = asn1c__save_example_am_makefile(arg, deps, datadir, destdir,
|
||||
example_am_makefile,
|
||||
library_makefile, argc, argv);
|
||||
if(ret) break;
|
||||
|
||||
if(arg->flags & A1C_GEN_AUTOTOOLS_EXAMPLE) {
|
||||
ret = asn1c__save_autotools_example(destdir, example_am_makefile);
|
||||
if(ret) break;
|
||||
}
|
||||
}
|
||||
} while(0);
|
||||
|
||||
asn1c_dep_chainset_free(deps);
|
||||
asn1c__cleanup_pdu_type();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Dump the streams.
|
||||
*/
|
||||
static int
|
||||
asn1c_dump_streams(arg_t *arg, asn1c_fdeps_t *deps, int optc, char **argv) {
|
||||
if(arg->flags & A1C_PRINT_COMPILED) {
|
||||
asn1c_dump_streams(arg_t *arg, asn1c_dep_chainset *deps, const char *destdir,
|
||||
int optc, char **argv) {
|
||||
if(arg->flags & A1C_PRINT_COMPILED) {
|
||||
return asn1c_print_streams(arg);
|
||||
} else {
|
||||
return asn1c_save_streams(arg, deps, optc, argv);
|
||||
return asn1c_save_streams(arg, deps, destdir, optc, argv);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -232,16 +476,18 @@ asn1c_print_streams(arg_t *arg) {
|
|||
}
|
||||
|
||||
static int
|
||||
asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps, int optc, char **argv) {
|
||||
asn1p_expr_t *expr = arg->expr;
|
||||
asn1c_save_streams(arg_t *arg, asn1c_dep_chainset *deps, const char *destdir,
|
||||
int optc, char **argv) {
|
||||
asn1p_expr_t *expr = arg->expr;
|
||||
compiler_streams_t *cs = expr->data;
|
||||
out_chunk_t *ot;
|
||||
FILE *fp_c, *fp_h;
|
||||
char *tmpname_c, *tmpname_h;
|
||||
char *name_buf;
|
||||
char *header_id;
|
||||
char name_buf[FILENAME_MAX];
|
||||
const char *header_id;
|
||||
const char *c_retained = "";
|
||||
const char *h_retained = "";
|
||||
char *filename;
|
||||
|
||||
if(cs == NULL) {
|
||||
safe_fprintf(stderr, "Cannot compile %s at line %d\n",
|
||||
|
@ -249,13 +495,18 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps, int optc, char **argv) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
fp_c = asn1c_open_file(expr->Identifier, ".c", &tmpname_c);
|
||||
fp_h = asn1c_open_file(expr->Identifier, ".h", &tmpname_h);
|
||||
if(fp_c == NULL || fp_h == NULL) {
|
||||
if(fp_c) { unlink(tmpname_c); free(tmpname_c); fclose(fp_c); }
|
||||
if(fp_h) { unlink(tmpname_h); free(tmpname_h); fclose(fp_h); }
|
||||
return -1;
|
||||
}
|
||||
filename = strdup(asn1c_make_identifier(AMI_MASK_ONLY_SPACES, expr, (char*)0));
|
||||
fp_c = asn1c_open_file(destdir, filename, ".c", &tmpname_c);
|
||||
if(fp_c == NULL) {
|
||||
return -1;
|
||||
}
|
||||
fp_h = asn1c_open_file(destdir, filename, ".h", &tmpname_h);
|
||||
if(fp_h == NULL) {
|
||||
unlink(tmpname_c);
|
||||
free(tmpname_c);
|
||||
fclose(fp_c);
|
||||
return -1;
|
||||
}
|
||||
|
||||
generate_preamble(arg, fp_c, optc, argv);
|
||||
generate_preamble(arg, fp_h, optc, argv);
|
||||
|
@ -273,7 +524,7 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps, int optc, char **argv) {
|
|||
if(TQ_FIRST(&(cs->destination[idx].chunks)) && *msg) \
|
||||
safe_fprintf(fp, "\n/* %s */\n", msg); \
|
||||
TQ_FOR(ot, &(cs->destination[idx].chunks), next) { \
|
||||
if(actdep) asn1c_activate_dependency(deps, 0, ot->buf); \
|
||||
if(actdep) asn1c_activate_dependency(deps, ot->buf, header_id); \
|
||||
safe_fwrite(ot->buf, ot->len, 1, fp); \
|
||||
} \
|
||||
} while(0)
|
||||
|
@ -283,6 +534,7 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps, int optc, char **argv) {
|
|||
safe_fprintf(fp_h, "\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n");
|
||||
SAVE_STREAM(fp_h, OT_DEPS, "Dependencies", 0);
|
||||
SAVE_STREAM(fp_h, OT_FWD_DECLS, "Forward declarations", 0);
|
||||
SAVE_STREAM(fp_h, OT_FWD_DEFS, "Forward definitions", 0);
|
||||
SAVE_STREAM(fp_h, OT_TYPE_DECLS, expr->Identifier, 0);
|
||||
SAVE_STREAM(fp_h, OT_FUNC_DECLS,"Implementation", 0);
|
||||
safe_fprintf(fp_h, "\n#ifdef __cplusplus\n}\n#endif\n");
|
||||
|
@ -293,9 +545,11 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps, int optc, char **argv) {
|
|||
safe_fprintf(fp_h, "\n#endif\t/* _%s_H_ */\n", header_id);
|
||||
|
||||
HINCLUDE("asn_internal.h");
|
||||
safe_fprintf(fp_c, "#include \"%s.h\"\n\n", expr->Identifier);
|
||||
safe_fprintf(fp_c, "#include \"%s.h\"\n\n", filename);
|
||||
if(arg->flags & A1C_NO_INCLUDE_DEPS)
|
||||
SAVE_STREAM(fp_c, OT_POST_INCLUDE, "", 1);
|
||||
TQ_FOR(ot, &(cs->destination[OT_IOC_TABLES].chunks), next)
|
||||
safe_fwrite(ot->buf, ot->len, 1, fp_c);
|
||||
TQ_FOR(ot, &(cs->destination[OT_CTABLES].chunks), next)
|
||||
safe_fwrite(ot->buf, ot->len, 1, fp_c);
|
||||
TQ_FOR(ot, &(cs->destination[OT_CODE].chunks), next)
|
||||
|
@ -305,14 +559,14 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps, int optc, char **argv) {
|
|||
TQ_FOR(ot, &(cs->destination[OT_STAT_DEFS].chunks), next)
|
||||
safe_fwrite(ot->buf, ot->len, 1, fp_c);
|
||||
|
||||
assert(OT_MAX == 11); /* Protection from reckless changes */
|
||||
assert(OT_MAX == 13); /* Protection from reckless changes */
|
||||
|
||||
fclose(fp_c);
|
||||
fclose(fp_h);
|
||||
|
||||
name_buf = alloca(strlen(expr->Identifier) + 3);
|
||||
int ret = snprintf(name_buf, sizeof(name_buf), "%s%s.c", destdir, filename);
|
||||
assert(ret > 0 && ret < (ssize_t)sizeof(name_buf));
|
||||
|
||||
sprintf(name_buf, "%s.c", expr->Identifier);
|
||||
if(identical_files(name_buf, tmpname_c)) {
|
||||
c_retained = " (contents unchanged)";
|
||||
unlink(tmpname_c);
|
||||
|
@ -326,7 +580,7 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps, int optc, char **argv) {
|
|||
}
|
||||
}
|
||||
|
||||
sprintf(name_buf, "%s.h", expr->Identifier);
|
||||
sprintf(name_buf, "%s%s.h", destdir, filename);
|
||||
if(identical_files(name_buf, tmpname_h)) {
|
||||
h_retained = " (contents unchanged)";
|
||||
unlink(tmpname_h);
|
||||
|
@ -343,10 +597,11 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps, int optc, char **argv) {
|
|||
free(tmpname_c);
|
||||
free(tmpname_h);
|
||||
|
||||
safe_fprintf(stderr, "Compiled %s.c%s\n",
|
||||
expr->Identifier, c_retained);
|
||||
safe_fprintf(stderr, "Compiled %s.h%s\n",
|
||||
expr->Identifier, h_retained);
|
||||
safe_fprintf(stderr, "Compiled %s%s.c%s\n",
|
||||
destdir, filename, c_retained);
|
||||
safe_fprintf(stderr, "Compiled %s%s.h%s\n",
|
||||
destdir, filename, h_retained);
|
||||
free(filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -422,7 +677,7 @@ real_copy(const char *src, const char *dst) {
|
|||
|
||||
fpsrc = fopen(src, "r");
|
||||
if(!fpsrc) { errno = EIO; return -1; }
|
||||
fpdst = asn1c_open_file(dst, "", &tmpname);
|
||||
fpdst = asn1c_open_file(NULL, dst, "", &tmpname);
|
||||
if(!fpdst) { fclose(fpsrc); errno = EIO; return -1; }
|
||||
|
||||
while(!feof(fpsrc)) {
|
||||
|
@ -450,15 +705,15 @@ real_copy(const char *src, const char *dst) {
|
|||
}
|
||||
|
||||
static int
|
||||
asn1c_copy_over(arg_t *arg, char *path) {
|
||||
char *fname;
|
||||
asn1c_copy_over(arg_t *arg, const char *destdir, const char *path,
|
||||
const char *msg) {
|
||||
#ifdef _WIN32
|
||||
int use_real_copy = 1;
|
||||
#else
|
||||
int use_real_copy = !(arg->flags & A1C_LINK_SKELETONS);
|
||||
#endif
|
||||
|
||||
fname = a1c_basename(path);
|
||||
const char *fname = a1c_basename(path, destdir);
|
||||
if(!fname
|
||||
|| (use_real_copy ? real_copy(path, fname) : symlink(path, fname))
|
||||
) {
|
||||
|
@ -492,87 +747,112 @@ asn1c_copy_over(arg_t *arg, char *path) {
|
|||
}
|
||||
}
|
||||
|
||||
safe_fprintf(stderr, "%s %s\t-> %s\n",
|
||||
use_real_copy ? "Copied" : "Symlinked", path, fname);
|
||||
const int has_msg = msg && *msg;
|
||||
safe_fprintf(stderr, "%s %s\t-> %s%s%s\n",
|
||||
use_real_copy ? "Copied" : "Symlinked", path, fname,
|
||||
has_msg ? " " : "", has_msg ? msg : "");
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
generate_pdu_collection_file(arg_t *arg) {
|
||||
asn1p_module_t *mod;
|
||||
FILE *fp;
|
||||
generate_pdu_collection_file(arg_t *arg, const char *destdir) {
|
||||
abuf *buf = generate_pdu_collection(arg);
|
||||
assert(buf);
|
||||
|
||||
fp = asn1c_open_file("pdu_collection", ".c", 0);
|
||||
FILE *fp = asn1c_open_file(destdir, "pdu_collection", ".c", 0);
|
||||
if(fp == NULL) {
|
||||
perror("pdu_collection.c");
|
||||
return -1;
|
||||
}
|
||||
safe_fwrite(buf->buffer, buf->length, 1, fp);
|
||||
fclose(fp);
|
||||
|
||||
safe_fprintf(fp,
|
||||
"/*\n"
|
||||
" * Generated by asn1c-" VERSION " (http://lionet.info/asn1c)\n"
|
||||
" */\n\n");
|
||||
safe_fprintf(fp, "struct asn_TYPE_descriptor_s;\t"
|
||||
"/* Forward declaration */\n\n");
|
||||
|
||||
TQ_FOR(mod, &(arg->asn->modules), mod_next) {
|
||||
TQ_FOR(arg->expr, &(mod->members), next) {
|
||||
if(!include_type_to_pdu_collection(arg))
|
||||
continue;
|
||||
safe_fprintf(fp, "extern struct asn_TYPE_descriptor_s "
|
||||
"asn_DEF_%s;\n",
|
||||
asn1c_make_identifier(0, arg->expr, NULL));
|
||||
}
|
||||
}
|
||||
|
||||
safe_fprintf(fp, "\n\n");
|
||||
safe_fprintf(fp, "struct asn_TYPE_descriptor_s *asn_pdu_collection[] = {\n");
|
||||
TQ_FOR(mod, &(arg->asn->modules), mod_next) {
|
||||
int mod_printed = 0;
|
||||
TQ_FOR(arg->expr, &(mod->members), next) {
|
||||
if(!include_type_to_pdu_collection(arg))
|
||||
continue;
|
||||
if(!mod_printed++)
|
||||
safe_fprintf(fp, "\t/* From module %s in %s */\n",
|
||||
arg->expr->module->ModuleName,
|
||||
arg->expr->module->source_file_name);
|
||||
safe_fprintf(fp, "\t&asn_DEF_%s,\t\n",
|
||||
asn1c_make_identifier(0, arg->expr, NULL));
|
||||
}
|
||||
}
|
||||
|
||||
safe_fprintf(fp, "\t0\n};\n\n");
|
||||
|
||||
pdu_collection_print_unused_types(arg);
|
||||
|
||||
fclose(fp);
|
||||
safe_fprintf(stderr, "Generated pdu_collection.c\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
static abuf *
|
||||
generate_pdu_collection(arg_t *arg) {
|
||||
asn1p_module_t *mod;
|
||||
abuf *buf = abuf_new();
|
||||
|
||||
abuf_printf(buf, "/*\n * Generated by asn1c-" VERSION
|
||||
" (http://lionet.info/asn1c)\n */\n\n");
|
||||
abuf_printf(buf,
|
||||
"struct asn_TYPE_descriptor_s;\t"
|
||||
"/* Forward declaration */\n\n");
|
||||
|
||||
|
||||
TQ_FOR(mod, &(arg->asn->modules), mod_next) {
|
||||
TQ_FOR(arg->expr, &(mod->members), next) {
|
||||
if(include_type_to_pdu_collection(arg) == TI_NOT_INCLUDED) continue;
|
||||
abuf_printf(buf,
|
||||
"extern struct asn_TYPE_descriptor_s "
|
||||
"asn_DEF_%s;\n",
|
||||
asn1c_make_identifier(0, arg->expr, NULL));
|
||||
}
|
||||
}
|
||||
|
||||
abuf_printf(buf, "\n\n");
|
||||
abuf_printf(buf, "struct asn_TYPE_descriptor_s *asn_pdu_collection[] = {\n");
|
||||
TQ_FOR(mod, &(arg->asn->modules), mod_next) {
|
||||
int mod_printed = 0;
|
||||
TQ_FOR(arg->expr, &(mod->members), next) {
|
||||
switch(include_type_to_pdu_collection(arg)) {
|
||||
case TI_NOT_INCLUDED:
|
||||
continue;
|
||||
case TI_INCLUDED_FROM_BULK:
|
||||
/* Increment */
|
||||
asn1c__pdu_type_lookup(arg->expr->Identifier);
|
||||
break;
|
||||
case TI_INCLUDED_FROM_CMDLINE:
|
||||
break;
|
||||
}
|
||||
if(!mod_printed++) {
|
||||
abuf_printf(buf, "\t/* From module %s in %s */\n",
|
||||
arg->expr->module->ModuleName,
|
||||
arg->expr->module->source_file_name);
|
||||
}
|
||||
abuf_printf(buf, "\t&asn_DEF_%s,\t\n",
|
||||
asn1c_make_identifier(0, arg->expr, NULL));
|
||||
}
|
||||
}
|
||||
|
||||
abuf_printf(buf, "\t0\n};\n\n");
|
||||
|
||||
if(pdu_collection_has_unused_types(arg)) {
|
||||
abuf_free(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
static struct PDUType {
|
||||
char *typename;
|
||||
int used;
|
||||
} *pduType;
|
||||
static int pduTypes;
|
||||
static size_t pduTypes;
|
||||
|
||||
static const char *
|
||||
generate_pdu_C_definition(void) {
|
||||
const char *src;
|
||||
char *def;
|
||||
const char *src;
|
||||
char *def;
|
||||
char *dst;
|
||||
if(pduTypes == 0) return "";
|
||||
def = malloc(strlen(pduType[0].typename) + 20);
|
||||
assert(def);
|
||||
strcpy(def, " -DPDU=");
|
||||
for(src = pduType[0].typename, dst = def + 7; *src; src++, dst++)
|
||||
if((*dst = *src) == '-')
|
||||
*dst = '_';
|
||||
*dst = 0;
|
||||
return def;
|
||||
if(pduTypes == 0) return "";
|
||||
def = malloc(strlen(pduType[0].typename) + 20);
|
||||
assert(def);
|
||||
strcpy(def, "-DPDU=");
|
||||
for(src = pduType[0].typename, dst = def + 6; *src; src++, dst++) {
|
||||
if((*dst = *src) == '-') {
|
||||
*dst = '_';
|
||||
}
|
||||
}
|
||||
*dst++ = ' ';
|
||||
*dst = 0;
|
||||
return def;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -587,51 +867,80 @@ asn1c__add_pdu_type(const char *ctypename) {
|
|||
pduTypes++;
|
||||
}
|
||||
|
||||
static void
|
||||
asn1c__cleanup_pdu_type() {
|
||||
for(size_t i = 0; i < pduTypes; i++) {
|
||||
free(pduType[i].typename);
|
||||
}
|
||||
free(pduType);
|
||||
pduType = NULL;
|
||||
pduTypes = 0;
|
||||
}
|
||||
|
||||
static int
|
||||
asn1c__pdu_type_lookup(const char *typename) {
|
||||
int i;
|
||||
for(i = 0; i < pduTypes; i++) {
|
||||
struct PDUType *pt = &pduType[i];
|
||||
if(strcmp(pt->typename, typename) == 0) {
|
||||
pt->used++;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
for(size_t i = 0; i < pduTypes; i++) {
|
||||
struct PDUType *pt = &pduType[i];
|
||||
if(strcmp(pt->typename, typename) == 0) {
|
||||
pt->used++;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
need_to_generate_pdu_collection(arg_t *arg) {
|
||||
/* If -pdu=all or -pdu=auto are given, we need to generate one. */
|
||||
if(arg->flags & (A1C_PDU_ALL|A1C_PDU_AUTO))
|
||||
return 1;
|
||||
if(arg->flags & A1C_PDU_TYPE)
|
||||
return (pduTypes > 1) ? 1 : 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pdu_collection_print_unused_types(arg_t *arg) {
|
||||
int i;
|
||||
for(i = 0; i < pduTypes; i++) {
|
||||
struct PDUType *pt = &pduType[i];
|
||||
if(!pt->used) {
|
||||
WARNING("Missing type specified in -pdu=%s",
|
||||
pt->typename);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* If no -pdu=... flags were given, need to do it, too,
|
||||
* effectively producing -pdu=auto.
|
||||
*/
|
||||
if(!(arg->flags & (A1C_PDU_ALL | A1C_PDU_AUTO | A1C_PDU_TYPE))) return 1;
|
||||
|
||||
if(arg->flags & A1C_PDU_TYPE) {
|
||||
return (pduTypes > 1) ? 1 : 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
include_type_to_pdu_collection(arg_t *arg) {
|
||||
if(!asn1_lang_map[arg->expr->meta_type]
|
||||
[arg->expr->expr_type].type_cb)
|
||||
return 0;
|
||||
pdu_collection_has_unused_types(arg_t *arg) {
|
||||
int ret = 0;
|
||||
|
||||
if((arg->flags & A1C_PDU_ALL)
|
||||
|| ((arg->flags & A1C_PDU_AUTO) && !arg->expr->_type_referenced)
|
||||
|| asn1c__pdu_type_lookup(arg->expr->Identifier)) {
|
||||
return 1;
|
||||
}
|
||||
for(size_t i = 0; i < pduTypes; i++) {
|
||||
struct PDUType *pt = &pduType[i];
|
||||
if(!pt->used) {
|
||||
FATAL("Unknown ASN.1 type specified in -pdu=%s", pt->typename);
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static enum include_type_result
|
||||
include_type_to_pdu_collection(arg_t *arg) {
|
||||
if(!asn1_lang_map[arg->expr->meta_type][arg->expr->expr_type].type_cb)
|
||||
return 0;
|
||||
|
||||
/* Parameterized types can't serve as PDU's without instantiation. */
|
||||
if(arg->expr->lhs_params) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if((arg->flags & A1C_PDU_ALL)
|
||||
/* -pdu=auto */
|
||||
|| ((arg->flags & A1C_PDU_AUTO) && !arg->expr->_type_referenced)
|
||||
/* No -pdu=... whatsoever, act as if -pdu=auto */
|
||||
|| (!(arg->flags & (A1C_PDU_ALL | A1C_PDU_AUTO | A1C_PDU_TYPE))
|
||||
&& !arg->expr->_type_referenced)
|
||||
|| asn1c__pdu_type_lookup(arg->expr->Identifier)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef ASN1C_SAVE_H
|
||||
#define ASN1C_SAVE_H
|
||||
|
||||
int asn1c_save_compiled_output(arg_t *arg, const char *datadir,
|
||||
int asn1c_save_compiled_output(arg_t *arg, const char *datadir, const char* destdir,
|
||||
int argc, int optc, char **argv);
|
||||
|
||||
#endif /* ASN1C_SAVE_H */
|
||||
|
|
|
@ -2,19 +2,24 @@
|
|||
#include "asn1c_lang.h"
|
||||
#include "asn1c_out.h"
|
||||
#include "asn1c_save.h"
|
||||
#include "asn1c_ioc.h"
|
||||
#include "asn1c_naming.h"
|
||||
|
||||
static void default_logger_cb(int, const char *fmt, ...);
|
||||
static int asn1c_compile_expr(arg_t *arg);
|
||||
static int asn1c_compile_expr(arg_t *arg, const asn1c_ioc_table_and_objset_t *);
|
||||
static int asn1c_attach_streams(asn1p_expr_t *expr);
|
||||
static int asn1c_detach_streams(asn1p_expr_t *expr);
|
||||
|
||||
int
|
||||
asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags flags,
|
||||
asn1_compile(asn1p_t *asn, const char *datadir, const char *destdir, enum asn1c_flags flags,
|
||||
int argc, int optc, char **argv) {
|
||||
arg_t arg_s;
|
||||
arg_t *arg = &arg_s;
|
||||
asn1p_module_t *mod;
|
||||
int ret;
|
||||
|
||||
c_name_clash_finder_init();
|
||||
|
||||
/*
|
||||
* Initialize target language.
|
||||
*/
|
||||
|
@ -32,6 +37,8 @@ asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags flags,
|
|||
*/
|
||||
TQ_FOR(mod, &(asn->modules), mod_next) {
|
||||
TQ_FOR(arg->expr, &(mod->members), next) {
|
||||
arg->ns = asn1_namespace_new_from_module(mod, 0);
|
||||
|
||||
compiler_streams_t *cs = NULL;
|
||||
|
||||
if(asn1c_attach_streams(arg->expr))
|
||||
|
@ -41,7 +48,7 @@ asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags flags,
|
|||
cs->target = OT_TYPE_DECLS;
|
||||
arg->target = cs;
|
||||
|
||||
ret = asn1c_compile_expr(arg);
|
||||
ret = asn1c_compile_expr(arg, NULL);
|
||||
if(ret) {
|
||||
FATAL("Cannot compile \"%s\" (%x:%x) at line %d",
|
||||
arg->expr->Identifier,
|
||||
|
@ -50,22 +57,47 @@ asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags flags,
|
|||
arg->expr->_lineno);
|
||||
return ret;
|
||||
}
|
||||
|
||||
asn1_namespace_free(arg->ns);
|
||||
arg->ns = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(c_name_clash(arg)) {
|
||||
if(arg->flags & A1C_COMPOUND_NAMES) {
|
||||
FATAL("Name clashes encountered even with -fcompound-names flag");
|
||||
/* Proceed further for better debugging. */
|
||||
} else {
|
||||
FATAL("Use \"-fcompound-names\" flag to asn1c to resolve name clashes");
|
||||
if(arg->flags & A1C_PRINT_COMPILED) {
|
||||
/* Proceed further for better debugging. */
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG("Saving compiled data");
|
||||
|
||||
c_name_clash_finder_destroy();
|
||||
|
||||
/*
|
||||
* Save or print out the compiled result.
|
||||
*/
|
||||
if(asn1c_save_compiled_output(arg, datadir, argc, optc, argv))
|
||||
if(asn1c_save_compiled_output(arg, datadir, destdir, argc, optc, argv))
|
||||
return -1;
|
||||
|
||||
TQ_FOR(mod, &(asn->modules), mod_next) {
|
||||
TQ_FOR(arg->expr, &(mod->members), next) {
|
||||
asn1c_detach_streams(arg->expr);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
asn1c_compile_expr(arg_t *arg) {
|
||||
asn1c_compile_expr(arg_t *arg, const asn1c_ioc_table_and_objset_t *opt_ioc) {
|
||||
asn1p_expr_t *expr = arg->expr;
|
||||
int (*type_cb)(arg_t *);
|
||||
int ret;
|
||||
|
@ -88,11 +120,12 @@ asn1c_compile_expr(arg_t *arg) {
|
|||
DEBUG("Parameterized type %s at line %d: %s (%d)",
|
||||
expr->Identifier, expr->_lineno,
|
||||
expr->specializations.pspecs_count
|
||||
? "compiling" : "unused, skipping");
|
||||
? "compiling" : "unused, skipping",
|
||||
expr->specializations.pspecs_count);
|
||||
for(i = 0; i<expr->specializations.pspecs_count; i++) {
|
||||
arg->expr = expr->specializations
|
||||
.pspec[i].my_clone;
|
||||
ret = asn1c_compile_expr(arg);
|
||||
ret = asn1c_compile_expr(arg, opt_ioc);
|
||||
if(ret) break;
|
||||
}
|
||||
arg->expr = expr; /* Restore */
|
||||
|
@ -159,6 +192,28 @@ asn1c_attach_streams(asn1p_expr_t *expr) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
asn1c_detach_streams(asn1p_expr_t *expr) {
|
||||
compiler_streams_t *cs;
|
||||
out_chunk_t *m;
|
||||
int i;
|
||||
|
||||
if(!expr->data)
|
||||
return 0; /* Already detached? */
|
||||
|
||||
cs = expr->data;
|
||||
for(i = 0; i < OT_MAX; i++) {
|
||||
while((m = TQ_REMOVE(&(cs->destination[i].chunks), next))) {
|
||||
free(m->buf);
|
||||
free(m);
|
||||
}
|
||||
}
|
||||
free(expr->data);
|
||||
expr->data = (void *)NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
default_logger_cb(int _severity, const char *fmt, ...) {
|
||||
va_list ap;
|
||||
|
@ -177,3 +232,55 @@ default_logger_cb(int _severity, const char *fmt, ...) {
|
|||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
static void
|
||||
asn1c_debug_expr_naming(arg_t *arg) {
|
||||
asn1p_expr_t *expr = arg->expr;
|
||||
|
||||
printf("%s: ", expr->Identifier);
|
||||
printf("%s\n", c_names_format(c_name(arg)));
|
||||
|
||||
printf("\n");
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
asn1c_debug_type_naming(asn1p_t *asn, enum asn1c_flags flags,
|
||||
char **asn_type_names) {
|
||||
arg_t arg_s;
|
||||
arg_t *arg = &arg_s;
|
||||
asn1p_module_t *mod;
|
||||
|
||||
memset(arg, 0, sizeof(*arg));
|
||||
arg->logger_cb = default_logger_cb;
|
||||
arg->flags = flags;
|
||||
arg->asn = asn;
|
||||
|
||||
c_name_clash_finder_init();
|
||||
|
||||
/*
|
||||
* Compile each individual top level structure.
|
||||
*/
|
||||
TQ_FOR(mod, &(asn->modules), mod_next) {
|
||||
int namespace_shown = 0;
|
||||
TQ_FOR(arg->expr, &(mod->members), next) {
|
||||
arg->ns = asn1_namespace_new_from_module(mod, 0);
|
||||
|
||||
for(char **t = asn_type_names; *t; t++) {
|
||||
if(strcmp(*t, arg->expr->Identifier) == 0) {
|
||||
if(!namespace_shown) {
|
||||
namespace_shown = 1;
|
||||
printf("Namespace %s\n",
|
||||
asn1_namespace_string(arg->ns));
|
||||
}
|
||||
asn1c_debug_expr_naming(arg);
|
||||
}
|
||||
}
|
||||
|
||||
asn1_namespace_free(arg->ns);
|
||||
arg->ns = 0;
|
||||
}
|
||||
}
|
||||
|
||||
c_name_clash_finder_destroy();
|
||||
}
|
||||
|
||||
|
|
|
@ -56,11 +56,7 @@ enum asn1c_flags {
|
|||
* Symlink support files rather than copy them.
|
||||
*/
|
||||
A1C_LINK_SKELETONS = 0x0800,
|
||||
/*
|
||||
* -gen-PER
|
||||
* Generate PER support code
|
||||
*/
|
||||
A1C_GEN_PER = 0x1000,
|
||||
|
||||
/*
|
||||
* -pdu={all|auto|Type}
|
||||
* Generate PDU table
|
||||
|
@ -77,15 +73,41 @@ enum asn1c_flags {
|
|||
* -fline-refs
|
||||
* Include ASN.1 module's line numbers in comments.
|
||||
*/
|
||||
A1C_LINE_REFS = 0x20000
|
||||
A1C_LINE_REFS = 0x20000,
|
||||
/*
|
||||
* -gen-OER
|
||||
* Generate Octet Encoding Rules support code
|
||||
*/
|
||||
A1C_GEN_OER = 0x40000,
|
||||
/*
|
||||
* -gen-PER
|
||||
* Generate Packed Encoding Rules support code
|
||||
*/
|
||||
A1C_GEN_PER = 0x80000,
|
||||
/*
|
||||
* Generate converter-example.c and converter-example.mk
|
||||
*/
|
||||
A1C_GEN_EXAMPLE = 0x100000,
|
||||
/*
|
||||
* Generate top-level configure.ac and Makefile.am
|
||||
*/
|
||||
A1C_GEN_AUTOTOOLS_EXAMPLE = 0x200000,
|
||||
/*
|
||||
* Print the source of generated lines.
|
||||
* -debug-output-origin-lines
|
||||
*/
|
||||
A1C_DEBUG_OUTPUT_ORIGIN_LINES = 0x400000,
|
||||
};
|
||||
|
||||
/*
|
||||
* Compile the ASN.1 specification.
|
||||
*/
|
||||
int asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags,
|
||||
int asn1_compile(asn1p_t *asn, const char *datadir, const char *destdir, enum asn1c_flags,
|
||||
int argc, int optc, char **argv);
|
||||
|
||||
void asn1c_debug_type_naming(asn1p_t *asn, enum asn1c_flags,
|
||||
char **asn_type_names);
|
||||
|
||||
void asn1c__add_pdu_type(const char *typename);
|
||||
|
||||
#endif /* ASN1_COMPILER_H */
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue