Index: contrib/debian/changelog
===================================================================
--- contrib/debian/changelog	(revision 929)
+++ contrib/debian/changelog	(revision 880)
@@ -1,17 +1,2 @@
-freediameter (1.1.6) UNRELEASED; urgency=low
-
-  * Fix major issue in 1.1.5 preventing to send answers to a received message.
-  * New command-line option: --enable_msg_log=( DROPPED | RECEIVED | SENT | NODELIVER | TIMING )
-  * Improved parsing error handling and Failed-AVP generation.
-  * Added support for some timings measurements in freeDiameter (in the logs)
-  * Fix port handling when using non-default port.
-  * Some cleanups in several dictionary files.
-  * New option to fd_dict_search: AVP_BY_STRUCT
-  * Improved compatibility with C++ compilers.
-  * Cleanups in sessions creation/destruction to avoid memory corruption under stress.
-  * Add support for "include" directive in freeDiameter.conf file.
-
- -- Sebastien Decugis <sdecugis@freediameter.net>  Sun, 03 Mar 2013 07:40:43 +0100
-
 freediameter (1.1.5) UNRELEASED; urgency=low
 
Index: contrib/debian/update_changelog.txt
===================================================================
--- contrib/debian/update_changelog.txt	(revision 929)
+++ contrib/debian/update_changelog.txt	(revision 654)
@@ -1,3 +1,3 @@
-new release: dch -v 1.0.3 -D UNRELEASED --release-heuristic log
+new release: dch -v 1.0.3 -D UNRELEASED
 Simple addition: dch "changelog entry text"
 
Index: contrib/tools/README
===================================================================
--- contrib/tools/README	(revision 953)
+++ contrib/tools/README	(revision 953)
@@ -0,0 +1,2 @@
+org_to_fd.pl converts org files like diameter-rfcs.org to C fragments
+that can be included in freeDiameter code.
Index: contrib/tools/diameter-rfcs.org
===================================================================
--- contrib/tools/diameter-rfcs.org	(revision 953)
+++ contrib/tools/diameter-rfcs.org	(revision 953)
@@ -0,0 +1,188 @@
+| Attribute Name                   | Code | Section | Data        | MUST | MAY | SHLD NOT | MUST NOT | Encr |
+| # RFC 3588 - Diameter #          |      |         |             |      |     |          |          |      |
+| Acct-Interim-Interval            |   85 |   9.8.2 | Unsigned32  | M    | P   |          | V        | Y    |
+| Accounting-Realtime-Required     |  483 |   9.8.7 | Enumerated  | M    | P   |          | V        | Y    |
+| Acct-Multi-Session-Id            |   50 |   9.8.5 | UTF8String  | M    | P   |          | V        | Y    |
+| Accounting-Record-Number         |  485 |   9.8.3 | Unsigned32  | M    | P   |          | V        | Y    |
+| Accounting-Record-Type           |  480 |   9.8.1 | Enumerated  | M    | P   |          | V        | Y    |
+| Accounting-Session-Id            |   44 |   9.8.4 | OctetString | M    | P   |          | V        | Y    |
+| Accounting-Sub-Session-Id        |  287 |   9.8.6 | Unsigned64  | M    | P   |          | V        | Y    |
+| Acct-Application-Id              |  259 |     6.9 | Unsigned32  | M    | P   |          | V        | N    |
+| Auth-Application-Id              |  258 |     6.8 | Unsigned32  | M    | P   |          | V        | N    |
+| Auth-Request-Type                |  274 |     8.7 | Enumerated  | M    | P   |          | V        | N    |
+| Authorization-Lifetime           |  291 |     8.9 | Unsigned32  | M    | P   |          | V        | N    |
+| Auth-Grace-Period                |  276 |    8.10 | Unsigned32  | M    | P   |          | V        | N    |
+| Auth-Session-State               |  277 |    8.11 | Enumerated  | M    | P   |          | V        | N    |
+| Re-Auth-Request-Type             |  285 |    8.12 | Enumerated  | M    | P   |          | V        | N    |
+| Class                            |   25 |    8.20 | OctetString | M    | P   |          | V        | Y    |
+| Destination-Host                 |  293 |     6.5 | DiamIdent   | M    | P   |          | V        | N    |
+| Destination-Realm                |  283 |     6.6 | DiamIdent   | M    | P   |          | V        | N    |
+| Disconnect-Cause                 |  273 |   5.4.3 | Enumerated  | M    | P   |          | V        | N    |
+| E2E-Sequence-AVP                 |  300 |    6.15 | Grouped     | M    | P   |          | V        | Y    |
+| Error-Message                    |  281 |     7.3 | UTF8String  |      | P   |          | V,M      | N    |
+| Error-Reporting-Host             |  294 |     7.4 | DiamIdent   |      | P   |          | V,M      | N    |
+| Event-Timestamp                  |   55 |    8.21 | Time        | M    | P   |          | V        | N    |
+| Experimental-Result              |  297 |     7.6 | Grouped     | M    | P   |          | V        | N    |
+| Experimental-Result-Code         |  298 |     7.7 | Unsigned32  | M    | P   |          | V        | N    |
+| Failed-AVP                       |  279 |     7.5 | Grouped     | M    | P   |          | V        | N    |
+| Firmware-Revision                |  267 |   5.3.4 | Unsigned32  |      |     |          | P,V,M    | N    |
+| Host-IP-Address                  |  257 |   5.3.5 | Address     | M    | P   |          | V        | N    |
+| Inband-Security-Id               |  299 |    6.10 | Unsigned32  | M    | P   |          | V        | N    |
+| Multi-Round-Time-Out             |  272 |    8.19 | Unsigned32  | M    | P   |          | V        | Y    |
+| Origin-Host                      |  264 |     6.3 | DiamIdent   | M    | P   |          | V        | N    |
+| Origin-Realm                     |  296 |     6.4 | DiamIdent   | M    | P   |          | V        | N    |
+| Origin-State-Id                  |  278 |    8.16 | Unsigned32  | M    | P   |          | V        | N    |
+| Product-Name                     |  269 |   5.3.7 | UTF8String  |      |     |          | P,V,M    | N    |
+| Proxy-Host                       |  280 |   6.7.3 | DiamIdent   | M    |     |          | P,V      | N    |
+| Proxy-Info                       |  284 |   6.7.2 | Grouped     | M    |     |          | P,V      | N    |
+| Proxy-State                      |   33 |   6.7.4 | OctetString | M    |     |          | P,V      | N    |
+| Redirect-Host                    |  292 |    6.12 | DiamURI     | M    | P   |          | V        | N    |
+| Redirect-Host-Usage              |  261 |    6.13 | Enumerated  | M    | P   |          | V        | N    |
+| Redirect-Max-Cache-Time          |  262 |    6.14 | Unsigned32  | M    | P   |          | V        | N    |
+| Result-Code                      |  268 |     7.1 | Unsigned32  | M    | P   |          | V        | N    |
+| Route-Record                     |  282 |   6.7.1 | DiamIdent   | M    |     |          | P,V      | N    |
+| Session-Id                       |  263 |     8.8 | UTF8String  | M    | P   |          | V        | Y    |
+| Session-Timeout                  |   27 |    8.13 | Unsigned32  | M    | P   |          | V        | N    |
+| Session-Binding                  |  270 |    8.17 | Unsigned32  | M    | P   |          | V        | Y    |
+| Session-Server-Failover          |  271 |    8.18 | Enumerated  | M    | P   |          | V        | Y    |
+| Supported-Vendor-Id              |  265 |   5.3.6 | Unsigned32  | M    | P   |          | V        | N    |
+| Termination-Cause                |  295 |    8.15 | Enumerated  | M    | P   |          | V        | N    |
+| User-Name                        |    1 |    8.14 | UTF8String  | M    | P   |          | V        | Y    |
+| Vendor-Id                        |  266 |   5.3.3 | Unsigned32  | M    | P   |          | V        | N    |
+| Vendor-Specific-Application-Id   |  260 |    6.11 | Grouped     | M    | P   |          | V        | N    |
+| # RFC 4005 - NAS #               |      |         |             |      |     |          |          |      |
+| NAS-Port                         |    5 |     4.2 | Unsigned32  | M    | P   |          | V        | Y    |
+| NAS-Port-Id                      |   87 |     4.3 | UTF8String  | M    | P   |          | V        | Y    |
+| NAS-Port-Type                    |   61 |     4.4 | Enumerated  | M    | P   |          | V        | Y    |
+| Called-Station-Id                |   30 |     4.5 | UTF8String  | M    | P   |          | V        | Y    |
+| Calling-Station-Id               |   31 |     4.6 | UTF8String  | M    | P   |          | V        | Y    |
+| Connect-Info                     |   77 |     4.7 | UTF8String  | M    | P   |          | V        | Y    |
+| Originating-Line-Info            |   94 |     4.8 | OctetString |      | M,P |          | V        | Y    |
+| Reply-Message                    |   18 |     4.9 | UTF8String  | M    | P   |          | V        | Y    |
+| User-Password                    |    2 |     5.1 | OctetString | M    | P   |          | V        | Y    |
+| Password-Retry                   |   75 |     5.2 | Unsigned32  | M    | P   |          | V        | Y    |
+| Prompt                           |   76 |     5.3 | Enumerated  | M    | P   |          | V        | Y    |
+| CHAP-Auth                        |  402 |     5.4 | Grouped     | M    | P   |          | V        | Y    |
+| CHAP-Algorithm                   |  403 |     5.5 | Enumerated  | M    | P   |          | V        | Y    |
+| CHAP-Ident                       |  404 |     5.6 | OctetString | M    | P   |          | V        | Y    |
+| CHAP-Response                    |  405 |     5.7 | OctetString | M    | P   |          | V        | Y    |
+| CHAP-Challenge                   |   60 |     5.8 | OctetString | M    | P   |          | V        | Y    |
+| ARAP-Password                    |   70 |     5.9 | OctetString | M    | P   |          | V        | Y    |
+| ARAP-Challenge-Response          |   84 |    5.10 | OctetString | M    | P   |          | V        | Y    |
+| ARAP-Security                    |   73 |    5.11 | Unsigned32  | M    | P   |          | V        | Y    |
+| ARAP-Security-Data               |   74 |    5.12 | OctetString | M    | P   |          | V        | Y    |
+| Service-Type                     |    6 |     6.1 | Enumerated  | M    | P   |          | V        | Y    |
+| Callback-Number                  |   19 |     6.2 | UTF8String  | M    | P   |          | V        | Y    |
+| Callback-Id                      |   20 |     6.3 | UTF8String  | M    | P   |          | V        | Y    |
+| Idle-Timeout                     |   28 |     6.4 | Unsigned32  | M    | P   |          | V        | Y    |
+| Port-Limit                       |   62 |     6.5 | Unsigned32  | M    | P   |          | V        | Y    |
+| NAS-Filter-Rule                  |  400 |     6.6 | IPFltrRule  | M    | P   |          | V        | Y    |
+| Filter-Id                        |   11 |     6.7 | UTF8String  | M    | P   |          | V        | Y    |
+| Configuration-Token              |   78 |     6.8 | OctetString | M    |     |          | P,V      |      |
+| QoS-Filter-Rule                  |  407 |     6.9 | QoSFltrRule |      |     |          |          |      |
+| Framed-Protocol                  |    7 |  6.10.1 | Enumerated  | M    | P   |          | V        | Y    |
+| Framed-Routing                   |   10 |  6.10.2 | Enumerated  | M    | P   |          | V        | Y    |
+| Framed-MTU                       |   12 |  6.10.3 | Unsigned32  | M    | P   |          | V        | Y    |
+| Framed-Compression               |   13 |  6.10.4 | Enumerated  | M    | P   |          | V        | Y    |
+| Framed-IP-Address                |    8 |  6.11.1 | OctetString | M    | P   |          | V        | Y    |
+| Framed-IP-Netmask                |    9 |  6.11.2 | OctetString | M    | P   |          | V        | Y    |
+| Framed-Route                     |   22 |  6.11.3 | UTF8String  | M    | P   |          | V        | Y    |
+| Framed-Pool                      |   88 |  6.11.4 | OctetString | M    | P   |          | V        | Y    |
+| Framed-Interface-Id              |   96 |  6.11.5 | Unsigned64  | M    | P   |          | V        | Y    |
+| Framed-IPv6-Prefix               |   97 |  6.11.6 | OctetString | M    | P   |          | V        | Y    |
+| Framed-IPv6-Route                |   99 |  6.11.7 | UTF8String  | M    | P   |          | V        | Y    |
+| Framed-IPv6-Pool                 |  100 |  6.11.8 | OctetString | M    | P   |          | V        | Y    |
+| Framed-IPX-Network               |   23 |  6.12.1 | UTF8String  | M    | P   |          | V        | Y    |
+| Framed-Appletalk-Link            |   37 |  6.13.1 | Unsigned32  | M    | P   |          | V        | Y    |
+| Framed-Appletalk-Network         |   38 |  6.13.2 | Unsigned32  | M    | P   |          | V        | Y    |
+| Framed-Appletalk-Zone            |   39 |  6.13.3 | OctetString | M    | P   |          | V        | Y    |
+| ARAP-Features                    |   71 |  6.14.1 | OctetString | M    | P   |          | V        | Y    |
+| ARAP-Zone-Access                 |   72 |  6.14.2 | Enumerated  | M    | P   |          | V        | Y    |
+| Login-IP-Host                    |   14 |  6.15.1 | OctetString | M    | P   |          | V        | Y    |
+| Login-IPv6-Host                  |   98 |  6.15.2 | OctetString | M    | P   |          | V        | Y    |
+| Login-Service                    |   15 |  6.15.3 | Enumerated  | M    | P   |          | V        | Y    |
+| Login-TCP-Port                   |   16 |  6.16.1 | Unsigned32  | M    | P   |          | V        | Y    |
+| Login-LAT-Service                |   34 |  6.17.1 | OctetString | M    | P   |          | V        | Y    |
+| Login-LAT-Node                   |   35 |  6.17.2 | OctetString | M    | P   |          | V        | Y    |
+| Login-LAT-Group                  |   36 |  6.17.3 | OctetString | M    | P   |          | V        | Y    |
+| Login-LAT-Port                   |   63 |  6.17.4 | OctetString | M    | P   |          | V        | Y    |
+| Tunneling                        |  401 |     7.1 | Grouped     | M    | P   |          | V        | N    |
+| Tunnel-Type                      |   64 |     7.2 | Enumerated  | M    | P   |          | V        | Y    |
+| Tunnel-Medium-Type               |   65 |     7.3 | Enumerated  | M    | P   |          | V        | Y    |
+| Tunnel-Client-Endpoint           |   66 |     7.4 | UTF8String  | M    | P   |          | V        | Y    |
+| Tunnel-Server-Endpoint           |   67 |     7.5 | UTF8String  | M    | P   |          | V        | Y    |
+| Tunnel-Password                  |   69 |     7.6 | OctetString | M    | P   |          | V        | Y    |
+| Tunnel-Private-Group-Id          |   81 |     7.7 | OctetString | M    | P   |          | V        | Y    |
+| Tunnel-Assignment-Id             |   82 |     7.8 | OctetString | M    | P   |          | V        | Y    |
+| Tunnel-Preference                |   83 |     7.9 | Unsigned32  | M    | P   |          | V        | Y    |
+| Tunnel-Client-Auth-Id            |   90 |    7.10 | UTF8String  | M    | P   |          | V        | Y    |
+| Tunnel-Server-Auth-Id            |   91 |    7.11 | UTF8String  | M    | P   |          | V        | Y    |
+| Accounting-Input-Octets          |  363 |     8.1 | Unsigned64  | M    | P   |          | V        | Y    |
+| Accounting-Output-Octets         |  364 |     8.2 | Unsigned64  | M    | P   |          | V        | Y    |
+| Accounting-Input-Packets         |  365 |     8.3 | Unsigned64  | M    | P   |          | V        | Y    |
+| Accounting-Output-Packets        |  366 |     8.4 | Unsigned64  | M    | P   |          | V        | Y    |
+| Acct-Session-Time                |   46 |     8.5 | Unsigned32  | M    | P   |          | V        | Y    |
+| Acct-Authentic                   |   45 |     8.6 | Enumerated  | M    | P   |          | V        | Y    |
+| Acounting-Auth-Method            |  406 |     8.7 | Enumerated  | M    | P   |          | V        | Y    |
+| Acct-Delay-Time                  |   41 |     8.8 | Unsigned32  | M    | P   |          | V        | Y    |
+| Acct-Link-Count                  |   51 |     8.9 | Unsigned32  | M    | P   |          | V        | Y    |
+| Acct-Tunnel-Connection           |   68 |    8.10 | OctetString | M    | P   |          | V        | Y    |
+| Acct-Tunnel-Packets-Lost         |   86 |    8.11 | Unsigned32  | M    | P   |          | V        | Y    |
+| NAS-Identifier                   |   32 |   9.3.1 | UTF8String  | M    | P   |          | V        | Y    |
+| NAS-IP-Address                   |    4 |   9.3.2 | OctetString | M    | P   |          | V        | Y    |
+| NAS-IPv6-Address                 |   95 |   9.3.3 | OctetString | M    | P   |          | V        | Y    |
+| State                            |   24 |   9.3.4 | OctetString | M    | P   |          | V        | Y    |
+| Termination-Cause                |  295 |   9.3.5 | Enumerated  | M    | P   |          | V        | Y    |
+| Origin-AAA-Protocol              |  408 |   9.3.6 | Enumerated  | M    | P   |          | V        | Y    |
+| # RFC 4006 - DCCA #              |      |         |             |      |     |          |          |      |
+| CC-Correlation-Id                |  411 |     8.1 | OctetString |      | P,M |          | V        | Y    |
+| CC-Input-Octets                  |  412 |    8.24 | Unsigned64  | M    | P   |          | V        | Y    |
+| CC-Money                         |  413 |    8.22 | Grouped     | M    | P   |          | V        | Y    |
+| CC-Output-Octets                 |  414 |    8.25 | Unsigned64  | M    | P   |          | V        | Y    |
+| CC-Request-Number                |  415 |     8.2 | Unsigned32  | M    | P   |          | V        | Y    |
+| CC-Request-Type                  |  416 |     8.3 | Enumerated  | M    | P   |          | V        | Y    |
+| CC-Service-Specific-Units        |  417 |    8.26 | Unsigned64  | M    | P   |          | V        | Y    |
+| CC-Session-Failover              |  418 |     8.4 | Enumerated  | M    | P   |          | V        | Y    |
+| CC-Sub-Session-Id                |  419 |     8.5 | Unsigned64  | M    | P   |          | V        | Y    |
+| CC-Time                          |  420 |    8.21 | Unsigned32  | M    | P   |          | V        | Y    |
+| CC-Total-Octets                  |  421 |    8.23 | Unsigned64  | M    | P   |          | V        | Y    |
+| CC-Unit-Type                     |  454 |    8.32 | Enumerated  | M    | P   |          | V        | Y    |
+| Check-Balance-Result             |  422 |     8.6 | Enumerated  | M    | P   |          | V        | Y    |
+| Cost-Information                 |  423 |     8.7 | Grouped     | M    | P   |          | V        | Y    |
+| Cost-Unit                        |  424 |    8.12 | UTF8String  | M    | P   |          | V        | Y    |
+| Credit-Control                   |  426 |    8.13 | Enumerated  | M    | P   |          | V        | Y    |
+| Credit-Control-Failure-Handling  |  427 |    8.14 | Enumerated  | M    | P   |          | V        | Y    |
+| Currency-Code                    |  425 |    8.11 | Unsigned32  | M    | P   |          | V        | Y    |
+| Direct-Debiting-Failure-Handling |  428 |    8.15 | Enumerated  | M    | P   |          | V        | Y    |
+| Exponent                         |  429 |     8.9 | Integer32   | M    | P   |          | V        | Y    |
+| Final-Unit-Action                |  449 |    8.35 | Enumerated  | M    | P   |          | V        | Y    |
+| Final-Unit-Indication            |  430 |    8.34 | Grouped     | M    | P   |          | V        | Y    |
+| Granted-Service-Unit             |  431 |    8.17 | Grouped     | M    | P   |          | V        | Y    |
+| G-S-U-Pool-Identifier            |  453 |    8.31 | Unsigned32  | M    | P   |          | V        | Y    |
+| G-S-U-Pool-Reference             |  457 |    8.30 | Grouped     | M    | P   |          | V        | Y    |
+| Multiple-Services-Credit-Control |  456 |    8.16 | Grouped     | M    | P   |          | V        | Y    |
+| Multiple-Services-Indicator      |  455 |    8.40 | Enumerated  | M    | P   |          | V        | Y    |
+| Rating-Group                     |  432 |    8.29 | Unsigned32  | M    | P   |          | V        | Y    |
+| Redirect-Address-Type            |  433 |    8.38 | Enumerated  | M    | P   |          | V        | Y    |
+| Redirect-Server                  |  434 |    8.37 | Grouped     | M    | P   |          | V        | Y    |
+| Redirect-Server-Address          |  435 |    8.39 | UTF8String  | M    | P   |          | V        | Y    |
+| Requested-Action                 |  436 |    8.41 | Enumerated  | M    | P   |          | V        | Y    |
+| Requested-Service-Unit           |  437 |    8.18 | Grouped     | M    | P   |          | V        | Y    |
+| Restriction-Filter-Rule          |  438 |    8.36 | IPFiltrRule | M    | P   |          | V        | Y    |
+| Service-Context-Id               |  461 |    8.42 | UTF8String  | M    | P   |          | V        | Y    |
+| Service-Identifier               |  439 |    8.28 | Unsigned32  | M    | P   |          | V        | Y    |
+| Service-Parameter-Info           |  440 |    8.43 | Grouped     |      | P,M |          | V        | Y    |
+| Service-Parameter-Type           |  441 |    8.44 | Unsigned32  |      | P,M |          | V        | Y    |
+| Service-Parameter-Value          |  442 |    8.45 | OctetString |      | P,M |          | V        | Y    |
+| Subscription-Id                  |  443 |    8.46 | Grouped     | M    | P   |          | V        | Y    |
+| Subscription-Id-Data             |  444 |    8.48 | UTF8String  | M    | P   |          | V        | Y    |
+| Subscription-Id-Type             |  450 |    8.47 | Enumerated  | M    | P   |          | V        | Y    |
+| Tariff-Change-Usage              |  452 |    8.27 | Enumerated  | M    | P   |          | V        | Y    |
+| Tariff-Time-Change               |  451 |    8.20 | Time        | M    | P   |          | V        | Y    |
+| Unit-Value                       |  445 |     8.8 | Grouped     | M    | P   |          | V        | Y    |
+| Used-Service-Unit                |  446 |    8.19 | Grouped     | M    | P   |          | V        | Y    |
+| User-Equipment-Info              |  458 |    8.49 | Grouped     |      | P,M |          | V        | Y    |
+| User-Equipment-Info-Type         |  459 |    8.50 | Enumerated  |      | P,M |          | V        | Y    |
+| User-Equipment-Info-Value        |  460 |    8.51 | OctetString |      | P,M |          | V        | Y    |
+| Value-Digits                     |  447 |    8.10 | Integer64   | M    | P   |          | V        | Y    |
+| Validity-Time                    |  448 |    8.33 | Unsigned32  | M    | P   |          | V        | Y    |
Index: contrib/tools/org_to_fd.pl
===================================================================
--- contrib/tools/org_to_fd.pl	(revision 953)
+++ contrib/tools/org_to_fd.pl	(revision 953)
@@ -0,0 +1,85 @@
+#!/usr/bin/env perl
+use strict;
+use Getopt::Std;
+
+our ($opt_v);
+
+sub convert_must_to_flags($) {
+    my ($allmust) = @_;
+    my ($mustfields) = "";
+    $mustfields .= "AVP_FLAG_VENDOR |" if ($allmust =~ m/V/);
+    $mustfields .= "AVP_FLAG_MANDATORY |" if ($allmust =~ m/M/);
+    $mustfields =~ s/ \|$//;
+    return $mustfields;
+}
+
+sub base_type($) {
+    my ($type) = @_;
+
+    return "AVP_TYPE_GROUPED" if ($type =~ m/Grouped/);
+    return "AVP_TYPE_OCTETSTRING" if ($type =~ m/(Address|DiameterIdentity|DiameterURI|OctetString|IPFilterRule|Time|UTF8String)/);
+    return "AVP_TYPE_INTEGER32" if ($type =~ m/Enumerated|Integer32/);
+    return "AVP_TYPE_INTEGER64" if ($type =~ m/Integer64/);
+    return "AVP_TYPE_UNSIGNED32" if ($type =~ m/Unsigned32/);
+    return "AVP_TYPE_UNSIGNED64" if ($type =~ m/Unsigned64/);
+    return "AVP_TYPE_FLOAT32" if ($type =~ m/Float32/);
+    return "AVP_TYPE_FLOAT64" if ($type =~ m/Float64/);
+
+    return "UNKNOWN TYPE: $type";
+}
+
+sub print_insert($$) {
+    my ($type, $name) = @_;
+    my $avp_type;
+
+    if ($type =~ m/(Grouped|OctetString|Integer32|Integer64|Unsigned32|Unsigned64|Float32|Float64)/) {
+        $avp_type = "NULL";
+    } elsif ($type =~ m/Enumerated/) {
+        print "\t\tstruct dict_object		*type;\n";
+        print "\t\tstruct dict_type_data	 tdata = { AVP_TYPE_INTEGER32, \"Enumerated($name)\", NULL, NULL, NULL };\n";
+        # XXX: add enumerated values
+        print "\t\tCHECK_dict_new(DICT_TYPE, &tdata, NULL, &type);\n";
+        $avp_type = "type";
+    } else {
+        $avp_type = "${type}_type";
+    }
+
+    print "\t\tCHECK_dict_new(DICT_AVP, &data, $avp_type, NULL);\n";
+}
+
+getopts("v:") || die("usage: org_to_fd.pl [-v vendor] [file ...]\n");
+
+# default to 3GPP
+my ($vendor) = 10415;
+if (defined($opt_v)) {
+    $vendor = $opt_v;
+}
+
+print "\t/* The following is created automatically. Do not modify. */\n";
+print "\t/* Changes will be lost during the next update. Modify the source org file instead. */\n\n";
+
+while (<>) {
+    my ($dummy, $name, $code, $section, $type, $must, $may, $shouldnot, $mustnot, $encr) = split /\|/;
+
+    next if ($name =~ m/Attribute Name/);
+    if ($name =~ m/ # (.*)/) {
+        print "\t/* $1 */\n";
+        next;
+    }
+        
+
+    $name =~ s/ *//g;
+    $code =~ s/ *//g;
+    $type =~ s/ *//g;
+
+    print "\t/* $name */\n\t{\n\t\tstruct dict_avp_data data = {\n";
+    print "\t\t\t$code,\t/* Code */\n";
+    print "\t\t\t$vendor,\t/* Vendor */\n";
+    print "\t\t\t\"$name\",\t/* Name */\n";
+    print "\t\t\t" . convert_must_to_flags("$must, $mustnot") . ",\t/* Fixed flags */\n";
+    print "\t\t\t" . convert_must_to_flags("$must") . ",\t/* Fixed flag values */\n";
+    print "\t\t\t" . base_type($type) . "\t/* base type of data */\n";
+    print "\t\t};\n";
+    print_insert($type, $name);
+    print "\t};\n\n";
+}
