├── .gitignore ├── README.md ├── config.js.example ├── css ├── bootstrap-theme.css ├── bootstrap-theme.css.map ├── bootstrap.css ├── bootstrap.css.map └── main.css ├── db └── .gitignore ├── ietf-yangs ├── iana-crypt-hash.yang ├── iana-if-type.yang ├── iana-if-type@2014-05-08.yang ├── ietf-inet-types.yang ├── ietf-inet-types@2010-09-24.yang ├── ietf-inet-types@2013-07-15.yang ├── ietf-interfaces.yang ├── ietf-interfaces@2014-05-08.yang ├── ietf-ip.yang ├── ietf-ip@2014-06-16.yang ├── ietf-ipfix-psamp.yang ├── ietf-ipfix-psamp@2012-09-05.yang ├── ietf-netconf-acm.yang ├── ietf-netconf-acm@2012-02-22.yang ├── ietf-netconf-monitoring.yang ├── ietf-netconf-monitoring@2010-10-04.yang ├── ietf-netconf-notifications.yang ├── ietf-netconf-notifications@2012-02-06.yang ├── ietf-netconf-partial-lock.yang ├── ietf-netconf-partial-lock@2009-10-19.yang ├── ietf-netconf-with-defaults.yang ├── ietf-netconf-with-defaults@2011-06-01.yang ├── ietf-netconf.yang ├── ietf-netconf@2011-06-01.yang ├── ietf-snmp-common.yang ├── ietf-snmp-community.yang ├── ietf-snmp-engine.yang ├── ietf-snmp-notification.yang ├── ietf-snmp-proxy.yang ├── ietf-snmp-ssh.yang ├── ietf-snmp-target.yang ├── ietf-snmp-tls.yang ├── ietf-snmp-tsm.yang ├── ietf-snmp-usm.yang ├── ietf-snmp-vacm.yang ├── ietf-snmp.yang ├── ietf-system.yang ├── ietf-system@2014-08-06.yang ├── ietf-x509-cert-to-name.yang ├── ietf-yang-smiv2.yang ├── ietf-yang-types.yang ├── ietf-yang-types@2010-09-24.yang ├── ietf-yang-types@2013-07-15.yang ├── nc-notifications@2008-07-14.yang └── notifications@2008-07-14.yang ├── js ├── ZeroClipboard.min.js ├── bootstrap.js ├── editor.js ├── jquery.form.min.js ├── jquery.js ├── json2.js ├── jstorage.js ├── main.js ├── promise.js ├── sha256.js └── yang.js ├── package.json ├── public ├── .gitignore ├── ZeroClipboard.swf ├── favicon.ico ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.svg │ ├── glyphicons-halflings-regular.ttf │ └── glyphicons-halflings-regular.woff ├── img │ ├── bt_close.png │ ├── bt_open.png │ ├── chosen-sprite.png │ ├── chosen-sprite@2x.png │ ├── favicon.png │ ├── github-logo.png │ ├── html5.png │ ├── logo.png │ └── spinner.gif ├── index.html └── yangs │ └── .gitignore ├── server.js ├── yang.js └── yang2src ├── code_gen.js └── template └── C ├── application ├── CMakeLists.txt ├── FindSYSREPO.cmake ├── README.asciidoc ├── entrypoint.sh ├── main.c └── run.sh └── plugin ├── CMakeLists.txt ├── FindSYSREPO.cmake ├── README.asciidoc ├── entrypoint.sh ├── main.c └── run.sh /.gitignore: -------------------------------------------------------------------------------- 1 | *.rej 2 | *.orig 3 | *~ 4 | *.swp 5 | *.patch 6 | 7 | node_modules 8 | 9 | *.tmp 10 | 11 | uploads/ 12 | config.js 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | YANG Creator 2 | ============ 3 | 4 | The online YANG creator, editor, and exporter. 5 | 6 | #### Installation 7 | git clone https://github.com/freenetconf/yang-creator.git 8 | cd yang-creator 9 | export PYTHON=python2 # in case you python is in fact python3 10 | npm install 11 | 12 | Copy `config.js.example` to `config.js` and edit as needed if you want to send 13 | YANG models via email as well. 14 | 15 | Run 16 | 17 | ./server.js 18 | 19 | You also need to have `pyang` installed for export to work. E.g.: 20 | 21 | pip2 install pyang 22 | 23 | #### Usage 24 | Open browser url 'http://127.0.0.1:8888' 25 | 26 | To register/login enter wanted 'username' and 'password'. 27 | This gives you ability to manage your YANG files. 28 | 29 | If you have module that imports another module, you need to create/import all 30 | depended module and save them. After that you can use your module. 31 | 32 | ##### Files 33 | Manage existing files which are saved to your account. 34 | 35 | ##### New 36 | Create new example module/submodule. 37 | 38 | ##### Validate 39 | Validate your YANG module using pyang. 40 | 41 | ##### Export 42 | See your finalized YANG module which you can download, copy (copy requieres flash) or send to email. 43 | 44 | ##### Save 45 | Save your YANG files online for later usage. 46 | 47 | #### TODO 48 | * statements: 49 | * check missing or incorrect statements 50 | * uniq values should be set for all statements that can hold only one specific statement inside 51 | * default values and possible values - some statements can only have specific values 52 | * extension statements - dynamically created statements are not supported 53 | * help: create help window for users where they can see how to use YANG Creator 54 | * import/include: YANG extension statements defined in other modules are not seen 55 | * import: depends on YANG parser work 56 | * security, code cleanup and consolidation 57 | -------------------------------------------------------------------------------- /config.js.example: -------------------------------------------------------------------------------- 1 | var config = {} 2 | 3 | module.exports = config 4 | 5 | config.export_to_email = false 6 | 7 | config.mail_options = { 8 | //"from": '"YANG" ', // not working with gmail 9 | 10 | // For more options see https://github.com/nodemailer/nodemailer#set-up-smtp 11 | "service": "gmail", 12 | "auth": { 13 | "user": "user@gmail.com", 14 | "pass": "secret" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /css/main.css: -------------------------------------------------------------------------------- 1 | /* Eric Meyer's Reset CSS v2.0 - http://cssreset.com */ 2 | html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{border:0;font-size:100%;vertical-align:baseline;margin:0;padding:0}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:none}table{border-collapse:collapse;border-spacing:0} 3 | 4 | body, html { 5 | font-family:arial; 6 | } 7 | 8 | #d_welcome, #f_login { 9 | display:none 10 | } 11 | 12 | #a_logout { 13 | margin-left: 18px; 14 | } 15 | 16 | #d_content { 17 | padding : 0% 2%; 18 | font-size: 0.9em 19 | } 20 | 21 | .modal-content{ 22 | padding: 5% 10% 23 | } 24 | 25 | .modal-footer { 26 | display: inline-flex; 27 | } 28 | 29 | table.files { 30 | width:100% 31 | } 32 | 33 | table.files th, td { 34 | padding: 1% 2%; 35 | } 36 | 37 | p { 38 | padding:0; 39 | margin:0 40 | } 41 | ul { 42 | list-style-type:none; 43 | margin-bottom: 1em; 44 | margin-left:1em 45 | } 46 | 47 | .completion input[type=text] { 48 | margin-left:1em; 49 | font-size:1em; 50 | font-weight:normal; 51 | margin-bottom:1em; 52 | } 53 | 54 | .completion a.close { 55 | margin-left:1em; 56 | margin-bottom:1em; 57 | } 58 | 59 | h4 { 60 | font-weight:bold; 61 | } 62 | 63 | li { 64 | margin:0px; 65 | padding:0px 66 | } 67 | 68 | span.identifier { 69 | font-weight:bold 70 | } 71 | 72 | span.name { 73 | color:black 74 | } 75 | 76 | span.property { 77 | color:grey 78 | } 79 | 80 | .small { 81 | font-size: 0.8em 82 | } 83 | 84 | .editable { 85 | padding : 0.05em 0.3em; 86 | border: 1px solid #EEEEEE; 87 | display:inline-block; 88 | } 89 | 90 | a.add, a.delete{ 91 | font-weight:bold; 92 | font-size:2.0em; 93 | vertical-align: -10%; 94 | text-decoration: none; 95 | } 96 | 97 | a.add { 98 | font-size: 1.0em 99 | 100 | } 101 | 102 | .completion { 103 | background-color : #EFEFEF 104 | } 105 | 106 | #d_editor { 107 | width: 50%; 108 | float:left 109 | } 110 | #d_output { 111 | border: 1px solid #EFEFEF; 112 | float:left; 113 | width:48%; 114 | margin: 0% 1%; 115 | padding: 1%; 116 | } 117 | 118 | #i_spinner { 119 | visibility:hidden 120 | } 121 | 122 | .modal .modal-body { 123 | max-height: 430px; 124 | overflow-y: scroll; 125 | } 126 | 127 | .modal-header { 128 | border-bottom: none; 129 | } 130 | 131 | .modal-footer { 132 | border-top: none; 133 | } 134 | 135 | button.btn.btn-info.btn-xs { 136 | margin-right: 0%; 137 | } 138 | 139 | 140 | .btn-file { 141 | position: relative; 142 | overflow: hidden; 143 | } 144 | 145 | .btn-file input[type=file] { 146 | position: absolute; 147 | top: 0; 148 | right: 0; 149 | min-width: 100%; 150 | min-height: 100%; 151 | font-size: 100px; 152 | text-align: right; 153 | filter: alpha(opacity=0); 154 | opacity: 0; 155 | background: red; 156 | cursor: inherit; 157 | display: block; 158 | } 159 | 160 | input[readonly] { 161 | cursor: text !important; 162 | } 163 | 164 | .input-xs { 165 | height: 22px; 166 | padding: 5px 5px; 167 | font-size: 12px; 168 | line-height: 1.5; 169 | border-radius: 3px; 170 | } 171 | 172 | pre{ 173 | font-family: "Courier New", Courier, monospace, sans-serif; 174 | background:#EFEFEF; 175 | padding:15px 176 | } 177 | 178 | /* csDefault */ 179 | /* Notification holder */ 180 | .csInfoDiv {display:none;z-index:10000; position:fixed; top:0; width:100%; left:0; text-align:center;padding:0; margin:0} 181 | 182 | /* Notification inner holder - holds generated text/html */ 183 | #csInfoInner {margin:0;display:inline-block;font-weight:bold; border-radius:0 0 3px 3px;padding:5px 15px;} 184 | 185 | footer { 186 | position:fixed; 187 | bottom:0; 188 | right:0; 189 | } 190 | 191 | .logo { 192 | padding:10px; 193 | } 194 | 195 | .navbar-form { 196 | width: auto; 197 | padding-top: 11px; 198 | padding-bottom: 0; 199 | margin-right: 0; 200 | margin-left: 0; 201 | border: 0; 202 | -webkit-box-shadow: none; 203 | box-shadow: none; 204 | } 205 | 206 | #form_download{ 207 | display: inline; 208 | } 209 | 210 | .glyphicon-trash { 211 | margin-right: 4px; 212 | } 213 | 214 | .glyphicon-download { 215 | margin-right: 4px; 216 | } 217 | 218 | #download { 219 | margin-right: 0px; 220 | } 221 | 222 | #i_confirm_reset { 223 | margin-left: 5px; 224 | } 225 | 226 | #i_reset_button { 227 | margin-left: 5px; 228 | } 229 | -------------------------------------------------------------------------------- /db/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | -------------------------------------------------------------------------------- /ietf-yangs/iana-crypt-hash.yang: -------------------------------------------------------------------------------- 1 | module iana-crypt-hash { 2 | namespace "urn:ietf:params:xml:ns:yang:iana-crypt-hash"; 3 | prefix ianach; 4 | 5 | organization "IANA"; 6 | contact 7 | " Internet Assigned Numbers Authority 8 | 9 | Postal: ICANN 10 | 12025 Waterfront Drive, Suite 300 11 | Los Angeles, CA 90094-2536 12 | United States 13 | 14 | Tel: +1 310 301 5800 15 | E-Mail: iana@iana.org>"; 16 | description 17 | "This YANG module defines a type for storing passwords 18 | using a hash function and features to indicate which hash 19 | functions are supported by an implementation. 20 | 21 | The latest revision of this YANG module can be obtained from 22 | the IANA web site. 23 | 24 | Requests for new values should be made to IANA via 25 | email (iana@iana.org). 26 | 27 | Copyright (c) 2014 IETF Trust and the persons identified as 28 | authors of the code. All rights reserved. 29 | 30 | Redistribution and use in source and binary forms, with or 31 | without modification, is permitted pursuant to, and subject 32 | to the license terms contained in, the Simplified BSD License 33 | set forth in Section 4.c of the IETF Trust's Legal Provisions 34 | Relating to IETF Documents 35 | (http://trustee.ietf.org/license-info). 36 | 37 | The initial version of this YANG module is part of RFC 7317; 38 | see the RFC itself for full legal notices."; 39 | 40 | revision 2014-08-06 { 41 | description 42 | "Initial revision."; 43 | reference 44 | "RFC 7317: A YANG Data Model for System Management"; 45 | } 46 | 47 | typedef crypt-hash { 48 | type string { 49 | pattern 50 | '$0$.*' 51 | + '|$1$[a-zA-Z0-9./]{1,8}$[a-zA-Z0-9./]{22}' 52 | + '|$5$(rounds=\d+$)?[a-zA-Z0-9./]{1,16}$[a-zA-Z0-9./]{43}' 53 | + '|$6$(rounds=\d+$)?[a-zA-Z0-9./]{1,16}$[a-zA-Z0-9./]{86}'; 54 | } 55 | description 56 | "The crypt-hash type is used to store passwords using 57 | a hash function. The algorithms for applying the hash 58 | function and encoding the result are implemented in 59 | various UNIX systems as the function crypt(3). 60 | 61 | A value of this type matches one of the forms: 62 | 63 | $0$ 64 | $$$ 65 | $$$$ 66 | 67 | The '$0$' prefix signals that the value is clear text. When 68 | such a value is received by the server, a hash value is 69 | calculated, and the string '$$$' or 70 | $$$$ is prepended to the result. This 71 | value is stored in the configuration data store. 72 | If a value starting with '$$', where is not '0', is 73 | received, the server knows that the value already represents a 74 | hashed value and stores it 'as is' in the data store. 75 | 76 | When a server needs to verify a password given by a user, it 77 | finds the stored password hash string for that user, extracts 78 | the salt, and calculates the hash with the salt and given 79 | password as input. If the calculated hash value is the same 80 | as the stored value, the password given by the client is 81 | accepted. 82 | 83 | This type defines the following hash functions: 84 | 85 | id | hash function | feature 86 | ---+---------------+------------------- 87 | 1 | MD5 | crypt-hash-md5 88 | 5 | SHA-256 | crypt-hash-sha-256 89 | 6 | SHA-512 | crypt-hash-sha-512 90 | 91 | The server indicates support for the different hash functions 92 | by advertising the corresponding feature."; 93 | reference 94 | "IEEE Std 1003.1-2008 - crypt() function 95 | RFC 1321: The MD5 Message-Digest Algorithm 96 | FIPS.180-4.2012: Secure Hash Standard (SHS)"; 97 | } 98 | 99 | feature crypt-hash-md5 { 100 | description 101 | "Indicates that the device supports the MD5 102 | hash function in 'crypt-hash' values."; 103 | reference "RFC 1321: The MD5 Message-Digest Algorithm"; 104 | } 105 | 106 | feature crypt-hash-sha-256 { 107 | description 108 | "Indicates that the device supports the SHA-256 109 | hash function in 'crypt-hash' values."; 110 | reference "FIPS.180-4.2012: Secure Hash Standard (SHS)"; 111 | } 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | feature crypt-hash-sha-512 { 121 | description 122 | "Indicates that the device supports the SHA-512 123 | hash function in 'crypt-hash' values."; 124 | reference "FIPS.180-4.2012: Secure Hash Standard (SHS)"; 125 | } 126 | 127 | } 128 | -------------------------------------------------------------------------------- /ietf-yangs/ietf-netconf-notifications.yang: -------------------------------------------------------------------------------- 1 | module ietf-netconf-notifications { 2 | 3 | namespace 4 | "urn:ietf:params:xml:ns:yang:ietf-netconf-notifications"; 5 | 6 | prefix ncn; 7 | 8 | import ietf-inet-types { prefix inet; } 9 | import ietf-netconf { prefix nc; } 10 | 11 | organization 12 | "IETF NETCONF (Network Configuration Protocol) Working Group"; 13 | 14 | contact 15 | "WG Web: 16 | WG List: 17 | 18 | WG Chair: Bert Wijnen 19 | 20 | 21 | WG Chair: Mehmet Ersue 22 | 23 | 24 | Editor: Andy Bierman 25 | "; 26 | 27 | description 28 | "This module defines a YANG data model for use with the 29 | NETCONF protocol that allows the NETCONF client to 30 | receive common NETCONF base event notifications. 31 | 32 | Copyright (c) 2012 IETF Trust and the persons identified as 33 | the document authors. All rights reserved. 34 | 35 | Redistribution and use in source and binary forms, with or 36 | without modification, is permitted pursuant to, and subject 37 | to the license terms contained in, the Simplified BSD License 38 | 39 | 40 | 41 | set forth in Section 4.c of the IETF Trust's Legal Provisions 42 | Relating to IETF Documents 43 | (http://trustee.ietf.org/license-info). 44 | 45 | This version of this YANG module is part of RFC 6470; see 46 | the RFC itself for full legal notices."; 47 | 48 | revision "2012-02-06" { 49 | description 50 | "Initial version. Errata 3957 added."; 51 | reference 52 | "RFC 6470: NETCONF Base Notifications"; 53 | } 54 | 55 | grouping common-session-parms { 56 | description 57 | "Common session parameters to identify a 58 | management session."; 59 | 60 | leaf username { 61 | type string; 62 | mandatory true; 63 | description 64 | "Name of the user for the session."; 65 | } 66 | 67 | leaf session-id { 68 | type nc:session-id-or-zero-type; 69 | mandatory true; 70 | description 71 | "Identifier of the session. 72 | A NETCONF session MUST be identified by a non-zero value. 73 | A non-NETCONF session MAY be identified by the value zero."; 74 | } 75 | 76 | leaf source-host { 77 | type inet:ip-address; 78 | description 79 | "Address of the remote host for the session."; 80 | } 81 | } 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | grouping changed-by-parms { 91 | description 92 | "Common parameters to identify the source 93 | of a change event, such as a configuration 94 | or capability change."; 95 | 96 | container changed-by { 97 | description 98 | "Indicates the source of the change. 99 | If caused by internal action, then the 100 | empty leaf 'server' will be present. 101 | If caused by a management session, then 102 | the name, remote host address, and session ID 103 | of the session that made the change will be reported."; 104 | choice server-or-user { 105 | mandatory true; 106 | leaf server { 107 | type empty; 108 | description 109 | "If present, the change was caused 110 | by the server."; 111 | } 112 | 113 | case by-user { 114 | uses common-session-parms; 115 | } 116 | } // choice server-or-user 117 | } // container changed-by-parms 118 | } 119 | 120 | 121 | notification netconf-config-change { 122 | description 123 | "Generated when the NETCONF server detects that the 124 | or configuration datastore 125 | has been changed by a management session. 126 | The notification summarizes the edits that 127 | have been detected. 128 | 129 | The server MAY choose to also generate this 130 | notification while loading a datastore during the 131 | boot process for the device."; 132 | 133 | uses changed-by-parms; 134 | 135 | 136 | 137 | 138 | 139 | leaf datastore { 140 | type enumeration { 141 | enum running { 142 | description "The datastore has changed."; 143 | } 144 | enum startup { 145 | description "The datastore has changed"; 146 | } 147 | } 148 | default "running"; 149 | description 150 | "Indicates which configuration datastore has changed."; 151 | } 152 | 153 | list edit { 154 | description 155 | "An edit record SHOULD be present for each distinct 156 | edit operation that the server has detected on 157 | the target datastore. This list MAY be omitted 158 | if the detailed edit operations are not known. 159 | The server MAY report entries in this list for 160 | changes not made by a NETCONF session (e.g., CLI)."; 161 | 162 | leaf target { 163 | type instance-identifier; 164 | description 165 | "Topmost node associated with the configuration change. 166 | A server SHOULD set this object to the node within 167 | the datastore that is being altered. A server MAY 168 | set this object to one of the ancestors of the actual 169 | node that was changed, or omit this object, if the 170 | exact node is not known."; 171 | } 172 | 173 | leaf operation { 174 | type nc:edit-operation-type; 175 | description 176 | "Type of edit operation performed. 177 | A server MUST set this object to the NETCONF edit 178 | operation performed on the target datastore."; 179 | } 180 | } // list edit 181 | } // notification netconf-config-change 182 | 183 | 184 | 185 | 186 | 187 | 188 | notification netconf-capability-change { 189 | description 190 | "Generated when the NETCONF server detects that 191 | the server capabilities have changed. 192 | Indicates which capabilities have been added, deleted, 193 | and/or modified. The manner in which a server 194 | capability is changed is outside the scope of this 195 | document."; 196 | 197 | uses changed-by-parms; 198 | 199 | leaf-list added-capability { 200 | type inet:uri; 201 | description 202 | "List of capabilities that have just been added."; 203 | } 204 | 205 | leaf-list deleted-capability { 206 | type inet:uri; 207 | description 208 | "List of capabilities that have just been deleted."; 209 | } 210 | 211 | leaf-list modified-capability { 212 | type inet:uri; 213 | description 214 | "List of capabilities that have just been modified. 215 | A capability is considered to be modified if the 216 | base URI for the capability has not changed, but 217 | one or more of the parameters encoded at the end of 218 | the capability URI have changed. 219 | The new modified value of the complete URI is returned."; 220 | } 221 | } // notification netconf-capability-change 222 | 223 | 224 | notification netconf-session-start { 225 | description 226 | "Generated when a NETCONF server detects that a 227 | NETCONF session has started. A server MAY generate 228 | this event for non-NETCONF management sessions. 229 | Indicates the identity of the user that started 230 | the session."; 231 | uses common-session-parms; 232 | } // notification netconf-session-start 233 | 234 | 235 | 236 | 237 | notification netconf-session-end { 238 | description 239 | "Generated when a NETCONF server detects that a 240 | NETCONF session has terminated. 241 | A server MAY optionally generate this event for 242 | non-NETCONF management sessions. Indicates the 243 | identity of the user that owned the session, 244 | and why the session was terminated."; 245 | 246 | uses common-session-parms; 247 | 248 | leaf killed-by { 249 | when "../termination-reason = 'killed'"; 250 | type nc:session-id-type; 251 | description 252 | "The ID of the session that directly caused this session 253 | to be abnormally terminated. If this session was abnormally 254 | terminated by a non-NETCONF session unknown to the server, 255 | then this leaf will not be present."; 256 | } 257 | 258 | leaf termination-reason { 259 | type enumeration { 260 | enum "closed" { 261 | description 262 | "The session was terminated by the client in normal 263 | fashion, e.g., by the NETCONF 264 | protocol operation."; 265 | } 266 | enum "killed" { 267 | description 268 | "The session was terminated in abnormal 269 | fashion, e.g., by the NETCONF 270 | protocol operation."; 271 | } 272 | enum "dropped" { 273 | description 274 | "The session was terminated because the transport layer 275 | connection was unexpectedly closed."; 276 | } 277 | enum "timeout" { 278 | description 279 | "The session was terminated because of inactivity, 280 | e.g., waiting for the message or 281 | messages."; 282 | } 283 | 284 | 285 | 286 | enum "bad-hello" { 287 | description 288 | "The client's message was invalid."; 289 | } 290 | enum "other" { 291 | description 292 | "The session was terminated for some other reason."; 293 | } 294 | } 295 | mandatory true; 296 | description 297 | "Reason the session was terminated."; 298 | } 299 | } // notification netconf-session-end 300 | 301 | 302 | notification netconf-confirmed-commit { 303 | description 304 | "Generated when a NETCONF server detects that a 305 | confirmed-commit event has occurred. Indicates the event 306 | and the current state of the confirmed-commit procedure 307 | in progress."; 308 | reference 309 | "RFC 6241, Section 8.4"; 310 | 311 | uses common-session-parms { 312 | when "confirm-event != 'timeout'"; 313 | } 314 | 315 | leaf confirm-event { 316 | type enumeration { 317 | enum "start" { 318 | description 319 | "The confirmed-commit procedure has started."; 320 | } 321 | enum "cancel" { 322 | description 323 | "The confirmed-commit procedure has been canceled, 324 | e.g., due to the session being terminated, or an 325 | explicit operation."; 326 | } 327 | enum "timeout" { 328 | description 329 | "The confirmed-commit procedure has been canceled 330 | due to the confirm-timeout interval expiring. 331 | The common session parameters will not be present 332 | in this sub-mode."; 333 | } 334 | 335 | enum "extend" { 336 | description 337 | "The confirmed-commit timeout has been extended, 338 | e.g., by a new operation."; 339 | } 340 | enum "complete" { 341 | description 342 | "The confirmed-commit procedure has been completed."; 343 | } 344 | } 345 | mandatory true; 346 | description 347 | "Indicates the event that caused the notification."; 348 | } 349 | 350 | leaf timeout { 351 | when 352 | "../confirm-event = 'start' or ../confirm-event = 'extend'"; 353 | type uint32; 354 | units "seconds"; 355 | description 356 | "The configured timeout value if the event type 357 | is 'start' or 'extend'. This value represents 358 | the approximate number of seconds from the event 359 | time when the 'timeout' event might occur."; 360 | } 361 | } // notification netconf-confirmed-commit 362 | 363 | } 364 | -------------------------------------------------------------------------------- /ietf-yangs/ietf-netconf-notifications@2012-02-06.yang: -------------------------------------------------------------------------------- 1 | module ietf-netconf-notifications { 2 | 3 | namespace 4 | "urn:ietf:params:xml:ns:yang:ietf-netconf-notifications"; 5 | 6 | prefix ncn; 7 | 8 | import ietf-inet-types { prefix inet; } 9 | import ietf-netconf { prefix nc; } 10 | 11 | organization 12 | "IETF NETCONF (Network Configuration Protocol) Working Group"; 13 | 14 | contact 15 | "WG Web: 16 | WG List: 17 | 18 | WG Chair: Bert Wijnen 19 | 20 | 21 | WG Chair: Mehmet Ersue 22 | 23 | 24 | Editor: Andy Bierman 25 | "; 26 | 27 | description 28 | "This module defines a YANG data model for use with the 29 | NETCONF protocol that allows the NETCONF client to 30 | receive common NETCONF base event notifications. 31 | 32 | Copyright (c) 2012 IETF Trust and the persons identified as 33 | the document authors. All rights reserved. 34 | 35 | Redistribution and use in source and binary forms, with or 36 | without modification, is permitted pursuant to, and subject 37 | to the license terms contained in, the Simplified BSD License 38 | 39 | 40 | 41 | set forth in Section 4.c of the IETF Trust's Legal Provisions 42 | Relating to IETF Documents 43 | (http://trustee.ietf.org/license-info). 44 | 45 | This version of this YANG module is part of RFC 6470; see 46 | the RFC itself for full legal notices."; 47 | 48 | revision "2012-02-06" { 49 | description 50 | "Initial version. Errata 3957 added."; 51 | reference 52 | "RFC 6470: NETCONF Base Notifications"; 53 | } 54 | 55 | grouping common-session-parms { 56 | description 57 | "Common session parameters to identify a 58 | management session."; 59 | 60 | leaf username { 61 | type string; 62 | mandatory true; 63 | description 64 | "Name of the user for the session."; 65 | } 66 | 67 | leaf session-id { 68 | type nc:session-id-or-zero-type; 69 | mandatory true; 70 | description 71 | "Identifier of the session. 72 | A NETCONF session MUST be identified by a non-zero value. 73 | A non-NETCONF session MAY be identified by the value zero."; 74 | } 75 | 76 | leaf source-host { 77 | type inet:ip-address; 78 | description 79 | "Address of the remote host for the session."; 80 | } 81 | } 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | grouping changed-by-parms { 91 | description 92 | "Common parameters to identify the source 93 | of a change event, such as a configuration 94 | or capability change."; 95 | 96 | container changed-by { 97 | description 98 | "Indicates the source of the change. 99 | If caused by internal action, then the 100 | empty leaf 'server' will be present. 101 | If caused by a management session, then 102 | the name, remote host address, and session ID 103 | of the session that made the change will be reported."; 104 | choice server-or-user { 105 | mandatory true; 106 | leaf server { 107 | type empty; 108 | description 109 | "If present, the change was caused 110 | by the server."; 111 | } 112 | 113 | case by-user { 114 | uses common-session-parms; 115 | } 116 | } // choice server-or-user 117 | } // container changed-by-parms 118 | } 119 | 120 | 121 | notification netconf-config-change { 122 | description 123 | "Generated when the NETCONF server detects that the 124 | or configuration datastore 125 | has been changed by a management session. 126 | The notification summarizes the edits that 127 | have been detected. 128 | 129 | The server MAY choose to also generate this 130 | notification while loading a datastore during the 131 | boot process for the device."; 132 | 133 | uses changed-by-parms; 134 | 135 | 136 | 137 | 138 | 139 | leaf datastore { 140 | type enumeration { 141 | enum running { 142 | description "The datastore has changed."; 143 | } 144 | enum startup { 145 | description "The datastore has changed"; 146 | } 147 | } 148 | default "running"; 149 | description 150 | "Indicates which configuration datastore has changed."; 151 | } 152 | 153 | list edit { 154 | description 155 | "An edit record SHOULD be present for each distinct 156 | edit operation that the server has detected on 157 | the target datastore. This list MAY be omitted 158 | if the detailed edit operations are not known. 159 | The server MAY report entries in this list for 160 | changes not made by a NETCONF session (e.g., CLI)."; 161 | 162 | leaf target { 163 | type instance-identifier; 164 | description 165 | "Topmost node associated with the configuration change. 166 | A server SHOULD set this object to the node within 167 | the datastore that is being altered. A server MAY 168 | set this object to one of the ancestors of the actual 169 | node that was changed, or omit this object, if the 170 | exact node is not known."; 171 | } 172 | 173 | leaf operation { 174 | type nc:edit-operation-type; 175 | description 176 | "Type of edit operation performed. 177 | A server MUST set this object to the NETCONF edit 178 | operation performed on the target datastore."; 179 | } 180 | } // list edit 181 | } // notification netconf-config-change 182 | 183 | 184 | 185 | 186 | 187 | 188 | notification netconf-capability-change { 189 | description 190 | "Generated when the NETCONF server detects that 191 | the server capabilities have changed. 192 | Indicates which capabilities have been added, deleted, 193 | and/or modified. The manner in which a server 194 | capability is changed is outside the scope of this 195 | document."; 196 | 197 | uses changed-by-parms; 198 | 199 | leaf-list added-capability { 200 | type inet:uri; 201 | description 202 | "List of capabilities that have just been added."; 203 | } 204 | 205 | leaf-list deleted-capability { 206 | type inet:uri; 207 | description 208 | "List of capabilities that have just been deleted."; 209 | } 210 | 211 | leaf-list modified-capability { 212 | type inet:uri; 213 | description 214 | "List of capabilities that have just been modified. 215 | A capability is considered to be modified if the 216 | base URI for the capability has not changed, but 217 | one or more of the parameters encoded at the end of 218 | the capability URI have changed. 219 | The new modified value of the complete URI is returned."; 220 | } 221 | } // notification netconf-capability-change 222 | 223 | 224 | notification netconf-session-start { 225 | description 226 | "Generated when a NETCONF server detects that a 227 | NETCONF session has started. A server MAY generate 228 | this event for non-NETCONF management sessions. 229 | Indicates the identity of the user that started 230 | the session."; 231 | uses common-session-parms; 232 | } // notification netconf-session-start 233 | 234 | 235 | 236 | 237 | notification netconf-session-end { 238 | description 239 | "Generated when a NETCONF server detects that a 240 | NETCONF session has terminated. 241 | A server MAY optionally generate this event for 242 | non-NETCONF management sessions. Indicates the 243 | identity of the user that owned the session, 244 | and why the session was terminated."; 245 | 246 | uses common-session-parms; 247 | 248 | leaf killed-by { 249 | when "../termination-reason = 'killed'"; 250 | type nc:session-id-type; 251 | description 252 | "The ID of the session that directly caused this session 253 | to be abnormally terminated. If this session was abnormally 254 | terminated by a non-NETCONF session unknown to the server, 255 | then this leaf will not be present."; 256 | } 257 | 258 | leaf termination-reason { 259 | type enumeration { 260 | enum "closed" { 261 | description 262 | "The session was terminated by the client in normal 263 | fashion, e.g., by the NETCONF 264 | protocol operation."; 265 | } 266 | enum "killed" { 267 | description 268 | "The session was terminated in abnormal 269 | fashion, e.g., by the NETCONF 270 | protocol operation."; 271 | } 272 | enum "dropped" { 273 | description 274 | "The session was terminated because the transport layer 275 | connection was unexpectedly closed."; 276 | } 277 | enum "timeout" { 278 | description 279 | "The session was terminated because of inactivity, 280 | e.g., waiting for the message or 281 | messages."; 282 | } 283 | 284 | 285 | 286 | enum "bad-hello" { 287 | description 288 | "The client's message was invalid."; 289 | } 290 | enum "other" { 291 | description 292 | "The session was terminated for some other reason."; 293 | } 294 | } 295 | mandatory true; 296 | description 297 | "Reason the session was terminated."; 298 | } 299 | } // notification netconf-session-end 300 | 301 | 302 | notification netconf-confirmed-commit { 303 | description 304 | "Generated when a NETCONF server detects that a 305 | confirmed-commit event has occurred. Indicates the event 306 | and the current state of the confirmed-commit procedure 307 | in progress."; 308 | reference 309 | "RFC 6241, Section 8.4"; 310 | 311 | uses common-session-parms { 312 | when "confirm-event != 'timeout'"; 313 | } 314 | 315 | leaf confirm-event { 316 | type enumeration { 317 | enum "start" { 318 | description 319 | "The confirmed-commit procedure has started."; 320 | } 321 | enum "cancel" { 322 | description 323 | "The confirmed-commit procedure has been canceled, 324 | e.g., due to the session being terminated, or an 325 | explicit operation."; 326 | } 327 | enum "timeout" { 328 | description 329 | "The confirmed-commit procedure has been canceled 330 | due to the confirm-timeout interval expiring. 331 | The common session parameters will not be present 332 | in this sub-mode."; 333 | } 334 | 335 | enum "extend" { 336 | description 337 | "The confirmed-commit timeout has been extended, 338 | e.g., by a new operation."; 339 | } 340 | enum "complete" { 341 | description 342 | "The confirmed-commit procedure has been completed."; 343 | } 344 | } 345 | mandatory true; 346 | description 347 | "Indicates the event that caused the notification."; 348 | } 349 | 350 | leaf timeout { 351 | when 352 | "../confirm-event = 'start' or ../confirm-event = 'extend'"; 353 | type uint32; 354 | units "seconds"; 355 | description 356 | "The configured timeout value if the event type 357 | is 'start' or 'extend'. This value represents 358 | the approximate number of seconds from the event 359 | time when the 'timeout' event might occur."; 360 | } 361 | } // notification netconf-confirmed-commit 362 | 363 | } 364 | -------------------------------------------------------------------------------- /ietf-yangs/ietf-netconf-partial-lock.yang: -------------------------------------------------------------------------------- 1 | module ietf-netconf-partial-lock { 2 | 3 | namespace urn:ietf:params:xml:ns:netconf:partial-lock:1.0; 4 | prefix pl; 5 | 6 | // needed to force data type of select string to be corect 7 | import ietf-yang-types { prefix yang; } 8 | 9 | organization "IETF Network Configuration (netconf) Working Group"; 10 | 11 | contact 12 | "Netconf Working Group 13 | Mailing list: netconf@ietf.org 14 | Web: http://www.ietf.org/html.charters/netconf-charter.html 15 | 16 | Balazs Lengyel 17 | Ericsson 18 | balazs.lengyel@ericsson.com"; 19 | 20 | description 21 | "This YANG module defines the and 22 | operations."; 23 | 24 | revision 2009-10-19 { 25 | description 26 | "Initial version, published as RFC 5717."; 27 | } 28 | 29 | typedef lock-id-type { 30 | type uint32; 31 | description 32 | "A number identifying a specific partial-lock granted to a session. 33 | It is allocated by the system, and SHOULD be used in the 34 | partial-unlock operation."; 35 | } 36 | 37 | rpc partial-lock { 38 | description 39 | "A NETCONF operation that locks parts of the running datastore."; 40 | input { 41 | leaf-list select { 42 | //type string; 43 | type yang:xpath1.0; 44 | min-elements 1; 45 | description 46 | "XPath expression that specifies the scope of the lock. 47 | An Instance Identifier expression MUST be used unless the 48 | :xpath capability is supported, in which case any XPath 1.0 49 | expression is allowed."; 50 | } 51 | } 52 | output { 53 | leaf lock-id { 54 | type lock-id-type; 55 | mandatory true; 56 | description 57 | "Identifies the lock, if granted. The lock-id SHOULD be 58 | used in the partial-unlock rpc."; 59 | } 60 | leaf-list locked-node { 61 | type instance-identifier; 62 | min-elements 1; 63 | description 64 | "List of locked nodes in the running datastore"; 65 | } 66 | } 67 | } 68 | 69 | rpc partial-unlock { 70 | description 71 | "A NETCONF operation that releases a previously acquired 72 | partial-lock."; 73 | input { 74 | leaf lock-id { 75 | type lock-id-type; 76 | mandatory true; 77 | description 78 | "Identifies the lock to be released. MUST be the value 79 | received in the response to a partial-lock operation."; 80 | } 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /ietf-yangs/ietf-netconf-partial-lock@2009-10-19.yang: -------------------------------------------------------------------------------- 1 | module ietf-netconf-partial-lock { 2 | 3 | namespace urn:ietf:params:xml:ns:netconf:partial-lock:1.0; 4 | prefix pl; 5 | 6 | // needed to force data type of select string to be corect 7 | import ietf-yang-types { prefix yang; } 8 | 9 | organization "IETF Network Configuration (netconf) Working Group"; 10 | 11 | contact 12 | "Netconf Working Group 13 | Mailing list: netconf@ietf.org 14 | Web: http://www.ietf.org/html.charters/netconf-charter.html 15 | 16 | Balazs Lengyel 17 | Ericsson 18 | balazs.lengyel@ericsson.com"; 19 | 20 | description 21 | "This YANG module defines the and 22 | operations."; 23 | 24 | revision 2009-10-19 { 25 | description 26 | "Initial version, published as RFC 5717."; 27 | } 28 | 29 | typedef lock-id-type { 30 | type uint32; 31 | description 32 | "A number identifying a specific partial-lock granted to a session. 33 | It is allocated by the system, and SHOULD be used in the 34 | partial-unlock operation."; 35 | } 36 | 37 | rpc partial-lock { 38 | description 39 | "A NETCONF operation that locks parts of the running datastore."; 40 | input { 41 | leaf-list select { 42 | //type string; 43 | type yang:xpath1.0; 44 | min-elements 1; 45 | description 46 | "XPath expression that specifies the scope of the lock. 47 | An Instance Identifier expression MUST be used unless the 48 | :xpath capability is supported, in which case any XPath 1.0 49 | expression is allowed."; 50 | } 51 | } 52 | output { 53 | leaf lock-id { 54 | type lock-id-type; 55 | mandatory true; 56 | description 57 | "Identifies the lock, if granted. The lock-id SHOULD be 58 | used in the partial-unlock rpc."; 59 | } 60 | leaf-list locked-node { 61 | type instance-identifier; 62 | min-elements 1; 63 | description 64 | "List of locked nodes in the running datastore"; 65 | } 66 | } 67 | } 68 | 69 | rpc partial-unlock { 70 | description 71 | "A NETCONF operation that releases a previously acquired 72 | partial-lock."; 73 | input { 74 | leaf lock-id { 75 | type lock-id-type; 76 | mandatory true; 77 | description 78 | "Identifies the lock to be released. MUST be the value 79 | received in the response to a partial-lock operation."; 80 | } 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /ietf-yangs/ietf-netconf-with-defaults.yang: -------------------------------------------------------------------------------- 1 | module ietf-netconf-with-defaults { 2 | 3 | namespace "urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults"; 4 | 5 | prefix ncwd; 6 | 7 | import ietf-netconf { prefix nc; } 8 | 9 | organization 10 | "IETF NETCONF (Network Configuration Protocol) Working Group"; 11 | 12 | contact 13 | "WG Web: 14 | 15 | WG List: 16 | 17 | WG Chair: Bert Wijnen 18 | 19 | 20 | WG Chair: Mehmet Ersue 21 | 22 | 23 | Editor: Andy Bierman 24 | 25 | 26 | Editor: Balazs Lengyel 27 | "; 28 | 29 | description 30 | "This module defines an extension to the NETCONF protocol 31 | that allows the NETCONF client to control how default 32 | values are handled by the server in particular NETCONF 33 | operations. 34 | 35 | Copyright (c) 2011 IETF Trust and the persons identified as 36 | the document authors. All rights reserved. 37 | 38 | Redistribution and use in source and binary forms, with or 39 | without modification, is permitted pursuant to, and subject 40 | to the license terms contained in, the Simplified BSD License 41 | set forth in Section 4.c of the IETF Trust's Legal Provisions 42 | Relating to IETF Documents 43 | (http://trustee.ietf.org/license-info). 44 | 45 | This version of this YANG module is part of RFC 6243; see 46 | the RFC itself for full legal notices."; 47 | 48 | revision 2011-06-01 { 49 | description 50 | "Initial version."; 51 | reference 52 | "RFC 6243: With-defaults Capability for NETCONF"; 53 | } 54 | 55 | typedef with-defaults-mode { 56 | description 57 | "Possible modes to report default data."; 58 | reference 59 | "RFC 6243; Section 3."; 60 | type enumeration { 61 | enum report-all { 62 | description 63 | "All default data is reported."; 64 | reference 65 | "RFC 6243; Section 3.1"; 66 | } 67 | enum report-all-tagged { 68 | description 69 | "All default data is reported. 70 | Any nodes considered to be default data 71 | will contain a 'default' XML attribute, 72 | set to 'true' or '1'."; 73 | reference 74 | "RFC 6243; Section 3.4"; 75 | } 76 | enum trim { 77 | description 78 | "Values are not reported if they contain the default."; 79 | reference 80 | "RFC 6243; Section 3.2"; 81 | } 82 | enum explicit { 83 | description 84 | "Report values that contain the definition of 85 | explicitly set data."; 86 | reference 87 | "RFC 6243; Section 3.3"; 88 | } 89 | } 90 | } 91 | 92 | grouping with-defaults-parameters { 93 | description 94 | "Contains the parameter for control 95 | of defaults in NETCONF retrieval operations."; 96 | 97 | leaf with-defaults { 98 | description 99 | "The explicit defaults processing mode requested."; 100 | reference 101 | "RFC 6243; Section 4.5.1"; 102 | 103 | type with-defaults-mode; 104 | } 105 | } 106 | 107 | // extending the get-config operation 108 | augment /nc:get-config/nc:input { 109 | description 110 | "Adds the parameter to the 111 | input of the NETCONF operation."; 112 | reference 113 | "RFC 6243; Section 4.5.1"; 114 | 115 | uses with-defaults-parameters; 116 | } 117 | 118 | // extending the get operation 119 | augment /nc:get/nc:input { 120 | description 121 | "Adds the parameter to 122 | the input of the NETCONF operation."; 123 | reference 124 | "RFC 6243; Section 4.5.1"; 125 | 126 | uses with-defaults-parameters; 127 | } 128 | 129 | // extending the copy-config operation 130 | augment /nc:copy-config/nc:input { 131 | description 132 | "Adds the parameter to 133 | the input of the NETCONF operation."; 134 | reference 135 | "RFC 6243; Section 4.5.1"; 136 | 137 | uses with-defaults-parameters; 138 | } 139 | 140 | } 141 | -------------------------------------------------------------------------------- /ietf-yangs/ietf-netconf-with-defaults@2011-06-01.yang: -------------------------------------------------------------------------------- 1 | module ietf-netconf-with-defaults { 2 | 3 | namespace "urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults"; 4 | 5 | prefix ncwd; 6 | 7 | import ietf-netconf { prefix nc; } 8 | 9 | organization 10 | "IETF NETCONF (Network Configuration Protocol) Working Group"; 11 | 12 | contact 13 | "WG Web: 14 | 15 | WG List: 16 | 17 | WG Chair: Bert Wijnen 18 | 19 | 20 | WG Chair: Mehmet Ersue 21 | 22 | 23 | Editor: Andy Bierman 24 | 25 | 26 | Editor: Balazs Lengyel 27 | "; 28 | 29 | description 30 | "This module defines an extension to the NETCONF protocol 31 | that allows the NETCONF client to control how default 32 | values are handled by the server in particular NETCONF 33 | operations. 34 | 35 | Copyright (c) 2011 IETF Trust and the persons identified as 36 | the document authors. All rights reserved. 37 | 38 | Redistribution and use in source and binary forms, with or 39 | without modification, is permitted pursuant to, and subject 40 | to the license terms contained in, the Simplified BSD License 41 | set forth in Section 4.c of the IETF Trust's Legal Provisions 42 | Relating to IETF Documents 43 | (http://trustee.ietf.org/license-info). 44 | 45 | This version of this YANG module is part of RFC 6243; see 46 | the RFC itself for full legal notices."; 47 | 48 | revision 2011-06-01 { 49 | description 50 | "Initial version."; 51 | reference 52 | "RFC 6243: With-defaults Capability for NETCONF"; 53 | } 54 | 55 | typedef with-defaults-mode { 56 | description 57 | "Possible modes to report default data."; 58 | reference 59 | "RFC 6243; Section 3."; 60 | type enumeration { 61 | enum report-all { 62 | description 63 | "All default data is reported."; 64 | reference 65 | "RFC 6243; Section 3.1"; 66 | } 67 | enum report-all-tagged { 68 | description 69 | "All default data is reported. 70 | Any nodes considered to be default data 71 | will contain a 'default' XML attribute, 72 | set to 'true' or '1'."; 73 | reference 74 | "RFC 6243; Section 3.4"; 75 | } 76 | enum trim { 77 | description 78 | "Values are not reported if they contain the default."; 79 | reference 80 | "RFC 6243; Section 3.2"; 81 | } 82 | enum explicit { 83 | description 84 | "Report values that contain the definition of 85 | explicitly set data."; 86 | reference 87 | "RFC 6243; Section 3.3"; 88 | } 89 | } 90 | } 91 | 92 | grouping with-defaults-parameters { 93 | description 94 | "Contains the parameter for control 95 | of defaults in NETCONF retrieval operations."; 96 | 97 | leaf with-defaults { 98 | description 99 | "The explicit defaults processing mode requested."; 100 | reference 101 | "RFC 6243; Section 4.5.1"; 102 | 103 | type with-defaults-mode; 104 | } 105 | } 106 | 107 | // extending the get-config operation 108 | augment /nc:get-config/nc:input { 109 | description 110 | "Adds the parameter to the 111 | input of the NETCONF operation."; 112 | reference 113 | "RFC 6243; Section 4.5.1"; 114 | 115 | uses with-defaults-parameters; 116 | } 117 | 118 | // extending the get operation 119 | augment /nc:get/nc:input { 120 | description 121 | "Adds the parameter to 122 | the input of the NETCONF operation."; 123 | reference 124 | "RFC 6243; Section 4.5.1"; 125 | 126 | uses with-defaults-parameters; 127 | } 128 | 129 | // extending the copy-config operation 130 | augment /nc:copy-config/nc:input { 131 | description 132 | "Adds the parameter to 133 | the input of the NETCONF operation."; 134 | reference 135 | "RFC 6243; Section 4.5.1"; 136 | 137 | uses with-defaults-parameters; 138 | } 139 | 140 | } 141 | -------------------------------------------------------------------------------- /ietf-yangs/ietf-snmp-common.yang: -------------------------------------------------------------------------------- 1 | submodule ietf-snmp-common { 2 | 3 | belongs-to ietf-snmp { 4 | prefix snmp; 5 | } 6 | 7 | import ietf-yang-types { 8 | prefix yang; 9 | } 10 | 11 | organization 12 | "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; 13 | 14 | contact 15 | "WG Web: 16 | WG List: 17 | WG Chair: Thomas Nadeau 18 | 19 | 20 | WG Chair: Juergen Schoenwaelder 21 | 22 | 23 | Editor: Martin Bjorklund 24 | 25 | 26 | Editor: Juergen Schoenwaelder 27 | "; 28 | 29 | description 30 | "This submodule contains a collection of common YANG definitions 31 | for configuring SNMP engines. 32 | 33 | Copyright (c) 2014 IETF Trust and the persons identified as 34 | authors of the code. All rights reserved. 35 | 36 | Redistribution and use in source and binary forms, with or 37 | without modification, is permitted pursuant to, and subject 38 | to the license terms contained in, the Simplified BSD License 39 | set forth in Section 4.c of the IETF Trust's Legal Provisions 40 | Relating to IETF Documents 41 | (http://trustee.ietf.org/license-info). 42 | 43 | This version of this YANG module is part of RFC 7407; see 44 | the RFC itself for full legal notices."; 45 | 46 | revision 2014-12-10 { 47 | description 48 | "Initial revision."; 49 | reference 50 | "RFC 7407: A YANG Data Model for SNMP Configuration"; 51 | } 52 | 53 | /* Collection of SNMP-specific data types */ 54 | 55 | typedef admin-string { 56 | type string { 57 | length "0..255"; 58 | } 59 | description 60 | "Represents SnmpAdminString as defined in RFC 3411. 61 | 62 | Note that the size of an SnmpAdminString is measured in 63 | octets, not characters."; 64 | 65 | reference 66 | "RFC 3411: An Architecture for Describing Simple Network 67 | Management Protocol (SNMP) Management Frameworks. 68 | SNMP-FRAMEWORK-MIB.SnmpAdminString"; 69 | } 70 | 71 | typedef identifier { 72 | type admin-string { 73 | length "1..32"; 74 | } 75 | description 76 | "Identifiers are used to name items in the SNMP configuration 77 | datastore."; 78 | } 79 | 80 | typedef context-name { 81 | type admin-string { 82 | length "0..32"; 83 | } 84 | description 85 | "The context type represents an SNMP context name."; 86 | reference 87 | "RFC 3411: An Architecture for Describing Simple Network 88 | Management Protocol (SNMP) Management Frameworks"; 89 | } 90 | 91 | typedef security-name { 92 | type admin-string { 93 | length "1..32"; 94 | } 95 | description 96 | "The security-name type represents an SNMP security name."; 97 | reference 98 | "RFC 3411: An Architecture for Describing Simple Network 99 | Management Protocol (SNMP) Management Frameworks"; 100 | } 101 | 102 | typedef security-model { 103 | type union { 104 | type enumeration { 105 | enum v1 { value 1; } 106 | enum v2c { value 2; } 107 | enum usm { value 3; } 108 | enum tsm { value 4; } 109 | } 110 | type int32 { 111 | range "1..2147483647"; 112 | } 113 | } 114 | reference 115 | "RFC 3411: An Architecture for Describing Simple Network 116 | Management Protocol (SNMP) Management Frameworks"; 117 | } 118 | 119 | typedef security-model-or-any { 120 | type union { 121 | type enumeration { 122 | enum any { value 0; } 123 | } 124 | type security-model; 125 | } 126 | reference 127 | "RFC 3411: An Architecture for Describing Simple Network 128 | Management Protocol (SNMP) Management Frameworks"; 129 | } 130 | 131 | typedef security-level { 132 | type enumeration { 133 | enum no-auth-no-priv { value 1; } 134 | enum auth-no-priv { value 2; } 135 | enum auth-priv { value 3; } 136 | } 137 | reference 138 | "RFC 3411: An Architecture for Describing Simple Network 139 | Management Protocol (SNMP) Management Frameworks"; 140 | } 141 | 142 | typedef engine-id { 143 | type yang:hex-string { 144 | pattern '([0-9a-fA-F]){2}(:([0-9a-fA-F]){2}){4,31}'; 145 | } 146 | description 147 | "The engine ID specified as a list of colon-specified 148 | hexadecimal octets, e.g., '80:00:02:b8:04:61:62:63'."; 149 | reference 150 | "RFC 3411: An Architecture for Describing Simple Network 151 | Management Protocol (SNMP) Management Frameworks"; 152 | } 153 | 154 | typedef wildcard-object-identifier { 155 | type string; 156 | description 157 | "The wildcard-object-identifier type represents an SNMP object 158 | identifier where subidentifiers can be given either as a label, 159 | in numeric form, or a wildcard, represented by an asterisk 160 | ('*')."; 161 | } 162 | 163 | typedef tag-value { 164 | type string { 165 | length "0..255"; 166 | } 167 | description 168 | "Represents SnmpTagValue as defined in RFC 3413. 169 | 170 | Note that the size of an SnmpTagValue is measured in 171 | octets, not characters."; 172 | reference 173 | "RFC 3413: Simple Network Management Protocol (SNMP) 174 | Applications. 175 | SNMP-TARGET-MIB.SnmpTagValue"; 176 | } 177 | 178 | container snmp { 179 | description 180 | "Top-level container for SNMP-related configuration and 181 | status objects."; 182 | } 183 | 184 | } 185 | -------------------------------------------------------------------------------- /ietf-yangs/ietf-snmp-community.yang: -------------------------------------------------------------------------------- 1 | submodule ietf-snmp-community { 2 | 3 | belongs-to ietf-snmp { 4 | prefix snmp; 5 | } 6 | 7 | import ietf-netconf-acm { 8 | prefix nacm; 9 | } 10 | 11 | include ietf-snmp-common; 12 | include ietf-snmp-target; 13 | include ietf-snmp-proxy; 14 | 15 | organization 16 | "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; 17 | 18 | contact 19 | "WG Web: 20 | WG List: 21 | 22 | WG Chair: Thomas Nadeau 23 | 24 | 25 | WG Chair: Juergen Schoenwaelder 26 | 27 | Editor: Martin Bjorklund 28 | 29 | 30 | Editor: Juergen Schoenwaelder 31 | "; 32 | 33 | description 34 | "This submodule contains a collection of YANG definitions 35 | for configuring community-based SNMP. 36 | 37 | Copyright (c) 2014 IETF Trust and the persons identified as 38 | authors of the code. All rights reserved. 39 | 40 | Redistribution and use in source and binary forms, with or 41 | without modification, is permitted pursuant to, and subject 42 | to the license terms contained in, the Simplified BSD License 43 | set forth in Section 4.c of the IETF Trust's Legal Provisions 44 | Relating to IETF Documents 45 | (http://trustee.ietf.org/license-info). 46 | 47 | This version of this YANG module is part of RFC 7407; see 48 | the RFC itself for full legal notices."; 49 | 50 | reference 51 | "RFC 3584: Coexistence between Version 1, Version 2, and 52 | Version 3 of the Internet-standard Network 53 | Management Framework"; 54 | 55 | revision 2014-12-10 { 56 | description 57 | "Initial revision."; 58 | reference 59 | "RFC 7407: A YANG Data Model for SNMP Configuration"; 60 | } 61 | 62 | augment /snmp:snmp { 63 | 64 | list community { 65 | key index; 66 | 67 | description 68 | "List of communities."; 69 | reference 70 | "RFC 3584: Coexistence between Version 1, Version 2, 71 | and Version 3 of the Internet-standard 72 | Network Management Framework. 73 | SNMP-COMMUNITY-MIB.snmpCommunityTable"; 74 | 75 | leaf index { 76 | type snmp:identifier; 77 | description 78 | "Index into the community list."; 79 | reference 80 | "RFC 3584: Coexistence between Version 1, Version 2, 81 | and Version 3 of the Internet-standard 82 | Network Management Framework. 83 | SNMP-COMMUNITY-MIB.snmpCommunityIndex"; 84 | } 85 | choice name { 86 | nacm:default-deny-all; 87 | description 88 | "The community name, specified as either a string or 89 | a binary value. The binary name is used when the 90 | community name contains characters that are not legal 91 | in a string. 92 | 93 | If not set, the value of 'security-name' is operationally 94 | used as the snmpCommunityName."; 95 | reference 96 | "RFC 3584: Coexistence between Version 1, Version 2, 97 | and Version 3 of the Internet-standard 98 | Network Management Framework. 99 | SNMP-COMMUNITY-MIB.snmpCommunityName"; 100 | leaf text-name { 101 | type string; 102 | description 103 | "A community name that can be represented as a 104 | YANG string."; 105 | } 106 | leaf binary-name { 107 | type binary; 108 | description 109 | "A community name represented as a binary value."; 110 | } 111 | } 112 | leaf security-name { 113 | type snmp:security-name; 114 | mandatory true; 115 | nacm:default-deny-all; 116 | description 117 | "The snmpCommunitySecurityName of this entry."; 118 | reference 119 | "RFC 3584: Coexistence between Version 1, Version 2, 120 | and Version 3 of the Internet-standard 121 | Network Management Framework. 122 | SNMP-COMMUNITY-MIB.snmpCommunitySecurityName"; 123 | } 124 | leaf engine-id { 125 | if-feature snmp:proxy; 126 | type snmp:engine-id; 127 | description 128 | "If not set, the value of the local SNMP engine is 129 | operationally used by the device."; 130 | reference 131 | "RFC 3584: Coexistence between Version 1, Version 2, 132 | and Version 3 of the Internet-standard 133 | Network Management Framework. 134 | SNMP-COMMUNITY-MIB.snmpCommunityContextEngineID"; 135 | } 136 | leaf context { 137 | type snmp:context-name; 138 | default ""; 139 | description 140 | "The context in which management information is accessed 141 | when using the community string specified by this entry."; 142 | reference 143 | "RFC 3584: Coexistence between Version 1, Version 2, 144 | and Version 3 of the Internet-standard 145 | Network Management Framework. 146 | SNMP-COMMUNITY-MIB.snmpCommunityContextName"; 147 | } 148 | leaf target-tag { 149 | type snmp:tag-value; 150 | description 151 | "Used to limit access for this community to the specified 152 | targets. 153 | 154 | Implementations MAY restrict the values of this leaf 155 | to be one of the available values of /snmp/target/tag in 156 | a valid configuration."; 157 | reference 158 | "RFC 3584: Coexistence between Version 1, Version 2, 159 | and Version 3 of the Internet-standard 160 | Network Management Framework. 161 | SNMP-COMMUNITY-MIB.snmpCommunityTransportTag"; 162 | } 163 | } 164 | } 165 | 166 | grouping v1-target-params { 167 | container v1 { 168 | description 169 | "SNMPv1 parameters type. 170 | Represents snmpTargetParamsMPModel '0', 171 | snmpTargetParamsSecurityModel '1', and 172 | snmpTargetParamsSecurityLevel 'noAuthNoPriv'."; 173 | leaf security-name { 174 | type snmp:security-name; 175 | mandatory true; 176 | description 177 | "Implementations MAY restrict the values of this leaf 178 | to be one of the available values of 179 | /snmp/community/security-name in a valid configuration."; 180 | reference 181 | "RFC 3413: Simple Network Management Protocol (SNMP). 182 | Applications. 183 | SNMP-TARGET-MIB.snmpTargetParamsSecurityName"; 184 | } 185 | } 186 | } 187 | 188 | grouping v2c-target-params { 189 | container v2c { 190 | description 191 | "SNMPv2 community parameters type. 192 | Represents snmpTargetParamsMPModel '1', 193 | snmpTargetParamsSecurityModel '2', and 194 | snmpTargetParamsSecurityLevel 'noAuthNoPriv'."; 195 | leaf security-name { 196 | type snmp:security-name; 197 | mandatory true; 198 | description 199 | "Implementations MAY restrict the values of this leaf 200 | to be one of the available values of 201 | /snmp/community/security-name in a valid configuration."; 202 | reference 203 | "RFC 3413: Simple Network Management Protocol (SNMP). 204 | Applications. 205 | SNMP-TARGET-MIB.snmpTargetParamsSecurityName"; 206 | } 207 | } 208 | } 209 | 210 | augment /snmp:snmp/snmp:target-params/snmp:params { 211 | case v1 { 212 | uses v1-target-params; 213 | } 214 | case v2c { 215 | uses v2c-target-params; 216 | } 217 | } 218 | 219 | augment /snmp:snmp/snmp:target { 220 | when "snmp:v1 or snmp:v2c"; 221 | leaf mms { 222 | type union { 223 | type enumeration { 224 | enum "unknown" { value 0; } 225 | } 226 | type int32 { 227 | range "484..max"; 228 | } 229 | } 230 | default "484"; 231 | description 232 | "The maximum message size."; 233 | reference 234 | "RFC 3584: Coexistence between Version 1, Version 2, 235 | and Version 3 of the Internet-standard 236 | Network Management Framework. 237 | SNMP-COMMUNITY-MIB.snmpTargetAddrMMS"; 238 | } 239 | } 240 | 241 | } 242 | -------------------------------------------------------------------------------- /ietf-yangs/ietf-snmp-engine.yang: -------------------------------------------------------------------------------- 1 | submodule ietf-snmp-engine { 2 | 3 | belongs-to ietf-snmp { 4 | prefix snmp; 5 | } 6 | 7 | import ietf-inet-types { 8 | prefix inet; 9 | } 10 | 11 | include ietf-snmp-common; 12 | 13 | organization 14 | "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; 15 | 16 | contact 17 | "WG Web: 18 | WG List: 19 | 20 | WG Chair: Thomas Nadeau 21 | 22 | 23 | WG Chair: Juergen Schoenwaelder 24 | 25 | 26 | Editor: Martin Bjorklund 27 | 28 | 29 | Editor: Juergen Schoenwaelder 30 | "; 31 | 32 | description 33 | "This submodule contains a collection of YANG definitions 34 | for configuring SNMP engines. 35 | 36 | Copyright (c) 2014 IETF Trust and the persons identified as 37 | authors of the code. All rights reserved. 38 | 39 | Redistribution and use in source and binary forms, with or 40 | without modification, is permitted pursuant to, and subject 41 | to the license terms contained in, the Simplified BSD License 42 | set forth in Section 4.c of the IETF Trust's Legal Provisions 43 | Relating to IETF Documents 44 | (http://trustee.ietf.org/license-info). 45 | This version of this YANG module is part of RFC 7407; see 46 | the RFC itself for full legal notices."; 47 | 48 | revision 2014-12-10 { 49 | description 50 | "Initial revision."; 51 | reference 52 | "RFC 7407: A YANG Data Model for SNMP Configuration"; 53 | } 54 | 55 | augment /snmp:snmp { 56 | 57 | container engine { 58 | 59 | description 60 | "Configuration of the SNMP engine."; 61 | 62 | leaf enabled { 63 | type boolean; 64 | default "false"; 65 | description 66 | "Enables the SNMP engine."; 67 | } 68 | 69 | list listen { 70 | key "name"; 71 | description 72 | "Configuration of the transport endpoints on which the 73 | engine listens."; 74 | 75 | leaf name { 76 | type snmp:identifier; 77 | description 78 | "An arbitrary name for the list entry."; 79 | } 80 | 81 | choice transport { 82 | mandatory true; 83 | description 84 | "The transport-protocol-specific parameters for this 85 | endpoint. Submodules providing configuration for 86 | additional transports are expected to augment this 87 | choice."; 88 | case udp { 89 | container udp { 90 | leaf ip { 91 | type inet:ip-address; 92 | mandatory true; 93 | description 94 | "The IPv4 or IPv6 address on which the engine 95 | listens."; 96 | } 97 | leaf port { 98 | type inet:port-number; 99 | description 100 | "The UDP port on which the engine listens. 101 | 102 | If the port is not configured, an engine that 103 | acts as a Command Responder uses port 161, and 104 | an engine that acts as a Notification Receiver 105 | uses port 162."; 106 | } 107 | } 108 | } 109 | } 110 | } 111 | 112 | 113 | 114 | container version { 115 | description 116 | "SNMP version used by the engine."; 117 | leaf v1 { 118 | type empty; 119 | } 120 | leaf v2c { 121 | type empty; 122 | } 123 | leaf v3 { 124 | type empty; 125 | } 126 | } 127 | 128 | leaf engine-id { 129 | type snmp:engine-id; 130 | description 131 | "The local SNMP engine's administratively assigned unique 132 | identifier. 133 | 134 | If this leaf is not set, the device automatically 135 | calculates an engine ID, as described in RFC 3411. A 136 | server MAY initialize this leaf with the automatically 137 | created value."; 138 | reference 139 | "RFC 3411: An Architecture for Describing Simple Network 140 | Management Protocol (SNMP) Management 141 | Frameworks. 142 | SNMP-FRAMEWORK-MIB.snmpEngineID"; 143 | } 144 | 145 | leaf enable-authen-traps { 146 | type boolean; 147 | description 148 | "Indicates whether the SNMP entity is permitted to 149 | generate authenticationFailure traps."; 150 | reference 151 | "RFC 3418: Management Information Base (MIB) for the 152 | Simple Network Management Protocol (SNMP) 153 | SNMPv2-MIB.snmpEnableAuthenTraps"; 154 | } 155 | } 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /ietf-yangs/ietf-snmp-notification.yang: -------------------------------------------------------------------------------- 1 | submodule ietf-snmp-notification { 2 | 3 | belongs-to ietf-snmp { 4 | prefix snmp; 5 | } 6 | 7 | include ietf-snmp-common; 8 | include ietf-snmp-target; 9 | 10 | organization 11 | "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; 12 | 13 | contact 14 | "WG Web: 15 | WG List: 16 | 17 | WG Chair: Thomas Nadeau 18 | 19 | WG Chair: Juergen Schoenwaelder 20 | 21 | 22 | Editor: Martin Bjorklund 23 | 24 | 25 | Editor: Juergen Schoenwaelder 26 | "; 27 | 28 | description 29 | "This submodule contains a collection of YANG definitions 30 | for configuring SNMP notifications. 31 | 32 | Copyright (c) 2014 IETF Trust and the persons identified as 33 | authors of the code. All rights reserved. 34 | 35 | Redistribution and use in source and binary forms, with or 36 | without modification, is permitted pursuant to, and subject 37 | to the license terms contained in, the Simplified BSD License 38 | set forth in Section 4.c of the IETF Trust's Legal Provisions 39 | Relating to IETF Documents 40 | (http://trustee.ietf.org/license-info). 41 | 42 | This version of this YANG module is part of RFC 7407; see 43 | the RFC itself for full legal notices."; 44 | 45 | reference 46 | "RFC 3413: Simple Network Management Protocol (SNMP) 47 | Applications"; 48 | 49 | revision 2014-12-10 { 50 | description 51 | "Initial revision."; 52 | reference 53 | "RFC 7407: A YANG Data Model for SNMP Configuration"; 54 | } 55 | 56 | feature notification-filter { 57 | description 58 | "A server implements this feature if it supports SNMP 59 | notification filtering."; 60 | reference 61 | "RFC 3413: Simple Network Management Protocol (SNMP) 62 | Applications"; 63 | } 64 | 65 | augment /snmp:snmp { 66 | 67 | list notify { 68 | key name; 69 | description 70 | "Targets that will receive notifications. 71 | 72 | Entries in this list are mapped 1-1 to entries in 73 | snmpNotifyTable, except that if an entry in snmpNotifyTable 74 | has an snmpNotifyTag for which no snmpTargetAddrEntry 75 | exists, then the snmpNotifyTable entry is not mapped to an 76 | entry in this list."; 77 | reference 78 | "RFC 3413: Simple Network Management Protocol (SNMP). 79 | Applications. 80 | SNMP-NOTIFICATION-MIB.snmpNotifyTable"; 81 | 82 | leaf name { 83 | type snmp:identifier; 84 | description 85 | "An arbitrary name for the list entry."; 86 | reference 87 | "RFC 3413: Simple Network Management Protocol (SNMP). 88 | Applications. 89 | SNMP-NOTIFICATION-MIB.snmpNotifyName"; 90 | } 91 | leaf tag { 92 | type snmp:tag-value; 93 | mandatory true; 94 | description 95 | "Target tag, selects a set of notification targets. 96 | 97 | Implementations MAY restrict the values of this leaf 98 | to be one of the available values of /snmp/target/tag in 99 | a valid configuration."; 100 | reference 101 | "RFC 3413: Simple Network Management Protocol (SNMP). 102 | Applications. 103 | SNMP-NOTIFICATION-MIB.snmpNotifyTag"; 104 | } 105 | leaf type { 106 | type enumeration { 107 | enum trap { value 1; } 108 | enum inform { value 2; } 109 | } 110 | default trap; 111 | description 112 | "Defines the notification type to be generated."; 113 | 114 | 115 | reference 116 | "RFC 3413: Simple Network Management Protocol (SNMP). 117 | Applications. 118 | SNMP-NOTIFICATION-MIB.snmpNotifyType"; 119 | } 120 | } 121 | 122 | list notify-filter-profile { 123 | if-feature snmp:notification-filter; 124 | key name; 125 | 126 | description 127 | "Notification filter profiles. 128 | 129 | The leaf /snmp/target/notify-filter-profile is used 130 | to associate a filter profile with a target. 131 | 132 | If an entry in this list is referred to by one or more 133 | /snmp/target/notify-filter-profile items, each such 134 | notify-filter-profile is represented by one 135 | snmpNotifyFilterProfileEntry. 136 | 137 | If an entry in this list is not referred to by any 138 | /snmp/target/notify-filter-profile, the entry is not mapped 139 | to snmpNotifyFilterProfileTable."; 140 | reference 141 | "RFC 3413: Simple Network Management Protocol (SNMP). 142 | Applications. 143 | SNMP-NOTIFICATION-MIB.snmpNotifyFilterProfileTable 144 | SNMP-NOTIFICATION-MIB.snmpNotifyFilterTable"; 145 | 146 | leaf name { 147 | type snmp:identifier; 148 | description 149 | "Name of the filter profile."; 150 | reference 151 | "RFC 3413: Simple Network Management Protocol (SNMP). 152 | Applications. 153 | SNMP-NOTIFICATION-MIB.snmpNotifyFilterProfileName"; 154 | } 155 | 156 | leaf-list include { 157 | type snmp:wildcard-object-identifier; 158 | description 159 | "A family of subtrees included in this filter."; 160 | 161 | 162 | 163 | reference 164 | "RFC 3413: Simple Network Management Protocol (SNMP). 165 | Applications. 166 | SNMP-NOTIFICATION-MIB.snmpNotifyFilterSubtree 167 | SNMP-NOTIFICATION-MIB.snmpNotifyFilterMask 168 | SNMP-NOTIFICATION-MIB.snmpNotifyFilterType"; 169 | } 170 | 171 | leaf-list exclude { 172 | type snmp:wildcard-object-identifier; 173 | description 174 | "A family of subtrees excluded from this filter."; 175 | reference 176 | "RFC 3413: Simple Network Management Protocol (SNMP). 177 | Applications. 178 | SNMP-NOTIFICATION-MIB.snmpNotifyFilterSubtree 179 | SNMP-NOTIFICATION-MIB.snmpNotifyFilterMask 180 | SNMP-NOTIFICATION-MIB.snmpNotifyFilterType"; 181 | } 182 | } 183 | 184 | } 185 | 186 | augment /snmp:snmp/snmp:target-params { 187 | reference 188 | "RFC 3413: Simple Network Management Protocol (SNMP). 189 | Applications. 190 | SNMP-NOTIFICATION-MIB.snmpNotifyFilterProfileTable"; 191 | leaf notify-filter-profile { 192 | if-feature snmp:notification-filter; 193 | type leafref { 194 | path "/snmp/notify-filter-profile/name"; 195 | } 196 | description 197 | "This leafref leaf is used to represent the sparse 198 | relationship between the /snmp/target-params list and the 199 | /snmp/notify-filter-profile list."; 200 | reference 201 | "RFC 3413: Simple Network Management Protocol (SNMP). 202 | Applications. 203 | SNMP-NOTIFICATION-MIB.snmpNotifyFilterProfileName"; 204 | } 205 | } 206 | 207 | } 208 | -------------------------------------------------------------------------------- /ietf-yangs/ietf-snmp-proxy.yang: -------------------------------------------------------------------------------- 1 | submodule ietf-snmp-proxy { 2 | 3 | belongs-to ietf-snmp { 4 | prefix snmp; 5 | } 6 | 7 | include ietf-snmp-common; 8 | include ietf-snmp-target; 9 | 10 | organization 11 | "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; 12 | 13 | contact 14 | "WG Web: 15 | WG List: 16 | 17 | WG Chair: Thomas Nadeau 18 | 19 | 20 | WG Chair: Juergen Schoenwaelder 21 | 22 | 23 | Editor: Martin Bjorklund 24 | 25 | 26 | Editor: Juergen Schoenwaelder 27 | "; 28 | 29 | description 30 | "This submodule contains a collection of YANG definitions 31 | for configuring SNMP proxies. 32 | 33 | Copyright (c) 2014 IETF Trust and the persons identified as 34 | authors of the code. All rights reserved. 35 | 36 | Redistribution and use in source and binary forms, with or 37 | without modification, is permitted pursuant to, and subject 38 | to the license terms contained in, the Simplified BSD License 39 | set forth in Section 4.c of the IETF Trust's Legal Provisions 40 | Relating to IETF Documents 41 | (http://trustee.ietf.org/license-info). 42 | 43 | This version of this YANG module is part of RFC 7407; see 44 | the RFC itself for full legal notices."; 45 | reference 46 | "RFC 3413: Simple Network Management Protocol (SNMP) 47 | Applications"; 48 | 49 | revision 2014-12-10 { 50 | description 51 | "Initial revision."; 52 | reference 53 | "RFC 7407: A YANG Data Model for SNMP Configuration"; 54 | } 55 | 56 | feature proxy { 57 | description 58 | "A server implements this feature if it can act as an 59 | SNMP proxy."; 60 | reference 61 | "RFC 3413: Simple Network Management Protocol (SNMP) 62 | Applications"; 63 | } 64 | 65 | augment /snmp:snmp { 66 | if-feature snmp:proxy; 67 | 68 | list proxy { 69 | key name; 70 | 71 | description 72 | "List of proxy parameters."; 73 | reference 74 | "RFC 3413: Simple Network Management Protocol (SNMP). 75 | Applications. 76 | SNMP-PROXY-MIB.snmpProxyTable"; 77 | 78 | leaf name { 79 | type snmp:identifier; 80 | description 81 | "Identifies the proxy parameter entry."; 82 | reference 83 | "RFC 3413: Simple Network Management Protocol (SNMP). 84 | Applications. 85 | SNMP-PROXY-MIB.snmpProxyName"; 86 | } 87 | leaf type { 88 | type enumeration { 89 | enum read { value 1; } 90 | enum write { value 2; } 91 | enum trap { value 3; } 92 | enum inform { value 4; } 93 | } 94 | mandatory true; 95 | reference 96 | "RFC 3413: Simple Network Management Protocol (SNMP). 97 | Applications. 98 | SNMP-PROXY-MIB.snmpProxyType"; 99 | } 100 | leaf context-engine-id { 101 | type snmp:engine-id; 102 | mandatory true; 103 | reference 104 | "RFC 3413: Simple Network Management Protocol (SNMP). 105 | Applications. 106 | SNMP-PROXY-MIB.snmpProxyContextEngineID"; 107 | } 108 | leaf context-name { 109 | type snmp:context-name; 110 | reference 111 | "RFC 3413: Simple Network Management Protocol (SNMP). 112 | Applications. 113 | SNMP-PROXY-MIB.snmpProxyContextName"; 114 | } 115 | leaf target-params-in { 116 | type snmp:identifier; 117 | description 118 | "The name of a target parameters list entry. 119 | 120 | Implementations MAY restrict the values of this 121 | leaf to be one of the available values of 122 | /snmp/target-params/name in a valid configuration."; 123 | reference 124 | "RFC 3413: Simple Network Management Protocol (SNMP). 125 | Applications. 126 | SNMP-PROXY-MIB.snmpProxyTargetParamsIn"; 127 | } 128 | leaf single-target-out { 129 | when "../type = 'read' or ../type = 'write'"; 130 | type snmp:identifier; 131 | description 132 | "Implementations MAY restrict the values of this leaf 133 | to be one of the available values of /snmp/target/name in 134 | a valid configuration."; 135 | reference 136 | "RFC 3413: Simple Network Management Protocol (SNMP). 137 | Applications. 138 | SNMP-PROXY-MIB.snmpProxySingleTargetOut"; 139 | } 140 | 141 | leaf multiple-target-out { 142 | when "../type = 'trap' or ../type = 'inform'"; 143 | type snmp:tag-value; 144 | description 145 | "Implementations MAY restrict the values of this leaf 146 | to be one of the available values of /snmp/target/tag in 147 | a valid configuration."; 148 | reference 149 | "RFC 3413: Simple Network Management Protocol (SNMP). 150 | Applications. 151 | SNMP-PROXY-MIB.snmpProxyMultipleTargetOut"; 152 | } 153 | } 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /ietf-yangs/ietf-snmp-ssh.yang: -------------------------------------------------------------------------------- 1 | submodule ietf-snmp-ssh { 2 | 3 | belongs-to ietf-snmp { 4 | prefix snmp; 5 | } 6 | 7 | import ietf-inet-types { 8 | prefix inet; 9 | } 10 | 11 | include ietf-snmp-common; 12 | include ietf-snmp-engine; 13 | include ietf-snmp-target; 14 | 15 | organization 16 | "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; 17 | 18 | contact 19 | "WG Web: 20 | WG List: 21 | 22 | WG Chair: Thomas Nadeau 23 | 24 | 25 | WG Chair: Juergen Schoenwaelder 26 | 27 | 28 | Editor: Martin Bjorklund 29 | 30 | 31 | Editor: Juergen Schoenwaelder 32 | "; 33 | 34 | description 35 | "This submodule contains a collection of YANG definitions for 36 | configuring the Secure Shell Transport Model (SSHTM) 37 | of SNMP. 38 | 39 | Copyright (c) 2014 IETF Trust and the persons identified as 40 | authors of the code. All rights reserved. 41 | 42 | Redistribution and use in source and binary forms, with or 43 | without modification, is permitted pursuant to, and subject 44 | to the license terms contained in, the Simplified BSD License 45 | set forth in Section 4.c of the IETF Trust's Legal Provisions 46 | Relating to IETF Documents 47 | (http://trustee.ietf.org/license-info). 48 | 49 | This version of this YANG module is part of RFC 7407; see 50 | the RFC itself for full legal notices."; 51 | 52 | reference 53 | "RFC 5592: Secure Shell Transport Model for the 54 | Simple Network Management Protocol (SNMP)"; 55 | 56 | revision 2014-12-10 { 57 | description 58 | "Initial revision."; 59 | reference 60 | "RFC 7407: A YANG Data Model for SNMP Configuration"; 61 | } 62 | 63 | feature sshtm { 64 | description 65 | "A server implements this feature if it supports the 66 | Secure Shell Transport Model for SNMP."; 67 | reference 68 | "RFC 5592: Secure Shell Transport Model for the 69 | Simple Network Management Protocol (SNMP)"; 70 | } 71 | 72 | augment /snmp:snmp/snmp:engine/snmp:listen/snmp:transport { 73 | if-feature sshtm; 74 | case ssh { 75 | container ssh { 76 | description 77 | "The IPv4 or IPv6 address and port to which the 78 | engine listens for SNMP messages over SSH."; 79 | 80 | leaf ip { 81 | type inet:ip-address; 82 | mandatory true; 83 | description 84 | "The IPv4 or IPv6 address on which the engine listens 85 | for SNMP messages over SSH."; 86 | } 87 | leaf port { 88 | type inet:port-number; 89 | description 90 | "The TCP port on which the engine listens for SNMP 91 | messages over SSH. 92 | 93 | If the port is not configured, an engine that 94 | acts as a Command Responder uses port 5161, and 95 | an engine that acts as a Notification Receiver 96 | uses port 5162."; 97 | } 98 | } 99 | } 100 | } 101 | 102 | augment /snmp:snmp/snmp:target/snmp:transport { 103 | if-feature sshtm; 104 | case ssh { 105 | reference 106 | "RFC 5592: Secure Shell Transport Model for the 107 | Simple Network Management Protocol (SNMP). 108 | SNMP-SSH-TM-MIB.snmpSSHDomain"; 109 | container ssh { 110 | leaf ip { 111 | type inet:host; 112 | mandatory true; 113 | reference 114 | "RFC 3413: Simple Network Management Protocol (SNMP). 115 | Applications. 116 | SNMP-TARGET-MIB.snmpTargetAddrTAddress 117 | RFC 5592: Secure Shell Transport Model for the 118 | Simple Network Management Protocol (SNMP). 119 | SNMP-SSH-TM-MIB.SnmpSSHAddress"; 120 | } 121 | leaf port { 122 | type inet:port-number; 123 | default 5161; 124 | reference 125 | "RFC 3413: Simple Network Management Protocol (SNMP). 126 | Applications. 127 | SNMP-TARGET-MIB.snmpTargetAddrTAddress 128 | RFC 5592: Secure Shell Transport Model for the 129 | Simple Network Management Protocol (SNMP). 130 | SNMP-SSH-TM-MIB.SnmpSSHAddress"; 131 | } 132 | leaf username { 133 | type string; 134 | reference 135 | "RFC 3413: Simple Network Management Protocol (SNMP). 136 | Applications. 137 | SNMP-TARGET-MIB.snmpTargetAddrTAddress 138 | RFC 5592: Secure Shell Transport Model for the 139 | Simple Network Management Protocol (SNMP). 140 | SNMP-SSH-TM-MIB.SnmpSSHAddress"; 141 | } 142 | } 143 | } 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /ietf-yangs/ietf-snmp-target.yang: -------------------------------------------------------------------------------- 1 | submodule ietf-snmp-target { 2 | 3 | belongs-to ietf-snmp { 4 | prefix snmp; 5 | } 6 | 7 | import ietf-inet-types { 8 | prefix inet; 9 | } 10 | 11 | include ietf-snmp-common; 12 | 13 | organization 14 | "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; 15 | 16 | contact 17 | "WG Web: 18 | WG List: 19 | 20 | WG Chair: Thomas Nadeau 21 | 22 | 23 | WG Chair: Juergen Schoenwaelder 24 | 25 | 26 | Editor: Martin Bjorklund 27 | 28 | 29 | Editor: Juergen Schoenwaelder 30 | "; 31 | 32 | description 33 | "This submodule contains a collection of YANG definitions 34 | for configuring SNMP targets. 35 | 36 | Copyright (c) 2014 IETF Trust and the persons identified as 37 | authors of the code. All rights reserved. 38 | 39 | Redistribution and use in source and binary forms, with or 40 | without modification, is permitted pursuant to, and subject 41 | to the license terms contained in, the Simplified BSD License 42 | set forth in Section 4.c of the IETF Trust's Legal Provisions 43 | Relating to IETF Documents 44 | (http://trustee.ietf.org/license-info). 45 | This version of this YANG module is part of RFC 7407; see 46 | the RFC itself for full legal notices."; 47 | 48 | reference 49 | "RFC 3413: Simple Network Management Protocol (SNMP) 50 | Applications"; 51 | 52 | revision 2014-12-10 { 53 | description 54 | "Initial revision."; 55 | reference 56 | "RFC 7407: A YANG Data Model for SNMP Configuration"; 57 | } 58 | 59 | augment /snmp:snmp { 60 | 61 | list target { 62 | key name; 63 | description 64 | "List of targets."; 65 | reference 66 | "RFC 3413: Simple Network Management Protocol (SNMP) 67 | Applications. 68 | SNMP-TARGET-MIB.snmpTargetAddrTable"; 69 | 70 | leaf name { 71 | type snmp:identifier; 72 | description 73 | "Identifies the target."; 74 | reference 75 | "RFC 3413: Simple Network Management Protocol (SNMP) 76 | Applications. 77 | SNMP-TARGET-MIB.snmpTargetAddrName"; 78 | } 79 | choice transport { 80 | mandatory true; 81 | description 82 | "Transport address of the target. 83 | 84 | The snmpTargetAddrTDomain and snmpTargetAddrTAddress 85 | objects are mapped to transport-specific YANG nodes. Each 86 | transport is configured as a separate case in this 87 | choice. Submodules providing configuration for additional 88 | transports are expected to augment this choice."; 89 | 90 | 91 | 92 | 93 | reference 94 | "RFC 3413: Simple Network Management Protocol (SNMP) 95 | Applications. 96 | SNMP-TARGET-MIB.snmpTargetAddrTDomain 97 | SNMP-TARGET-MIB.snmpTargetAddrTAddress"; 98 | case udp { 99 | reference 100 | "RFC 3417: Transport Mappings for the Simple Network 101 | Management Protocol (SNMP). 102 | SNMPv2-TM.snmpUDPDomain 103 | RFC 3419: Textual Conventions for Transport Addresses. 104 | TRANSPORT-ADDRESS-MIB.transportDomainUdpIpv4 105 | TRANSPORT-ADDRESS-MIB.transportDomainUdpIpv4z 106 | TRANSPORT-ADDRESS-MIB.transportDomainUdpIpv6 107 | TRANSPORT-ADDRESS-MIB.transportDomainUdpIpv6z"; 108 | container udp { 109 | leaf ip { 110 | type inet:ip-address; 111 | mandatory true; 112 | reference 113 | "RFC 3413: Simple Network Management Protocol (SNMP). 114 | SNMP-TARGET-MIB.snmpTargetAddrTAddress"; 115 | } 116 | leaf port { 117 | type inet:port-number; 118 | default 162; 119 | description 120 | "UDP port number."; 121 | reference 122 | "RFC 3413: Simple Network Management Protocol (SNMP). 123 | SNMP-TARGET-MIB.snmpTargetAddrTAddress"; 124 | } 125 | leaf prefix-length { 126 | type uint8; 127 | description 128 | "The value of this leaf must match the value of 129 | ../snmp:ip. If ../snmp:ip contains an IPv4 address, 130 | this leaf must be less than or equal to 32. If it 131 | contains an IPv6 address, it must be less than or 132 | equal to 128. 133 | 134 | Note that the prefix-length is currently only used 135 | by the Community-based Security Model to filter 136 | incoming messages. Furthermore, the prefix-length 137 | filtering does not cover all possible filters 138 | supported by the corresponding MIB object."; 139 | 140 | 141 | reference 142 | "RFC 3584: Coexistence between Version 1, Version 2, 143 | and Version 3 of the Internet-standard 144 | Network Management Framework. 145 | SNMP-COMMUNITY-MIB.snmpTargetAddrTMask"; 146 | } 147 | } 148 | } 149 | } 150 | leaf-list tag { 151 | type snmp:tag-value; 152 | description 153 | "List of tag values used to select target addresses."; 154 | reference 155 | "RFC 3413: Simple Network Management Protocol (SNMP). 156 | Applications. 157 | SNMP-TARGET-MIB.snmpTargetAddrTagList"; 158 | } 159 | leaf timeout { 160 | type uint32; 161 | units "0.01 seconds"; 162 | default 1500; 163 | description 164 | "Needed only if this target can receive 165 | InformRequest-PDUs."; 166 | reference 167 | "RFC 3413: Simple Network Management Protocol (SNMP). 168 | Applications. 169 | SNMP-TARGET-MIB.snmpTargetAddrTimeout"; 170 | } 171 | leaf retries { 172 | type uint8; 173 | default 3; 174 | description 175 | "Needed only if this target can receive 176 | InformRequest-PDUs."; 177 | reference 178 | "RFC 3413: Simple Network Management Protocol (SNMP). 179 | Applications. 180 | SNMP-TARGET-MIB.snmpTargetAddrRetryCount"; 181 | } 182 | leaf target-params { 183 | type snmp:identifier; 184 | mandatory true; 185 | reference 186 | "RFC 3413: Simple Network Management Protocol (SNMP). 187 | Applications. 188 | SNMP-TARGET-MIB.snmpTargetAddrParams"; 189 | } 190 | } 191 | 192 | list target-params { 193 | key name; 194 | description 195 | "List of target parameters."; 196 | reference 197 | "RFC 3413: Simple Network Management Protocol (SNMP). 198 | Applications. 199 | SNMP-TARGET-MIB.snmpTargetParamsTable"; 200 | 201 | leaf name { 202 | type snmp:identifier; 203 | } 204 | choice params { 205 | description 206 | "This choice is augmented with case nodes containing 207 | configuration parameters specific to the security model."; 208 | } 209 | } 210 | } 211 | } 212 | -------------------------------------------------------------------------------- /ietf-yangs/ietf-snmp-tls.yang: -------------------------------------------------------------------------------- 1 | submodule ietf-snmp-tls { 2 | 3 | belongs-to ietf-snmp { 4 | prefix snmp; 5 | } 6 | 7 | import ietf-inet-types { 8 | prefix inet; 9 | } 10 | import ietf-x509-cert-to-name { 11 | prefix x509c2n; 12 | } 13 | 14 | include ietf-snmp-common; 15 | include ietf-snmp-engine; 16 | include ietf-snmp-target; 17 | 18 | organization 19 | "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; 20 | 21 | contact 22 | "WG Web: 23 | WG List: 24 | 25 | WG Chair: Thomas Nadeau 26 | 27 | 28 | WG Chair: Juergen Schoenwaelder 29 | 30 | 31 | Editor: Martin Bjorklund 32 | 33 | 34 | Editor: Juergen Schoenwaelder 35 | "; 36 | 37 | 38 | 39 | description 40 | "This submodule contains a collection of YANG definitions for 41 | configuring the Transport Layer Security Transport Model (TLSTM) 42 | of SNMP. 43 | 44 | Copyright (c) 2014 IETF Trust and the persons identified as 45 | authors of the code. All rights reserved. 46 | 47 | Redistribution and use in source and binary forms, with or 48 | without modification, is permitted pursuant to, and subject 49 | to the license terms contained in, the Simplified BSD License 50 | set forth in Section 4.c of the IETF Trust's Legal Provisions 51 | Relating to IETF Documents 52 | (http://trustee.ietf.org/license-info). 53 | 54 | This version of this YANG module is part of RFC 7407; see 55 | the RFC itself for full legal notices."; 56 | 57 | reference 58 | "RFC 6353: Transport Layer Security (TLS) Transport Model for 59 | the Simple Network Management Protocol (SNMP)"; 60 | 61 | revision 2014-12-10 { 62 | description 63 | "Initial revision."; 64 | reference 65 | "RFC 7407: A YANG Data Model for SNMP Configuration"; 66 | } 67 | 68 | feature tlstm { 69 | description 70 | "A server implements this feature if it supports the 71 | Transport Layer Security Transport Model for SNMP."; 72 | reference 73 | "RFC 6353: Transport Layer Security (TLS) Transport Model for 74 | the Simple Network Management Protocol (SNMP)"; 75 | } 76 | 77 | augment /snmp:snmp/snmp:engine/snmp:listen/snmp:transport { 78 | if-feature tlstm; 79 | case tls { 80 | container tls { 81 | description 82 | "A list of IPv4 and IPv6 addresses and ports to which the 83 | engine listens for SNMP messages over TLS."; 84 | 85 | 86 | 87 | leaf ip { 88 | type inet:ip-address; 89 | mandatory true; 90 | description 91 | "The IPv4 or IPv6 address on which the engine listens 92 | for SNMP messages over TLS."; 93 | } 94 | leaf port { 95 | type inet:port-number; 96 | description 97 | "The TCP port on which the engine listens for SNMP 98 | messages over TLS. 99 | 100 | If the port is not configured, an engine that 101 | acts as a Command Responder uses port 10161, and 102 | an engine that acts as a Notification Receiver 103 | uses port 10162."; 104 | } 105 | } 106 | } 107 | case dtls { 108 | container dtls { 109 | description 110 | "A list of IPv4 and IPv6 addresses and ports to which the 111 | engine listens for SNMP messages over DTLS."; 112 | 113 | leaf ip { 114 | type inet:ip-address; 115 | mandatory true; 116 | description 117 | "The IPv4 or IPv6 address on which the engine listens 118 | for SNMP messages over DTLS."; 119 | } 120 | leaf port { 121 | type inet:port-number; 122 | description 123 | "The UDP port on which the engine listens for SNMP 124 | messages over DTLS. 125 | 126 | If the port is not configured, an engine that 127 | acts as a Command Responder uses port 10161, and 128 | an engine that acts as a Notification Receiver 129 | uses port 10162."; 130 | } 131 | } 132 | } 133 | } 134 | 135 | augment /snmp:snmp { 136 | if-feature tlstm; 137 | container tlstm { 138 | uses x509c2n:cert-to-name { 139 | description 140 | "Defines how certificates are mapped to names. The 141 | resulting name is used as a security name."; 142 | refine cert-to-name/map-type { 143 | description 144 | "Mappings that use the snmpTlstmCertToTSNData column 145 | need to augment the cert-to-name list with 146 | additional configuration objects corresponding 147 | to the snmpTlstmCertToTSNData value. Such objects 148 | should use the 'when' statement to make them 149 | conditional based on the map-type."; 150 | } 151 | } 152 | } 153 | } 154 | 155 | grouping tls-transport { 156 | leaf ip { 157 | type inet:host; 158 | mandatory true; 159 | reference 160 | "RFC 3413: Simple Network Management Protocol (SNMP). 161 | Applications. 162 | SNMP-TARGET-MIB.snmpTargetAddrTAddress 163 | RFC 6353: Transport Layer Security (TLS) Transport Model 164 | for the Simple Network Management Protocol (SNMP). 165 | SNMP-TLS-TM-MIB.SnmpTLSAddress"; 166 | } 167 | leaf port { 168 | type inet:port-number; 169 | default 10161; 170 | reference 171 | "RFC 3413: Simple Network Management Protocol (SNMP). 172 | Applications. 173 | SNMP-TARGET-MIB.snmpTargetAddrTAddress 174 | RFC 6353: Transport Layer Security (TLS) Transport Model 175 | for the Simple Network Management Protocol (SNMP). 176 | SNMP-TLS-TM-MIB.SnmpTLSAddress"; 177 | } 178 | leaf client-fingerprint { 179 | type x509c2n:tls-fingerprint; 180 | reference 181 | "RFC 6353: Transport Layer Security (TLS) Transport Model 182 | for the Simple Network Management Protocol (SNMP). 183 | SNMP-TLS-TM-MIB.snmpTlstmParamsClientFingerprint"; 184 | } 185 | leaf server-fingerprint { 186 | type x509c2n:tls-fingerprint; 187 | reference 188 | "RFC 6353: Transport Layer Security (TLS) Transport Model 189 | for the Simple Network Management Protocol (SNMP). 190 | SNMP-TLS-TM-MIB.snmpTlstmAddrServerFingerprint"; 191 | } 192 | leaf server-identity { 193 | type snmp:admin-string; 194 | reference 195 | "RFC 6353: Transport Layer Security (TLS) Transport Model 196 | for the Simple Network Management Protocol (SNMP). 197 | SNMP-TLS-TM-MIB.snmpTlstmAddrServerIdentity"; 198 | } 199 | } 200 | 201 | augment /snmp:snmp/snmp:target/snmp:transport { 202 | if-feature tlstm; 203 | case tls { 204 | reference 205 | "RFC 6353: Transport Layer Security (TLS) Transport Model 206 | for the Simple Network Management Protocol (SNMP). 207 | SNMP-TLS-TM-MIB.snmpTLSTCPDomain"; 208 | container tls { 209 | uses tls-transport; 210 | } 211 | } 212 | } 213 | 214 | augment /snmp:snmp/snmp:target/snmp:transport { 215 | if-feature tlstm; 216 | case dtls { 217 | reference 218 | "RFC 6353: Transport Layer Security (TLS) Transport Model 219 | for the Simple Network Management Protocol (SNMP). 220 | SNMP-TLS-TM-MIB.snmpDTLSUDPDomain"; 221 | container dtls { 222 | uses tls-transport; 223 | } 224 | } 225 | } 226 | } 227 | -------------------------------------------------------------------------------- /ietf-yangs/ietf-snmp-tsm.yang: -------------------------------------------------------------------------------- 1 | submodule ietf-snmp-tsm { 2 | 3 | belongs-to ietf-snmp { 4 | prefix snmp; 5 | } 6 | 7 | include ietf-snmp-common; 8 | include ietf-snmp-target; 9 | include ietf-snmp-proxy; 10 | 11 | organization 12 | "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; 13 | 14 | contact 15 | "WG Web: 16 | WG List: 17 | 18 | 19 | WG Chair: Thomas Nadeau 20 | 21 | 22 | WG Chair: Juergen Schoenwaelder 23 | 24 | 25 | Editor: Martin Bjorklund 26 | 27 | 28 | Editor: Juergen Schoenwaelder 29 | "; 30 | 31 | description 32 | "This submodule contains a collection of YANG definitions for 33 | configuring the Transport Security Model (TSM) of SNMP. 34 | 35 | Copyright (c) 2014 IETF Trust and the persons identified as 36 | authors of the code. All rights reserved. 37 | 38 | Redistribution and use in source and binary forms, with or 39 | without modification, is permitted pursuant to, and subject 40 | to the license terms contained in, the Simplified BSD License 41 | set forth in Section 4.c of the IETF Trust's Legal Provisions 42 | Relating to IETF Documents 43 | (http://trustee.ietf.org/license-info). 44 | 45 | This version of this YANG module is part of RFC 7407; see 46 | the RFC itself for full legal notices."; 47 | 48 | reference 49 | "RFC 5591: Transport Security Model for the 50 | Simple Network Management Protocol (SNMP)"; 51 | 52 | revision 2014-12-10 { 53 | description 54 | "Initial revision."; 55 | reference 56 | "RFC 7407: A YANG Data Model for SNMP Configuration"; 57 | } 58 | 59 | feature tsm { 60 | description 61 | "A server implements this feature if it supports the 62 | Transport Security Model for SNMP."; 63 | reference 64 | "RFC 5591: Transport Security Model for the 65 | Simple Network Management Protocol (SNMP)"; 66 | } 67 | augment /snmp:snmp { 68 | if-feature tsm; 69 | container tsm { 70 | description 71 | "Configuration of the Transport Security Model."; 72 | 73 | leaf use-prefix { 74 | type boolean; 75 | default false; 76 | reference 77 | "RFC 5591: Transport Security Model for the Simple 78 | Network Management Protocol (SNMP). 79 | SNMP-TSM-MIB.snmpTsmConfigurationUsePrefix"; 80 | } 81 | } 82 | } 83 | 84 | grouping tsm-target-params { 85 | container tsm { 86 | description 87 | "Transport-based security SNMPv3 parameters type. 88 | 89 | Represents snmpTargetParamsMPModel '3' and 90 | snmpTargetParamsSecurityModel '4'."; 91 | leaf security-name { 92 | type snmp:security-name; 93 | mandatory true; 94 | reference 95 | "RFC 3413: Simple Network Management Protocol (SNMP). 96 | Applications. 97 | SNMP-TARGET-MIB.snmpTargetParamsSecurityName"; 98 | } 99 | leaf security-level { 100 | type snmp:security-level; 101 | mandatory true; 102 | reference 103 | "RFC 3413: Simple Network Management Protocol (SNMP). 104 | Applications. 105 | SNMP-TARGET-MIB.snmpTargetParamsSecurityLevel"; 106 | } 107 | } 108 | } 109 | 110 | augment /snmp:snmp/snmp:target-params/snmp:params { 111 | if-feature tsm; 112 | case tsm { 113 | uses tsm-target-params; 114 | } 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /ietf-yangs/ietf-snmp-usm.yang: -------------------------------------------------------------------------------- 1 | submodule ietf-snmp-usm { 2 | 3 | belongs-to ietf-snmp { 4 | prefix snmp; 5 | } 6 | 7 | import ietf-yang-types { 8 | prefix yang; 9 | } 10 | import ietf-netconf-acm { 11 | prefix nacm; 12 | } 13 | 14 | include ietf-snmp-common; 15 | include ietf-snmp-target; 16 | include ietf-snmp-proxy; 17 | 18 | organization 19 | "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; 20 | 21 | contact 22 | "WG Web: 23 | WG List: 24 | 25 | WG Chair: Thomas Nadeau 26 | 27 | 28 | WG Chair: Juergen Schoenwaelder 29 | 30 | 31 | Editor: Martin Bjorklund 32 | 33 | 34 | Editor: Juergen Schoenwaelder 35 | "; 36 | 37 | description 38 | "This submodule contains a collection of YANG definitions for 39 | configuring the User-based Security Model (USM) of SNMP. 40 | 41 | Copyright (c) 2014 IETF Trust and the persons identified as 42 | authors of the code. All rights reserved. 43 | 44 | Redistribution and use in source and binary forms, with or 45 | without modification, is permitted pursuant to, and subject 46 | to the license terms contained in, the Simplified BSD License 47 | set forth in Section 4.c of the IETF Trust's Legal Provisions 48 | Relating to IETF Documents 49 | (http://trustee.ietf.org/license-info). 50 | 51 | This version of this YANG module is part of RFC 7407; see 52 | the RFC itself for full legal notices."; 53 | 54 | 55 | reference 56 | "RFC 3414: User-based Security Model (USM) for version 3 of the 57 | Simple Network Management Protocol (SNMPv3)"; 58 | 59 | revision 2014-12-10 { 60 | description 61 | "Initial revision."; 62 | reference 63 | "RFC 7407: A YANG Data Model for SNMP Configuration"; 64 | } 65 | 66 | grouping key { 67 | leaf key { 68 | type yang:hex-string; 69 | mandatory true; 70 | nacm:default-deny-all; 71 | description 72 | "Localized key specified as a list of colon-specified 73 | hexadecimal octets."; 74 | } 75 | } 76 | 77 | grouping user-list { 78 | list user { 79 | key "name"; 80 | 81 | reference 82 | "RFC 3414: User-based Security Model (USM) for version 3 83 | of the Simple Network Management Protocol (SNMPv3). 84 | SNMP-USER-BASED-SM-MIB.usmUserTable"; 85 | 86 | leaf name { 87 | type snmp:identifier; 88 | reference 89 | "RFC 3414: User-based Security Model (USM) for version 3 90 | of the Simple Network Management Protocol (SNMPv3). 91 | SNMP-USER-BASED-SM-MIB.usmUserName"; 92 | } 93 | container auth { 94 | presence "enables authentication"; 95 | description 96 | "Enables authentication of the user."; 97 | choice protocol { 98 | mandatory true; 99 | reference 100 | "RFC 3414: User-based Security Model (USM) for version 3 101 | of the Simple Network Management Protocol (SNMPv3). 102 | SNMP-USER-BASED-SM-MIB.usmUserAuthProtocol"; 103 | container md5 { 104 | uses key; 105 | reference 106 | "RFC 3414: User-based Security Model (USM) for 107 | version 3 of the Simple Network Management Protocol 108 | (SNMPv3). 109 | SNMP-USER-BASED-SM-MIB.usmHMACMD5AuthProtocol"; 110 | } 111 | container sha { 112 | uses key; 113 | reference 114 | "RFC 3414: User-based Security Model (USM) for 115 | version 3 of the Simple Network Management Protocol 116 | (SNMPv3). 117 | SNMP-USER-BASED-SM-MIB.usmHMACSHAAuthProtocol"; 118 | } 119 | } 120 | } 121 | container priv { 122 | must "../auth" { 123 | error-message 124 | "when privacy (confidentiality) is used, " 125 | + "authentication must also be used"; 126 | } 127 | presence "enables encryption"; 128 | description 129 | "Enables encryption of SNMP messages."; 130 | 131 | choice protocol { 132 | mandatory true; 133 | reference 134 | "RFC 3414: User-based Security Model (USM) for version 3 135 | of the Simple Network Management Protocol (SNMPv3). 136 | SNMP-USER-BASED-SM-MIB.usmUserPrivProtocol"; 137 | container des { 138 | uses key; 139 | reference 140 | "RFC 3414: User-based Security Model (USM) for 141 | version 3 of the Simple Network Management Protocol 142 | (SNMPv3). 143 | SNMP-USER-BASED-SM-MIB.usmDESPrivProtocol"; 144 | } 145 | container aes { 146 | uses key; 147 | 148 | 149 | 150 | 151 | reference 152 | "RFC 3826: The Advanced Encryption Standard (AES) 153 | Cipher Algorithm in the SNMP User-based Security 154 | Model. 155 | SNMP-USM-AES-MIB.usmAesCfb128Protocol"; 156 | } 157 | } 158 | } 159 | } 160 | } 161 | 162 | augment /snmp:snmp { 163 | 164 | container usm { 165 | description 166 | "Configuration of the User-based Security Model."; 167 | container local { 168 | uses user-list; 169 | } 170 | 171 | list remote { 172 | key "engine-id"; 173 | 174 | leaf engine-id { 175 | type snmp:engine-id; 176 | reference 177 | "RFC 3414: User-based Security Model (USM) for version 3 178 | of the Simple Network Management Protocol (SNMPv3). 179 | SNMP-USER-BASED-SM-MIB.usmUserEngineID"; 180 | } 181 | 182 | uses user-list; 183 | } 184 | } 185 | } 186 | 187 | grouping usm-target-params { 188 | container usm { 189 | description 190 | "User-based SNMPv3 parameters type. 191 | 192 | Represents snmpTargetParamsMPModel '3' and 193 | snmpTargetParamsSecurityModel '3'."; 194 | leaf user-name { 195 | type snmp:security-name; 196 | mandatory true; 197 | 198 | 199 | reference 200 | "RFC 3413: Simple Network Management Protocol (SNMP). 201 | Applications. 202 | SNMP-TARGET-MIB.snmpTargetParamsSecurityName"; 203 | } 204 | leaf security-level { 205 | type snmp:security-level; 206 | mandatory true; 207 | reference 208 | "RFC 3413: Simple Network Management Protocol (SNMP). 209 | Applications. 210 | SNMP-TARGET-MIB.snmpTargetParamsSecurityLevel"; 211 | } 212 | } 213 | } 214 | 215 | augment /snmp:snmp/snmp:target-params/snmp:params { 216 | case usm { 217 | uses usm-target-params; 218 | } 219 | } 220 | 221 | } 222 | -------------------------------------------------------------------------------- /ietf-yangs/ietf-snmp-vacm.yang: -------------------------------------------------------------------------------- 1 | submodule ietf-snmp-vacm { 2 | 3 | belongs-to ietf-snmp { 4 | prefix snmp; 5 | } 6 | 7 | include ietf-snmp-common; 8 | 9 | organization 10 | "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; 11 | 12 | contact 13 | "WG Web: 14 | WG List: 15 | 16 | WG Chair: Thomas Nadeau 17 | 18 | 19 | WG Chair: Juergen Schoenwaelder 20 | 21 | 22 | Editor: Martin Bjorklund 23 | 24 | 25 | Editor: Juergen Schoenwaelder 26 | "; 27 | 28 | description 29 | "This submodule contains a collection of YANG definitions 30 | for configuring the View-based Access Control Model (VACM) 31 | of SNMP. 32 | 33 | Copyright (c) 2014 IETF Trust and the persons identified as 34 | authors of the code. All rights reserved. 35 | 36 | Redistribution and use in source and binary forms, with or 37 | without modification, is permitted pursuant to, and subject 38 | to the license terms contained in, the Simplified BSD License 39 | set forth in Section 4.c of the IETF Trust's Legal Provisions 40 | Relating to IETF Documents 41 | (http://trustee.ietf.org/license-info). 42 | 43 | This version of this YANG module is part of RFC 7407; see 44 | the RFC itself for full legal notices."; 45 | 46 | reference 47 | "RFC 3415: View-based Access Control Model (VACM) for the 48 | Simple Network Management Protocol (SNMP)"; 49 | 50 | revision 2014-12-10 { 51 | description 52 | "Initial revision."; 53 | reference 54 | "RFC 7407: A YANG Data Model for SNMP Configuration"; 55 | } 56 | 57 | typedef view-name { 58 | type snmp:identifier; 59 | description 60 | "The view-name type represents an SNMP VACM view name."; 61 | } 62 | 63 | typedef group-name { 64 | type snmp:identifier; 65 | description 66 | "The group-name type represents an SNMP VACM group name."; 67 | } 68 | 69 | augment /snmp:snmp { 70 | 71 | container vacm { 72 | description 73 | "Configuration of the View-based Access Control Model."; 74 | 75 | list group { 76 | key name; 77 | description 78 | "VACM groups. 79 | 80 | This data model has a different structure than the MIB. 81 | Groups are explicitly defined in this list, and group 82 | members are defined in the 'member' list (mapped to 83 | vacmSecurityToGroupTable), and access for the group is 84 | defined in the 'access' list (mapped to 85 | vacmAccessTable)."; 86 | reference 87 | "RFC 3415: View-based Access Control Model (VACM) for the 88 | Simple Network Management Protocol (SNMP). 89 | SNMP-VIEW-BASED-ACM-MIB.vacmSecurityToGroupTable 90 | SNMP-VIEW-BASED-ACM-MIB.vacmAccessTable"; 91 | 92 | leaf name { 93 | type group-name; 94 | description 95 | "The name of this VACM group."; 96 | reference 97 | "RFC 3415: View-based Access Control Model (VACM) for the 98 | Simple Network Management Protocol (SNMP). 99 | SNMP-VIEW-BASED-ACM-MIB.vacmGroupName"; 100 | } 101 | 102 | list member { 103 | key "security-name"; 104 | description 105 | "A member of this VACM group. 106 | 107 | A specific combination of security-name and 108 | security-model MUST NOT be present in more than 109 | one group."; 110 | reference 111 | "RFC 3415: View-based Access Control Model (VACM) for the 112 | Simple Network Management Protocol (SNMP). 113 | SNMP-VIEW-BASED-ACM-MIB.vacmSecurityToGroupTable"; 114 | 115 | leaf security-name { 116 | type snmp:security-name; 117 | description 118 | "The securityName of a group member."; 119 | reference 120 | "RFC 3415: View-based Access Control Model (VACM) for 121 | the Simple Network Management Protocol (SNMP). 122 | SNMP-VIEW-BASED-ACM-MIB.vacmSecurityName"; 123 | } 124 | 125 | leaf-list security-model { 126 | type snmp:security-model; 127 | min-elements 1; 128 | description 129 | "The security models under which this security-name 130 | is a member of this group."; 131 | reference 132 | "RFC 3415: View-based Access Control Model (VACM) for 133 | the Simple Network Management Protocol (SNMP). 134 | SNMP-VIEW-BASED-ACM-MIB.vacmSecurityModel"; 135 | } 136 | } 137 | 138 | list access { 139 | key "context security-model security-level"; 140 | description 141 | "Definition of access right for groups."; 142 | reference 143 | "RFC 3415: View-based Access Control Model (VACM) for 144 | the Simple Network Management Protocol (SNMP). 145 | SNMP-VIEW-BASED-ACM-MIB.vacmAccessTable"; 146 | 147 | leaf context { 148 | type snmp:context-name; 149 | description 150 | "The context (prefix) under which the access rights 151 | apply."; 152 | reference 153 | "RFC 3415: View-based Access Control Model (VACM) for 154 | the Simple Network Management Protocol (SNMP). 155 | SNMP-VIEW-BASED-ACM-MIB.vacmAccessContextPrefix"; 156 | } 157 | 158 | leaf context-match { 159 | type enumeration { 160 | enum exact { value 1; } 161 | enum prefix { value 2; } 162 | } 163 | default exact; 164 | reference 165 | "RFC 3415: View-based Access Control Model (VACM) for 166 | the Simple Network Management Protocol (SNMP). 167 | SNMP-VIEW-BASED-ACM-MIB.vacmAccessContextMatch"; 168 | } 169 | 170 | leaf security-model { 171 | type snmp:security-model-or-any; 172 | description 173 | "The security model under which the access rights 174 | apply."; 175 | reference 176 | "RFC 3415: View-based Access Control Model (VACM) for 177 | the Simple Network Management Protocol (SNMP). 178 | SNMP-VIEW-BASED-ACM-MIB.vacmAccessSecurityModel"; 179 | } 180 | 181 | leaf security-level { 182 | type snmp:security-level; 183 | description 184 | "The minimum security level under which the access 185 | rights apply."; 186 | reference 187 | "RFC 3415: View-based Access Control Model (VACM) for 188 | the Simple Network Management Protocol (SNMP). 189 | SNMP-VIEW-BASED-ACM-MIB.vacmAccessSecurityLevel"; 190 | } 191 | 192 | leaf read-view { 193 | type view-name; 194 | description 195 | "The name of the MIB view of the SNMP context 196 | authorizing read access. If this leaf does not 197 | exist in a configuration, it maps to a zero-length 198 | vacmAccessReadViewName. 199 | 200 | Implementations MAY restrict the values of this 201 | leaf to be one of the available values of 202 | /snmp/vacm/view/name in a valid configuration."; 203 | reference 204 | "RFC 3415: View-based Access Control Model (VACM) for 205 | the Simple Network Management Protocol (SNMP). 206 | SNMP-VIEW-BASED-ACM-MIB.vacmAccessReadViewName"; 207 | } 208 | 209 | leaf write-view { 210 | type view-name; 211 | description 212 | "The name of the MIB view of the SNMP context 213 | authorizing write access. If this leaf does not 214 | exist in a configuration, it maps to a zero-length 215 | vacmAccessWriteViewName. 216 | 217 | Implementations MAY restrict the values of this 218 | leaf to be one of the available values of 219 | /snmp/vacm/view/name in a valid configuration."; 220 | reference 221 | "RFC 3415: View-based Access Control Model (VACM) for 222 | the Simple Network Management Protocol (SNMP). 223 | SNMP-VIEW-BASED-ACM-MIB.vacmAccessWriteViewName"; 224 | } 225 | 226 | leaf notify-view { 227 | type view-name; 228 | description 229 | "The name of the MIB view of the SNMP context 230 | authorizing notify access. If this leaf does not 231 | exist in a configuration, it maps to a zero-length 232 | vacmAccessNotifyViewName. 233 | 234 | Implementations MAY restrict the values of this 235 | leaf to be one of the available values of 236 | /snmp/vacm/view/name in a valid configuration."; 237 | reference 238 | "RFC 3415: View-based Access Control Model (VACM) for 239 | the Simple Network Management Protocol (SNMP). 240 | SNMP-VIEW-BASED-ACM-MIB.vacmAccessNotifyViewName"; 241 | } 242 | } 243 | } 244 | 245 | list view { 246 | key name; 247 | description 248 | "Definition of MIB views."; 249 | reference 250 | "RFC 3415: View-based Access Control Model (VACM) for 251 | the Simple Network Management Protocol (SNMP). 252 | SNMP-VIEW-BASED-ACM-MIB.vacmViewTreeFamilyTable"; 253 | 254 | leaf name { 255 | type view-name; 256 | description 257 | "The name of this VACM MIB view."; 258 | 259 | reference 260 | "RFC 3415: View-based Access Control Model (VACM) for 261 | the Simple Network Management Protocol (SNMP). 262 | SNMP-VIEW-BASED-ACM-MIB.vacmViewTreeFamilyName"; 263 | } 264 | 265 | leaf-list include { 266 | type snmp:wildcard-object-identifier; 267 | description 268 | "A family of subtrees included in this MIB view."; 269 | reference 270 | "RFC 3415: View-based Access Control Model (VACM) for 271 | the Simple Network Management Protocol (SNMP). 272 | SNMP-VIEW-BASED-ACM-MIB.vacmViewTreeFamilySubtree 273 | SNMP-VIEW-BASED-ACM-MIB.vacmViewTreeFamilyMask 274 | SNMP-VIEW-BASED-ACM-MIB.vacmViewTreeFamilyType"; 275 | } 276 | 277 | leaf-list exclude { 278 | type snmp:wildcard-object-identifier; 279 | description 280 | "A family of subtrees excluded from this MIB view."; 281 | reference 282 | "RFC 3415: View-based Access Control Model (VACM) for 283 | the Simple Network Management Protocol (SNMP). 284 | SNMP-VIEW-BASED-ACM-MIB.vacmViewTreeFamilySubtree 285 | SNMP-VIEW-BASED-ACM-MIB.vacmViewTreeFamilyMask 286 | SNMP-VIEW-BASED-ACM-MIB.vacmViewTreeFamilyType"; 287 | } 288 | } 289 | } 290 | } 291 | } 292 | -------------------------------------------------------------------------------- /ietf-yangs/ietf-snmp.yang: -------------------------------------------------------------------------------- 1 | module ietf-snmp { 2 | 3 | namespace "urn:ietf:params:xml:ns:yang:ietf-snmp"; 4 | prefix snmp; 5 | 6 | include ietf-snmp-common { 7 | revision-date 2014-12-10; 8 | } 9 | include ietf-snmp-engine { 10 | revision-date 2014-12-10; 11 | } 12 | include ietf-snmp-target { 13 | revision-date 2014-12-10; 14 | } 15 | include ietf-snmp-notification { 16 | revision-date 2014-12-10; 17 | } 18 | include ietf-snmp-proxy { 19 | revision-date 2014-12-10; 20 | } 21 | include ietf-snmp-community { 22 | revision-date 2014-12-10; 23 | } 24 | include ietf-snmp-usm { 25 | revision-date 2014-12-10; 26 | } 27 | include ietf-snmp-tsm { 28 | revision-date 2014-12-10; 29 | } 30 | include ietf-snmp-vacm { 31 | revision-date 2014-12-10; 32 | } 33 | include ietf-snmp-tls { 34 | revision-date 2014-12-10; 35 | } 36 | include ietf-snmp-ssh { 37 | revision-date 2014-12-10; 38 | } 39 | 40 | organization 41 | "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; 42 | 43 | contact 44 | "WG Web: 45 | WG List: 46 | 47 | WG Chair: Thomas Nadeau 48 | 49 | 50 | WG Chair: Juergen Schoenwaelder 51 | 52 | 53 | Editor: Martin Bjorklund 54 | 55 | 56 | Editor: Juergen Schoenwaelder 57 | "; 58 | description 59 | "This module contains a collection of YANG definitions for 60 | configuring SNMP engines. 61 | 62 | Copyright (c) 2014 IETF Trust and the persons identified as 63 | authors of the code. All rights reserved. 64 | 65 | Redistribution and use in source and binary forms, with or 66 | without modification, is permitted pursuant to, and subject 67 | to the license terms contained in, the Simplified BSD License 68 | set forth in Section 4.c of the IETF Trust's Legal Provisions 69 | Relating to IETF Documents 70 | (http://trustee.ietf.org/license-info). 71 | 72 | This version of this YANG module is part of RFC 7407; see 73 | the RFC itself for full legal notices."; 74 | 75 | revision 2014-12-10 { 76 | description 77 | "Initial revision."; 78 | reference 79 | "RFC 7407: A YANG Data Model for SNMP Configuration"; 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /ietf-yangs/ietf-x509-cert-to-name.yang: -------------------------------------------------------------------------------- 1 | module ietf-x509-cert-to-name { 2 | 3 | namespace "urn:ietf:params:xml:ns:yang:ietf-x509-cert-to-name"; 4 | prefix x509c2n; 5 | 6 | import ietf-yang-types { 7 | prefix yang; 8 | } 9 | 10 | organization 11 | "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; 12 | 13 | contact 14 | "WG Web: 15 | WG List: 16 | 17 | WG Chair: Thomas Nadeau 18 | 19 | 20 | WG Chair: Juergen Schoenwaelder 21 | 22 | 23 | Editor: Martin Bjorklund 24 | 25 | 26 | Editor: Juergen Schoenwaelder 27 | "; 28 | 29 | description 30 | "This module contains a collection of YANG definitions for 31 | extracting a name from an X.509 certificate. 32 | The algorithm used to extract a name from an X.509 certificate 33 | was first defined in RFC 6353. 34 | 35 | Copyright (c) 2014 IETF Trust and the persons identified as 36 | authors of the code. All rights reserved. 37 | 38 | Redistribution and use in source and binary forms, with or 39 | without modification, is permitted pursuant to, and subject 40 | to the license terms contained in, the Simplified BSD License 41 | set forth in Section 4.c of the IETF Trust's Legal Provisions 42 | Relating to IETF Documents 43 | (http://trustee.ietf.org/license-info). 44 | 45 | This version of this YANG module is part of RFC 7407; see 46 | the RFC itself for full legal notices."; 47 | 48 | reference 49 | "RFC 6353: Transport Layer Security (TLS) Transport Model for 50 | the Simple Network Management Protocol (SNMP)"; 51 | 52 | revision 2014-12-10 { 53 | description 54 | "Initial revision."; 55 | reference 56 | "RFC 7407: A YANG Data Model for SNMP Configuration"; 57 | 58 | } 59 | 60 | typedef tls-fingerprint { 61 | type yang:hex-string { 62 | pattern '([0-9a-fA-F]){2}(:([0-9a-fA-F]){2}){0,254}'; 63 | } 64 | description 65 | "A fingerprint value that can be used to uniquely reference 66 | other data of potentially arbitrary length. 67 | 68 | A tls-fingerprint value is composed of a 1-octet hashing 69 | algorithm identifier followed by the fingerprint value. The 70 | first octet value identifying the hashing algorithm is taken 71 | from the IANA 'TLS HashAlgorithm Registry' (RFC 5246). The 72 | remaining octets are filled using the results of the hashing 73 | algorithm."; 74 | reference 75 | "RFC 6353: Transport Layer Security (TLS) Transport Model 76 | for the Simple Network Management Protocol (SNMP). 77 | SNMP-TLS-TM-MIB.SnmpTLSFingerprint"; 78 | } 79 | 80 | /* Identities */ 81 | 82 | identity cert-to-name { 83 | description 84 | "Base identity for algorithms to derive a name from a 85 | certificate."; 86 | } 87 | 88 | identity specified { 89 | base cert-to-name; 90 | description 91 | "Directly specifies the name to be used for the certificate. 92 | The value of the leaf 'name' in the cert-to-name list is 93 | used."; 94 | reference 95 | "RFC 6353: Transport Layer Security (TLS) Transport Model 96 | for the Simple Network Management Protocol (SNMP). 97 | SNMP-TLS-TM-MIB.snmpTlstmCertSpecified"; 98 | } 99 | 100 | identity san-rfc822-name { 101 | base cert-to-name; 102 | description 103 | "Maps a subjectAltName's rfc822Name to a name. The local part 104 | of the rfc822Name is passed unaltered, but the host-part of 105 | the name must be passed in lowercase. For example, the 106 | rfc822Name field FooBar@Example.COM is mapped to name 107 | FooBar@example.com."; 108 | reference 109 | "RFC 6353: Transport Layer Security (TLS) Transport Model 110 | for the Simple Network Management Protocol (SNMP). 111 | SNMP-TLS-TM-MIB.snmpTlstmCertSANRFC822Name"; 112 | } 113 | 114 | identity san-dns-name { 115 | base cert-to-name; 116 | description 117 | "Maps a subjectAltName's dNSName to a name after first 118 | converting it to all lowercase (RFC 5280 does not specify 119 | converting to lowercase, so this involves an extra step). 120 | This mapping results in a 1:1 correspondence between 121 | subjectAltName dNSName values and the name values."; 122 | reference 123 | "RFC 6353: Transport Layer Security (TLS) Transport Model 124 | for the Simple Network Management Protocol (SNMP). 125 | SNMP-TLS-TM-MIB.snmpTlstmCertSANDNSName"; 126 | } 127 | 128 | identity san-ip-address { 129 | base cert-to-name; 130 | description 131 | "Maps a subjectAltName's iPAddress to a name by 132 | transforming the binary-encoded address as follows: 133 | 134 | 1) for IPv4, the value is converted into a 135 | decimal-dotted quad address (e.g., '192.0.2.1'). 136 | 137 | 2) for IPv6 addresses, the value is converted into a 138 | 32-character, all-lowercase hexadecimal string 139 | without any colon separators. 140 | 141 | This mapping results in a 1:1 correspondence between 142 | subjectAltName iPAddress values and the name values."; 143 | reference 144 | "RFC 6353: Transport Layer Security (TLS) Transport Model 145 | for the Simple Network Management Protocol (SNMP). 146 | SNMP-TLS-TM-MIB.snmpTlstmCertSANIpAddress"; 147 | } 148 | 149 | identity san-any { 150 | base cert-to-name; 151 | description 152 | "Maps any of the following fields using the corresponding 153 | mapping algorithms: 154 | 155 | +------------+-----------------+ 156 | | Type | Algorithm | 157 | |------------+-----------------| 158 | | rfc822Name | san-rfc822-name | 159 | | dNSName | san-dns-name | 160 | | iPAddress | san-ip-address | 161 | +------------+-----------------+ 162 | 163 | The first matching subjectAltName value found in the 164 | certificate of the above types MUST be used when deriving 165 | the name. The mapping algorithm specified in the 166 | 'Algorithm' column MUST be used to derive the name. 167 | 168 | This mapping results in a 1:1 correspondence between 169 | subjectAltName values and name values. The three sub-mapping 170 | algorithms produced by this combined algorithm cannot produce 171 | conflicting results between themselves."; 172 | reference 173 | "RFC 6353: Transport Layer Security (TLS) Transport Model 174 | for the Simple Network Management Protocol (SNMP). 175 | SNMP-TLS-TM-MIB.snmpTlstmCertSANAny"; 176 | } 177 | 178 | identity common-name { 179 | base cert-to-name; 180 | description 181 | "Maps a certificate's CommonName to a name after converting 182 | it to a UTF-8 encoding. The usage of CommonNames is 183 | deprecated, and users are encouraged to use subjectAltName 184 | mapping methods instead. This mapping results in a 1:1 185 | correspondence between certificate CommonName values and name 186 | values."; 187 | reference 188 | "RFC 6353: Transport Layer Security (TLS) Transport Model 189 | for the Simple Network Management Protocol (SNMP). 190 | SNMP-TLS-TM-MIB.snmpTlstmCertCommonName"; 191 | } 192 | 193 | /* 194 | * Groupings 195 | */ 196 | 197 | grouping cert-to-name { 198 | description 199 | "Defines nodes for mapping certificates to names. Modules 200 | that use this grouping should describe how the resulting 201 | name is used."; 202 | 203 | list cert-to-name { 204 | key id; 205 | description 206 | "This list defines how certificates are mapped to names. 207 | The name is derived by considering each cert-to-name 208 | list entry in order. The cert-to-name entry's fingerprint 209 | determines whether the list entry is a match: 210 | 211 | 1) If the cert-to-name list entry's fingerprint value 212 | matches that of the presented certificate, then consider 213 | the list entry a successful match. 214 | 215 | 2) If the cert-to-name list entry's fingerprint value 216 | matches that of a locally held copy of a trusted CA 217 | certificate, and that CA certificate was part of the CA 218 | certificate chain to the presented certificate, then 219 | consider the list entry a successful match. 220 | 221 | Once a matching cert-to-name list entry has been found, the 222 | map-type is used to determine how the name associated with 223 | the certificate should be determined. See the map-type 224 | leaf's description for details on determining the name value. 225 | If it is impossible to determine a name from the cert-to-name 226 | list entry's data combined with the data presented in the 227 | certificate, then additional cert-to-name list entries MUST 228 | be searched to look for another potential match. 229 | 230 | Security administrators are encouraged to make use of 231 | certificates with subjectAltName fields that can be mapped to 232 | names so that a single root CA certificate can allow all 233 | child certificates' subjectAltName fields to map directly to 234 | a name via a 1:1 transformation."; 235 | reference 236 | "RFC 6353: Transport Layer Security (TLS) Transport Model 237 | for the Simple Network Management Protocol (SNMP). 238 | SNMP-TLS-TM-MIB.snmpTlstmCertToTSNEntry"; 239 | 240 | leaf id { 241 | type uint32; 242 | description 243 | "The id specifies the order in which the entries in the 244 | cert-to-name list are searched. Entries with lower 245 | numbers are searched first."; 246 | reference 247 | "RFC 6353: Transport Layer Security (TLS) Transport Model 248 | for the Simple Network Management Protocol 249 | (SNMP). 250 | SNMP-TLS-TM-MIB.snmpTlstmCertToTSNID"; 251 | } 252 | 253 | leaf fingerprint { 254 | type x509c2n:tls-fingerprint; 255 | mandatory true; 256 | description 257 | "Specifies a value with which the fingerprint of the 258 | full certificate presented by the peer is compared. If 259 | the fingerprint of the full certificate presented by the 260 | peer does not match the fingerprint configured, then the 261 | entry is skipped, and the search for a match continues."; 262 | reference 263 | "RFC 6353: Transport Layer Security (TLS) Transport Model 264 | for the Simple Network Management Protocol 265 | (SNMP). 266 | SNMP-TLS-TM-MIB.snmpTlstmCertToTSNFingerprint"; 267 | } 268 | 269 | leaf map-type { 270 | type identityref { 271 | base cert-to-name; 272 | } 273 | mandatory true; 274 | description 275 | "Specifies the algorithm used to map the certificate 276 | presented by the peer to a name. 277 | 278 | Mappings that need additional configuration objects should 279 | use the 'when' statement to make them conditional based on 280 | the map-type."; 281 | reference 282 | "RFC 6353: Transport Layer Security (TLS) Transport Model 283 | for the Simple Network Management Protocol 284 | (SNMP). 285 | SNMP-TLS-TM-MIB.snmpTlstmCertToTSNMapType"; 286 | } 287 | 288 | leaf name { 289 | when "../map-type = 'x509c2n:specified'"; 290 | type string; 291 | mandatory true; 292 | description 293 | "Directly specifies the NETCONF username when the 294 | map-type is 'specified'."; 295 | reference 296 | "RFC 6353: Transport Layer Security (TLS) Transport Model 297 | for the Simple Network Management Protocol 298 | (SNMP). 299 | SNMP-TLS-TM-MIB.snmpTlstmCertToTSNData"; 300 | } 301 | } 302 | } 303 | } 304 | -------------------------------------------------------------------------------- /ietf-yangs/ietf-yang-smiv2.yang: -------------------------------------------------------------------------------- 1 | module ietf-yang-smiv2 { 2 | 3 | namespace "urn:ietf:params:xml:ns:yang:ietf-yang-smiv2"; 4 | prefix "smiv2"; 5 | 6 | organization 7 | "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; 8 | 9 | contact 10 | "WG Web: 11 | WG List: 12 | 13 | WG Chair: David Kessens 14 | 15 | 16 | WG Chair: Juergen Schoenwaelder 17 | 18 | 19 | Editor: Juergen Schoenwaelder 20 | "; 21 | 22 | description 23 | "This module defines YANG extensions that are used to translate 24 | SMIv2 concepts into YANG. 25 | 26 | Copyright (c) 2012 IETF Trust and the persons identified as 27 | authors of the code. All rights reserved. 28 | 29 | Redistribution and use in source and binary forms, with or 30 | without modification, is permitted pursuant to, and subject 31 | to the license terms contained in, the Simplified BSD License 32 | set forth in Section 4.c of the IETF Trust's Legal Provisions 33 | Relating to IETF Documents 34 | (http://trustee.ietf.org/license-info). 35 | 36 | This version of this YANG module is part of RFC 6643; see 37 | the RFC itself for full legal notices."; 38 | 39 | revision 2012-06-22 { 40 | description 41 | "Initial revision."; 42 | reference 43 | "RFC 6643: Translation of Structure of Management Information 44 | Version 2 (SMIv2) MIB Modules to YANG Modules"; 45 | } 46 | 47 | identity object-identity { 48 | description 49 | "Base identity for all SMIv2 OBJECT-IDENTITYs."; 50 | } 51 | 52 | typedef opaque { 53 | type binary; 54 | description 55 | "The Opaque type supports the capability to pass arbitrary ASN.1 56 | syntax. A value is encoded using the ASN.1 Basic Encoding Rules 57 | into a string of octets. This, in turn, is encoded as an OCTET 58 | STRING, in effect 'double-wrapping' the original ASN.1 value. 59 | 60 | In the value set and its semantics, this type is equivalent to 61 | the Opaque type of the SMIv2. This type exists in the SMIv2 62 | solely for backward-compatibility reasons and this is also 63 | true for this YANG data type."; 64 | reference 65 | "RFC 2578: Structure of Management Information Version 2 (SMIv2)"; 66 | } 67 | 68 | extension display-hint { 69 | argument "format"; 70 | description 71 | "The display-hint statement takes as an argument the DISPLAY-HINT 72 | assigned to an SMIv2 textual convention."; 73 | reference 74 | "RFC 2579: Textual Conventions for SMIv2"; 75 | } 76 | 77 | 78 | 79 | 80 | 81 | extension max-access { 82 | argument "access"; 83 | description 84 | "The max-access statement takes as an argument the MAX-ACCESS 85 | assigned to an SMIv2 object definition. 86 | 87 | The MAX-ACCESS value is SMIv2 specific and has no impact on 88 | the access provided to YANG objects through protocols such 89 | as NETCONF."; 90 | reference 91 | "RFC 2578: Structure of Management Information Version 2 (SMIv2)"; 92 | } 93 | 94 | extension defval { 95 | argument "value"; 96 | description 97 | "The defval statement takes as an argument a default value 98 | defined by an SMIv2 DEFVAL clause. Note that the value is in 99 | the SMIv2 value space defined by the SMIv2 syntax of the 100 | corresponding object and not in the YANG value space 101 | defined by the corresponding YANG data type."; 102 | reference 103 | "RFC 2578: Structure of Management Information Version 2 (SMIv2)"; 104 | } 105 | 106 | extension implied { 107 | argument "index"; 108 | description 109 | "If an SMIv2 INDEX object is preceded by the IMPLIED keyword, then 110 | the implied statement is present in the YANG module and takes as 111 | an argument the name of the IMPLIED index object."; 112 | reference 113 | "RFC 2578: Structure of Management Information Version 2 (SMIv2)"; 114 | } 115 | 116 | extension alias { 117 | argument "descriptor"; 118 | description 119 | "The alias statement introduces an SMIv2 descriptor. The body of 120 | the alias statement is expected to contain an oid statement that 121 | provides the numeric OID associated with the descriptor."; 122 | reference 123 | "RFC 2578: Structure of Management Information Version 2 (SMIv2)"; 124 | } 125 | 126 | 127 | 128 | 129 | extension oid { 130 | argument "value"; 131 | description 132 | "The oid statement takes as an argument the object identifier 133 | assigned to an SMIv2 definition. The object identifier value 134 | is written in decimal dotted notation."; 135 | reference 136 | "RFC 2578: Structure of Management Information Version 2 (SMIv2)"; 137 | } 138 | 139 | extension subid { 140 | argument "value"; 141 | description 142 | "The subid statement takes as an argument the last sub-identifier 143 | of the object identifier assigned to an SMIv2 definition. The 144 | sub-identifier value is a single positive decimal natural number. 145 | The subid statement may not be used as a substatement to any 146 | top-level node in a YANG document. The subid substatement may 147 | be used only as a substatement to a node having a parent node 148 | defined with either an smiv2:oid or smiv2:subid substatement."; 149 | reference 150 | "RFC 2578: Structure of Management Information Version 2 (SMIv2)"; 151 | } 152 | 153 | } 154 | -------------------------------------------------------------------------------- /ietf-yangs/nc-notifications@2008-07-14.yang: -------------------------------------------------------------------------------- 1 | module nc-notifications { 2 | 3 | namespace "urn:ietf:params:xml:ns:netmod:notification"; 4 | prefix "manageEvent"; 5 | 6 | import ietf-yang-types{ prefix yang; } 7 | import notifications { prefix ncEvent; } 8 | 9 | organization 10 | "IETF NETCONF WG"; 11 | 12 | contact 13 | "netconf@ietf.org"; 14 | 15 | description 16 | "Conversion of the 'manageEvent' XSD in the NETCONF 17 | Notifications RFC."; 18 | 19 | reference 20 | "RFC 5277"; 21 | 22 | revision 2008-07-14 { 23 | description "RFC 5277 version."; 24 | } 25 | 26 | container netconf { 27 | description "Top-level element in the notification namespace"; 28 | 29 | config false; 30 | 31 | container streams { 32 | description 33 | "The list of event streams supported by the system. When 34 | a query is issued, the returned set of streams is 35 | determined based on user privileges."; 36 | 37 | list stream { 38 | description 39 | "Stream name, description and other information."; 40 | key name; 41 | min-elements 1; 42 | 43 | leaf name { 44 | description 45 | "The name of the event stream. If this is the default 46 | NETCONF stream, this must have the value 'NETCONF'."; 47 | type ncEvent:streamNameType; 48 | } 49 | 50 | leaf description { 51 | description 52 | "A description of the event stream, including such 53 | information as the type of events that are sent over 54 | this stream."; 55 | type string; 56 | mandatory true; 57 | } 58 | 59 | leaf replaySupport { 60 | description 61 | "A description of the event stream, including such 62 | information as the type of events that are sent over 63 | this stream."; 64 | type boolean; 65 | mandatory true; 66 | } 67 | 68 | leaf replayLogCreationTime { 69 | description 70 | "The timestamp of the creation of the log used to support 71 | the replay function on this stream. Note that this might 72 | be earlier then the earliest available notification in 73 | the log. This object is updated if the log resets for 74 | some reason. This object MUST be present if replay is 75 | supported."; 76 | type yang:date-and-time; // xsd:dateTime is wrong! 77 | } 78 | } 79 | } 80 | } 81 | 82 | notification replayComplete { 83 | description 84 | "This notification is sent to signal the end of a replay 85 | portion of a subscription."; 86 | } 87 | 88 | notification notificationComplete { 89 | description 90 | "This notification is sent to signal the end of a notification 91 | subscription. It is sent in the case that stopTime was 92 | specified during the creation of the subscription.."; 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /ietf-yangs/notifications@2008-07-14.yang: -------------------------------------------------------------------------------- 1 | module notifications { 2 | 3 | namespace "urn:ietf:params:xml:ns:netconf:notification:1.0"; 4 | prefix "ncEvent"; 5 | 6 | import ietf-yang-types { prefix yang; } 7 | 8 | import yuma-ncx { prefix ncx; } 9 | 10 | organization 11 | "IETF NETCONF WG"; 12 | 13 | contact 14 | "netconf@ops.ietf.org"; 15 | 16 | description 17 | "Conversion of the 'ncEvent' XSD in the 18 | NETCONF Notifications RFC."; 19 | 20 | reference 21 | "RFC 5277."; 22 | 23 | revision 2008-07-14 { 24 | description "RFC 5277 version."; 25 | } 26 | 27 | typedef streamNameType { 28 | description 29 | "The name of an event stream."; 30 | type string; 31 | } 32 | 33 | rpc create-subscription { 34 | description 35 | "The command to create a notification subscription. It 36 | takes as argument the name of the notification stream 37 | and filter. Both of those options limit the content of 38 | the subscription. In addition, there are two time-related 39 | parameters, startTime and stopTime, which can be used to 40 | select the time interval of interest to the notification 41 | replay feature."; 42 | 43 | input { 44 | leaf stream { 45 | description 46 | "An optional parameter that indicates which stream of events 47 | is of interest. If not present, then events in the default 48 | NETCONF stream will be sent."; 49 | type streamNameType; 50 | default "NETCONF"; 51 | } 52 | 53 | anyxml filter { 54 | description 55 | "An optional parameter that indicates which subset of all 56 | possible events is of interest. The format of this 57 | parameter is the same as that of the filter parameter 58 | in the NETCONF protocol operations. If not present, 59 | all events not precluded by other parameters will 60 | be sent."; 61 | } 62 | 63 | leaf startTime { 64 | description 65 | "A parameter used to trigger the replay feature and 66 | indicates that the replay should start at the time 67 | specified. If start time is not present, this is not a 68 | replay subscription."; 69 | type yang:date-and-time; 70 | } 71 | 72 | leaf stopTime { 73 | // must ". >= ../startTime"; 74 | description 75 | "An optional parameter used with the optional replay 76 | feature to indicate the newest notifications of 77 | interest. If stop time is not present, the notifications 78 | will continue until the subscription is terminated. 79 | Must be used with startTime."; 80 | type yang:date-and-time; 81 | } 82 | } 83 | } 84 | 85 | container notification { 86 | description "internal struct to start a notification"; 87 | ncx:abstract; 88 | ncx:hidden; 89 | config false; 90 | 91 | leaf eventTime { 92 | mandatory true; 93 | type yang:date-and-time; 94 | } 95 | 96 | // eventType and any data content goes here 97 | } 98 | } 99 | 100 | -------------------------------------------------------------------------------- /js/main.js: -------------------------------------------------------------------------------- 1 | var spinner = "loading" 2 | 3 | function loading(show) { 4 | $("#i_spinner").css('visibility', (show == 1) ? 'visible' : 'hidden') 5 | } 6 | 7 | function validateEmail(email) { 8 | var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 9 | return re.test(email); 10 | } 11 | 12 | $(function() { 13 | // open last opened link or open channels if nothing requested 14 | if (location.hash) 15 | process_action(location.hash) 16 | else 17 | location.hash = "#editor" 18 | 19 | // open when hash changes - click mostly 20 | $(window).on("hashchange", function() { 21 | var action = location.hash 22 | process_action(action) 23 | }) 24 | 25 | function set_login_welcome() { 26 | var user_data = get_userdata() 27 | if (user_data) { 28 | $("#f_login").hide() 29 | $("#d_welcome").find("#s_msg").text(user_data.email).end().show() 30 | } else { 31 | $("#d_welcome").hide() 32 | $("#f_login").show() 33 | } 34 | } 35 | set_login_welcome() 36 | 37 | var do_login = function(email, pass) { 38 | if (!validateEmail(email)) 39 | return Promise.reject("Invalid email") 40 | 41 | if (pass.length < 6) 42 | return Promise.reject("Password is too short") 43 | 44 | var pass_hash = Sha256.hash(pass) 45 | 46 | return $.ajax({ 47 | type: 'POST', 48 | url: '/register/' + email + "/" + pass_hash, 49 | dataType: 'json', 50 | success: function(result) { 51 | $.jStorage.set('yanger_pass_hash', pass_hash) 52 | $.jStorage.set('yanger_email', email) 53 | set_login_welcome() 54 | } 55 | }) 56 | } 57 | 58 | var do_logout = function() {} 59 | 60 | $("#f_login").submit(function(e) { 61 | e.preventDefault() 62 | var self = $(this) 63 | var user_pass = self.find("#i_userpass").val().trim() 64 | var email = self.find("#i_email").val().trim() 65 | 66 | do_login(email, user_pass).then(function(data) { 67 | show_alert("Welcome, " + email + '!') 68 | }, function(error) { 69 | show_alert(error) 70 | }) 71 | }) 72 | 73 | $("#d_welcome").on("click", "#a_logout", function() { 74 | console.debug("logout") 75 | $.jStorage.deleteKey('yanger_pass_hash') 76 | $.jStorage.deleteKey('yanger_pass_email') 77 | 78 | set_login_welcome() 79 | }) 80 | 81 | $(document).on('change', '.btn-file :file', function() { 82 | var input = $(this) 83 | var numFiles = input.get(0).files ? input.get(0).files.length : 1 84 | var label = input.val().replace(/\\/g, '/').replace(/.*\//, '') 85 | input.trigger('fileselect', [numFiles, label]) 86 | }) 87 | 88 | $('.btn-file :file').on('fileselect', function(event, numFiles, label) { 89 | 90 | var input = $(this).parents('.input-group').find(':text') 91 | var log = numFiles > 1 ? numFiles + ' files selected' : label 92 | 93 | input.length && input.val(log) 94 | }) 95 | }) 96 | 97 | function process_action(action) { 98 | if (!action) 99 | return 100 | 101 | action = $.trim(action.replace('#', '')) 102 | } 103 | 104 | function show_success(msg) { 105 | $("" + msg + " ").csInfo() 106 | loading(0) 107 | } 108 | 109 | function show_alert(msg) { 110 | $("" + msg + " ").csInfo('alert alert-danger') 111 | loading(0) 112 | } 113 | 114 | function show_modal(title, html, footer) { 115 | title = title || '' 116 | html = html || '' 117 | footer = footer || '' 118 | 119 | var ref = $("#d_modal") 120 | ref.find('.modal-title').html(title) 121 | ref.find(".modal-body").html(html) 122 | 123 | var $footer = ref.find(".modal-footer") 124 | footer && $footer.html(footer).show() || $footer.hide() 125 | 126 | ref.modal() 127 | } 128 | 129 | function hide_modal() { 130 | $("#d_modal").modal('hide') 131 | } 132 | 133 | function get_userdata() { 134 | var yang_userpass_hash = $.jStorage.get("yanger_pass_hash") 135 | var yang_email = $.jStorage.get("yanger_email") 136 | 137 | console.debug("email:" + yang_email) 138 | 139 | if (!yang_userpass_hash || !yang_email) 140 | return 0 141 | else 142 | return { 143 | "pass": yang_userpass_hash, 144 | "email": yang_email 145 | } 146 | } 147 | 148 | (function($) { 149 | $.fn.outerHTML = function() { 150 | $t = $(this); 151 | if ("outerHTML" in $t[0]) return $t[0].outerHTML; 152 | else return $t.clone().wrap('

').parent().html(); 153 | } 154 | 155 | /* csDefault */ 156 | var csInfoID = 0 157 | $.fn.csInfo = function(arg1, arg2) { 158 | ++csInfoID 159 | var bkgclass = "alert alert-info" 160 | var duration = 2500 161 | 162 | if (arg1 && arg2)(bkgclass = arg1) && (duration = arg2) 163 | else arg1 && (isNaN(arg1) && (bkgclass = arg1) || (duration = arg1)) 164 | 165 | var msg = $(this).outerHTML() 166 | 167 | var html = $('

' + msg + '
') 168 | 169 | $div = $("body").append(html).find('div[id^="csInfoDiv"]') 170 | $div.addClass("csInfoDiv") 171 | $div.slideDown("fast").delay(duration).slideUp("fast", function() { 172 | $(this).remove() 173 | }) 174 | $div.hover(function() { 175 | $(this).css("opacity", "0.5") 176 | }, function() { 177 | $(this).css("opacity", "1") 178 | }) 179 | } 180 | })(jQuery) 181 | 182 | function htmlentities(string, quote_style, charset, double_encode) { 183 | var hash_map = this.get_html_translation_table('HTML_ENTITIES', quote_style) 184 | var symbol = '' 185 | string = string == null ? '' : string + '' 186 | 187 | if (!hash_map) 188 | return false 189 | 190 | if (quote_style && quote_style === 'ENT_QUOTES') 191 | hash_map["'"] = ''' 192 | 193 | if (!!double_encode || double_encode == null) { 194 | for (symbol in hash_map) { 195 | if (hash_map.hasOwnProperty(symbol)) { 196 | string = string.split(symbol) 197 | .join(hash_map[symbol]); 198 | } 199 | } 200 | } else { 201 | string = string.replace(/([\s\S]*?)(&(?:#\d+|#x[\da-f]+|[a-zA-Z][\da-z]*);|$)/g, function(ignore, text, entity) { 202 | for (symbol in hash_map) { 203 | if (hash_map.hasOwnProperty(symbol)) { 204 | text = text.split(symbol).join(hash_map[symbol]) 205 | } 206 | } 207 | 208 | return text + entity; 209 | }) 210 | } 211 | 212 | return nl2br(string) 213 | } 214 | 215 | function get_html_translation_table(table, quote_style) { 216 | var entities = {}, 217 | hash_map = {}, 218 | decimal; 219 | var constMappingTable = {}, 220 | constMappingQuoteStyle = {}; 221 | var useTable = {}, 222 | useQuoteStyle = {}; 223 | 224 | constMappingTable[0] = 'HTML_SPECIALCHARS'; 225 | constMappingTable[1] = 'HTML_ENTITIES'; 226 | constMappingQuoteStyle[0] = 'ENT_NOQUOTES'; 227 | constMappingQuoteStyle[2] = 'ENT_COMPAT'; 228 | constMappingQuoteStyle[3] = 'ENT_QUOTES'; 229 | 230 | useTable = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS'; 231 | useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 232 | 'ENT_COMPAT'; 233 | 234 | if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') { 235 | throw new Error('Table: ' + useTable + ' not supported'); 236 | } 237 | 238 | entities['38'] = '&'; 239 | if (useTable === 'HTML_ENTITIES') { 240 | entities['160'] = ' '; 241 | entities['161'] = '¡'; 242 | entities['162'] = '¢'; 243 | entities['163'] = '£'; 244 | entities['164'] = '¤'; 245 | entities['165'] = '¥'; 246 | entities['166'] = '¦'; 247 | entities['167'] = '§'; 248 | entities['168'] = '¨'; 249 | entities['169'] = '©'; 250 | entities['170'] = 'ª'; 251 | entities['171'] = '«'; 252 | entities['172'] = '¬'; 253 | entities['173'] = '­'; 254 | entities['174'] = '®'; 255 | entities['175'] = '¯'; 256 | entities['176'] = '°'; 257 | entities['177'] = '±'; 258 | entities['178'] = '²'; 259 | entities['179'] = '³'; 260 | entities['180'] = '´'; 261 | entities['181'] = 'µ'; 262 | entities['182'] = '¶'; 263 | entities['183'] = '·'; 264 | entities['184'] = '¸'; 265 | entities['185'] = '¹'; 266 | entities['186'] = 'º'; 267 | entities['187'] = '»'; 268 | entities['188'] = '¼'; 269 | entities['189'] = '½'; 270 | entities['190'] = '¾'; 271 | entities['191'] = '¿'; 272 | entities['192'] = 'À'; 273 | entities['193'] = 'Á'; 274 | entities['194'] = 'Â'; 275 | entities['195'] = 'Ã'; 276 | entities['196'] = 'Ä'; 277 | entities['197'] = 'Å'; 278 | entities['198'] = 'Æ'; 279 | entities['199'] = 'Ç'; 280 | entities['200'] = 'È'; 281 | entities['201'] = 'É'; 282 | entities['202'] = 'Ê'; 283 | entities['203'] = 'Ë'; 284 | entities['204'] = 'Ì'; 285 | entities['205'] = 'Í'; 286 | entities['206'] = 'Î'; 287 | entities['207'] = 'Ï'; 288 | entities['208'] = 'Ð'; 289 | entities['209'] = 'Ñ'; 290 | entities['210'] = 'Ò'; 291 | entities['211'] = 'Ó'; 292 | entities['212'] = 'Ô'; 293 | entities['213'] = 'Õ'; 294 | entities['214'] = 'Ö'; 295 | entities['215'] = '×'; 296 | entities['216'] = 'Ø'; 297 | entities['217'] = 'Ù'; 298 | entities['218'] = 'Ú'; 299 | entities['219'] = 'Û'; 300 | entities['220'] = 'Ü'; 301 | entities['221'] = 'Ý'; 302 | entities['222'] = 'Þ'; 303 | entities['223'] = 'ß'; 304 | entities['224'] = 'à'; 305 | entities['225'] = 'á'; 306 | entities['226'] = 'â'; 307 | entities['227'] = 'ã'; 308 | entities['228'] = 'ä'; 309 | entities['229'] = 'å'; 310 | entities['230'] = 'æ'; 311 | entities['231'] = 'ç'; 312 | entities['232'] = 'è'; 313 | entities['233'] = 'é'; 314 | entities['234'] = 'ê'; 315 | entities['235'] = 'ë'; 316 | entities['236'] = 'ì'; 317 | entities['237'] = 'í'; 318 | entities['238'] = 'î'; 319 | entities['239'] = 'ï'; 320 | entities['240'] = 'ð'; 321 | entities['241'] = 'ñ'; 322 | entities['242'] = 'ò'; 323 | entities['243'] = 'ó'; 324 | entities['244'] = 'ô'; 325 | entities['245'] = 'õ'; 326 | entities['246'] = 'ö'; 327 | entities['247'] = '÷'; 328 | entities['248'] = 'ø'; 329 | entities['249'] = 'ù'; 330 | entities['250'] = 'ú'; 331 | entities['251'] = 'û'; 332 | entities['252'] = 'ü'; 333 | entities['253'] = 'ý'; 334 | entities['254'] = 'þ'; 335 | entities['255'] = 'ÿ'; 336 | } 337 | 338 | if (useQuoteStyle !== 'ENT_NOQUOTES') { 339 | entities['34'] = '"' 340 | } 341 | 342 | if (useQuoteStyle === 'ENT_QUOTES') { 343 | entities['39'] = ''' 344 | } 345 | 346 | entities['60'] = '<' 347 | entities['62'] = '>' 348 | 349 | for (decimal in entities) { 350 | if (entities.hasOwnProperty(decimal)) { 351 | hash_map[String.fromCharCode(decimal)] = entities[decimal]; 352 | } 353 | } 354 | 355 | return hash_map; 356 | } 357 | 358 | function html_entity_decode(string, quote_style) { 359 | var hash_map = {} 360 | var symbol = '' 361 | var tmp_str = '' 362 | var entity = '' 363 | var tmp_str = string.toString() 364 | 365 | if (false === (hash_map = this.get_html_translation_table('HTML_ENTITIES', quote_style))) { 366 | return false; 367 | } 368 | 369 | delete(hash_map['&']) 370 | hash_map['&'] = '&' 371 | 372 | for (symbol in hash_map) { 373 | entity = hash_map[symbol] 374 | tmp_str = tmp_str.split(entity).join(symbol) 375 | } 376 | tmp_str = tmp_str.split(''').join("'") 377 | 378 | return br2nl(tmp_str) 379 | } 380 | 381 | function nl2br(str) { 382 | return str.replace(/(?:\r\n|\r|\n)/g, '
') 383 | } 384 | 385 | function br2nl(str) { 386 | return str.replace(//gi, "\n") 387 | } 388 | 389 | function remove_server_path(str) { 390 | return str.replace(/\/[A-z0-9]+.\/[A-z0-9]+\//gi, '') 391 | } 392 | -------------------------------------------------------------------------------- /js/promise.js: -------------------------------------------------------------------------------- 1 | !function(){var a,b,c,d;!function(){var e={},f={};a=function(a,b,c){e[a]={deps:b,callback:c}},d=c=b=function(a){function c(b){if("."!==b.charAt(0))return b;for(var c=b.split("/"),d=a.split("/").slice(0,-1),e=0,f=c.length;f>e;e++){var g=c[e];if(".."===g)d.pop();else{if("."===g)continue;d.push(g)}}return d.join("/")}if(d._eak_seen=e,f[a])return f[a];if(f[a]={},!e[a])throw new Error("Could not find module "+a);for(var g,h=e[a],i=h.deps,j=h.callback,k=[],l=0,m=i.length;m>l;l++)"exports"===i[l]?k.push(g={}):k.push(b(c(i[l])));var n=j.apply(this,k);return f[a]=g||n}}(),a("promise/all",["./utils","exports"],function(a,b){"use strict";function c(a){var b=this;if(!d(a))throw new TypeError("You must pass an array to all.");return new b(function(b,c){function d(a){return function(b){f(a,b)}}function f(a,c){h[a]=c,0===--i&&b(h)}var g,h=[],i=a.length;0===i&&b([]);for(var j=0;j>> 32, but since JS converts 61 | // bitwise-op args to 32 bits, we need to simulate this by arithmetic operators 62 | M[N-1][14] = ((msg.length-1)*8) / Math.pow(2, 32); M[N-1][14] = Math.floor(M[N-1][14]); 63 | M[N-1][15] = ((msg.length-1)*8) & 0xffffffff; 64 | 65 | 66 | // HASH COMPUTATION [§6.1.2] 67 | 68 | var W = new Array(64); var a, b, c, d, e, f, g, h; 69 | for (var i=0; i>> n) | (x << (32-n)); 113 | }; 114 | 115 | /** 116 | * Logical functions [§4.1.2]. 117 | * @private 118 | */ 119 | Sha256.Σ0 = function(x) { return Sha256.ROTR(2, x) ^ Sha256.ROTR(13, x) ^ Sha256.ROTR(22, x); }; 120 | Sha256.Σ1 = function(x) { return Sha256.ROTR(6, x) ^ Sha256.ROTR(11, x) ^ Sha256.ROTR(25, x); }; 121 | Sha256.σ0 = function(x) { return Sha256.ROTR(7, x) ^ Sha256.ROTR(18, x) ^ (x>>>3); }; 122 | Sha256.σ1 = function(x) { return Sha256.ROTR(17, x) ^ Sha256.ROTR(19, x) ^ (x>>>10); }; 123 | Sha256.Ch = function(x, y, z) { return (x & y) ^ (~x & z); }; 124 | Sha256.Maj = function(x, y, z) { return (x & y) ^ (x & z) ^ (y & z); }; 125 | 126 | 127 | /** 128 | * Hexadecimal representation of a number. 129 | * @private 130 | */ 131 | Sha256.toHexStr = function(n) { 132 | // note can't use toString(16) as it is implementation-dependant, 133 | // and in IE returns signed numbers when used on full words 134 | var s="", v; 135 | for (var i=7; i>=0; i--) { v = (n>>>(i*4)) & 0xf; s += v.toString(16); } 136 | return s; 137 | }; 138 | 139 | 140 | /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 141 | 142 | 143 | /** Extend String object with method to encode multi-byte string to utf8 144 | * - monsur.hossa.in/2012/07/20/utf-8-in-javascript.html */ 145 | if (typeof String.prototype.utf8Encode == 'undefined') { 146 | String.prototype.utf8Encode = function() { 147 | return unescape( encodeURIComponent( this ) ); 148 | }; 149 | } 150 | 151 | /** Extend String object with method to decode utf8 string to multi-byte */ 152 | if (typeof String.prototype.utf8Decode == 'undefined') { 153 | String.prototype.utf8Decode = function() { 154 | try { 155 | return decodeURIComponent( escape( this ) ); 156 | } catch (e) { 157 | return this; // invalid UTF-8? return as-is 158 | } 159 | }; 160 | } 161 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "yanger", 3 | "version": "0.9.0", 4 | "description": "Yang Creator UI written using HTML5 and nodejs", 5 | "main": "server.js", 6 | "scripts": { 7 | }, 8 | "repository": { 9 | "type": "git", 10 | "url": "https://github.com/freenetconf/yanger" 11 | }, 12 | "keywords": [ 13 | "YANG", 14 | "NETCONF", 15 | "Editor" 16 | ], 17 | "author": { 18 | "name": "Petar Koretic", 19 | "email": "petar.koretic@sartura.hr" 20 | }, 21 | "license": "MIT", 22 | "bugs": { 23 | "url": "https://github.com/freenetconf/yanger/issues" 24 | }, 25 | "homepage": "https://github.com/freenetconf/yanger", 26 | "dependencies": { 27 | "express" : "4.13.4", 28 | "body-parser" : "1.15.0", 29 | "level" : "1.4.0", 30 | "node-minify" : "1.3.2", 31 | "compression" : "1.6.1", 32 | "multer" : "1.1.0", 33 | "yang-parser" : "0.1.0", 34 | "validator" : "5.1.0", 35 | "rimraf" : "2.5.2", 36 | "adm-zip": "0.4.7", 37 | "nodemailer": "2.3.0", 38 | "promise": "7.1.1", 39 | "mustache": "2.2.1", 40 | "fs-extra": "0.30.0", 41 | "libyang": "1.0.9", 42 | "easy-zip": "0.0.4" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /public/.gitignore: -------------------------------------------------------------------------------- 1 | main.css 2 | main.js 3 | -------------------------------------------------------------------------------- /public/ZeroClipboard.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freenetconf/yang-creator/f79279ceed1fdeb982cdf21f6e71ed73574238f9/public/ZeroClipboard.swf -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freenetconf/yang-creator/f79279ceed1fdeb982cdf21f6e71ed73574238f9/public/favicon.ico -------------------------------------------------------------------------------- /public/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freenetconf/yang-creator/f79279ceed1fdeb982cdf21f6e71ed73574238f9/public/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /public/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freenetconf/yang-creator/f79279ceed1fdeb982cdf21f6e71ed73574238f9/public/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /public/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freenetconf/yang-creator/f79279ceed1fdeb982cdf21f6e71ed73574238f9/public/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /public/img/bt_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freenetconf/yang-creator/f79279ceed1fdeb982cdf21f6e71ed73574238f9/public/img/bt_close.png -------------------------------------------------------------------------------- /public/img/bt_open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freenetconf/yang-creator/f79279ceed1fdeb982cdf21f6e71ed73574238f9/public/img/bt_open.png -------------------------------------------------------------------------------- /public/img/chosen-sprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freenetconf/yang-creator/f79279ceed1fdeb982cdf21f6e71ed73574238f9/public/img/chosen-sprite.png -------------------------------------------------------------------------------- /public/img/chosen-sprite@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freenetconf/yang-creator/f79279ceed1fdeb982cdf21f6e71ed73574238f9/public/img/chosen-sprite@2x.png -------------------------------------------------------------------------------- /public/img/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freenetconf/yang-creator/f79279ceed1fdeb982cdf21f6e71ed73574238f9/public/img/favicon.png -------------------------------------------------------------------------------- /public/img/github-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freenetconf/yang-creator/f79279ceed1fdeb982cdf21f6e71ed73574238f9/public/img/github-logo.png -------------------------------------------------------------------------------- /public/img/html5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freenetconf/yang-creator/f79279ceed1fdeb982cdf21f6e71ed73574238f9/public/img/html5.png -------------------------------------------------------------------------------- /public/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freenetconf/yang-creator/f79279ceed1fdeb982cdf21f6e71ed73574238f9/public/img/logo.png -------------------------------------------------------------------------------- /public/img/spinner.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freenetconf/yang-creator/f79279ceed1fdeb982cdf21f6e71ed73574238f9/public/img/spinner.gif -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | YANG Creator 8 | 9 | 10 | 11 | 12 | 13 |
14 | 41 | 42 | 57 | 58 |
59 | 60 |
61 | 62 |
63 | 64 |
65 | 69 |
70 | 71 |
72 | 77 | 81 |
82 | 83 |
84 | 88 |
89 | 90 |
91 | 95 |
96 | 97 |
98 | 102 |
103 | 104 | loading 105 | 106 |
107 |
108 | 109 |
110 |
111 | 112 | 113 | 114 | Browse… 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 |
124 |
125 | 126 |
127 | 128 |
129 | 130 |
131 |
132 | 133 |
134 |

Validation

135 |
136 |
Module not validated yet.
137 |
138 | 139 |
140 | 141 | 150 | 151 | 152 | 153 | 154 | 155 | -------------------------------------------------------------------------------- /public/yangs/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /yang.js: -------------------------------------------------------------------------------- 1 | var levelup = require('level') 2 | var fs = require('fs') 3 | var Promise = require('promise') 4 | var rmdir = require('rimraf') 5 | var yang_parser = require('yang-parser') 6 | 7 | var Yang 8 | 9 | Yang = (function(db_file) { 10 | function Yang() {} 11 | 12 | var db 13 | var ensureDbOpen = function() { 14 | db = levelup(db_file) 15 | } 16 | 17 | /* 18 | * check yang module name if matches identifier 19 | * https://tools.ietf.org/html/rfc6020#page-163 20 | * 21 | * client side and pyang will handle yang validation in more detail 22 | * 23 | * @identifier - yang identifier - mostly yang module name 24 | */ 25 | Yang.identifier_valid = function(identifier) { 26 | if (!identifier) 27 | return false 28 | 29 | return new RegExp(/([A-z]|'_')+([A-z0-9]|\_|\-|\.)*/).test(identifier) 30 | } 31 | 32 | Yang.initial_yang_load = function() { 33 | return new Promise(function(resolve, reject) { 34 | ensureDbOpen() 35 | 36 | var dir = "./ietf-yangs" 37 | var files 38 | try { 39 | files = fs.readdirSync(dir) 40 | } 41 | catch (e) { 42 | console.error(e.toString()) 43 | return reject("can't read default yang dir") 44 | } 45 | 46 | var batch = db.batch() 47 | 48 | for (var i = 0, len = files.length; i < len; i++) { 49 | var yang_module_name = files[i] 50 | 51 | var yang_module_content 52 | try { 53 | yang_module_content = fs.readFileSync(dir + '/' + yang_module_name, 'utf-8') 54 | } catch (e) { 55 | console.error(e.toString()) 56 | console.log("can't read default yang file", yang_module_name) 57 | } 58 | batch = batch.put(yang_module_name, yang_module_content, { "sync": true }) 59 | } 60 | 61 | batch.write(function(error) { 62 | db.close() 63 | 64 | if (error) { 65 | console.error(error) 66 | return reject("unable to save yang module to database") 67 | } 68 | 69 | resolve() 70 | }) 71 | }) 72 | } 73 | 74 | Yang.register = function() { 75 | return new Promise(function(resolve, reject) { 76 | try { 77 | fs.statSync(db_file) 78 | } 79 | catch (e) { 80 | console.log('db not found. registering user') 81 | Yang.initial_yang_load().then(resolve, reject) 82 | } 83 | 84 | resolve() 85 | }) 86 | } 87 | 88 | Yang.all_names = function() { 89 | return new Promise(function(resolve, reject) { 90 | ensureDbOpen() 91 | 92 | var keys = [] 93 | db.createReadStream({ 94 | values: false 95 | }) 96 | .on('data', function(key) { 97 | keys.push(key) 98 | }) 99 | .on('error', function(error) { 100 | console.error("database error when reading yang files") 101 | console.error(error) 102 | 103 | db.close() 104 | }) 105 | .on('end', function() { 106 | resolve(keys) 107 | }) 108 | .on('close', function() { 109 | db.close() 110 | }) 111 | 112 | }) 113 | } 114 | 115 | Yang.find = function(yang_module_name) { 116 | if (!Yang.identifier_valid(yang_module_name)) { 117 | return Promise.reject("invalid YANG module name") 118 | } 119 | 120 | return new Promise(function(resolve, reject) { 121 | ensureDbOpen() 122 | 123 | db.get(yang_module_name, function(error, value) { 124 | db.close() 125 | 126 | if (error) { 127 | console.error("unable to get yang module from database") 128 | console.error(error) 129 | 130 | return reject(error.toString()) 131 | } 132 | 133 | try { 134 | return resolve(yang_parser.parse(value)) 135 | } catch (e) { 136 | console.error(e) 137 | return reject(e) 138 | } 139 | }) 140 | }) 141 | } 142 | 143 | Yang.update = function(yang_module_name, yang_module_content) { 144 | if (!Yang.identifier_valid(yang_module_name)) { 145 | return Promise.reject("invalid YANG module name") 146 | } 147 | if (!yang_module_content || yang_module_content.length < 10) { 148 | return Promise.reject("invalid YANG module content") 149 | } 150 | 151 | return new Promise(function(resolve, reject) { 152 | console.log("saving yang module: " + yang_module_name) 153 | ensureDbOpen() 154 | 155 | db.put(yang_module_name, yang_module_content, function(error) { 156 | db.close() 157 | 158 | if (error) { 159 | console.error(error) 160 | return reject(res, error) 161 | } 162 | 163 | return resolve() 164 | }) 165 | }) 166 | } 167 | 168 | Yang.reset_db = function() { 169 | return new Promise(function(resolve, reject) { 170 | rmdir(db_file, function(error) { 171 | if (error) { 172 | return reject(error) 173 | } 174 | return Yang.initial_yang_load().then(resolve, reject) 175 | }) 176 | }) 177 | } 178 | 179 | Yang.delete = function(name) { 180 | if (!Yang.identifier_valid(name)) { 181 | return Promise.reject("invalid YANG module name") 182 | } 183 | 184 | return new Promise(function(resolve, reject) { 185 | ensureDbOpen() 186 | 187 | db.del(name, function(error) { 188 | db.close() 189 | if (error) { 190 | console.error("database error when deleting yang files") 191 | console.error(error) 192 | 193 | return reject(error) 194 | } 195 | 196 | resolve() 197 | }) 198 | }) 199 | } 200 | 201 | return Yang 202 | }); 203 | 204 | var YangFactory 205 | YangFactory = (function() { 206 | function YangFactory() {} 207 | 208 | /* 209 | * function that we use to get 'uniq' user id 210 | */ 211 | function uniq_n(email, userpass_hash) { 212 | return email + "_" + userpass_hash 213 | } 214 | 215 | YangFactory.setup = function(leveldb_dir) { 216 | this.leveldb_dir = leveldb_dir 217 | } 218 | 219 | YangFactory.createYang = function (email, userpass_hash) { 220 | var user_id = uniq_n(email, userpass_hash) 221 | return Yang(this.leveldb_dir + user_id) 222 | } 223 | 224 | return YangFactory 225 | })() 226 | 227 | module.exports = YangFactory 228 | -------------------------------------------------------------------------------- /yang2src/code_gen.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs') 2 | var mustache = require('mustache') 3 | 4 | var genObject = { 5 | 'C' : [ 6 | { 7 | 'application': { 8 | 'CMakeLists.txt': 'CMakeLists.txt', 9 | 'FindSYSREPO.cmake': 'CMakeModules/FindSYSREPO.cmake', 10 | 'main.c': 'src/main.c', 11 | 'entrypoint.sh': 'entrypoint.sh', 12 | 'run.sh': 'run.sh', 13 | 'README.asciidoc': 'README.asciidoc' 14 | } 15 | }, { 16 | 'plugin': { 17 | 'CMakeLists.txt': 'CMakeLists.txt', 18 | 'FindSYSREPO.cmake': 'CMakeModules/FindSYSREPO.cmake', 19 | 'main.c': 'src/main.c', 20 | 'entrypoint.sh': 'entrypoint.sh', 21 | 'run.sh': 'run.sh', 22 | 'README.asciidoc': 'README.asciidoc' 23 | } 24 | } 25 | ] 26 | }; 27 | 28 | function generate_yang_model(yang_name_full, language, tmp_dir) { 29 | 30 | var short_name = yang_name_full.split('.yang')[0].split('@')[0] 31 | 32 | var view = { 33 | yang_name_full: yang_name_full, 34 | yang_name_short: short_name, 35 | }; 36 | 37 | var template_root = __dirname + "/template/" + language + "/" 38 | 39 | var app_object = genObject[language] 40 | Object.keys(app_object).forEach(function(num_order) { 41 | Object.keys(app_object[num_order]).forEach(function(app_type) { 42 | Object.keys(app_object[num_order][app_type]).forEach(function(item_src) { 43 | item_dest = app_object[num_order][app_type][item_src] 44 | var template_src = template_root + app_type + "/" 45 | var template_dest = tmp_dir + '/' + yang_name_full + '/' + app_type + '/' 46 | 47 | var template = fs.readFileSync(template_src + item_src).toString(); 48 | var content = mustache.render(template, view) 49 | 50 | try { 51 | fs.writeFileSync(template_dest + item_dest, content, 'utf8'); 52 | } catch (e) { 53 | console.log("WRITE ERROR!") 54 | // TODO, write a response 55 | return 56 | } 57 | }); 58 | }); 59 | }); 60 | }; 61 | 62 | function create_folder_structure(yang_name, language, tmp_dir, populate) { 63 | fs.mkdirSync(tmp_dir + '/' + yang_name) 64 | 65 | if (language == "C") { 66 | var app_object = genObject[language] 67 | Object.keys(app_object).forEach(function(num_order) { 68 | Object.keys(app_object[num_order]).forEach(function(app_type) { 69 | var write_loc = tmp_dir + '/' + yang_name + '/' + app_type 70 | fs.mkdirSync(write_loc) 71 | fs.mkdirSync(write_loc + '/yang') 72 | fs.mkdirSync(write_loc + '/src') 73 | fs.mkdirSync(write_loc + '/CMakeModules') 74 | fs.writeFileSync(write_loc + '/yang/' + yang_name, fs.readFileSync(tmp_dir + '/ietf-yang/' + yang_name)); 75 | }); 76 | }); 77 | } 78 | 79 | populate() 80 | }; 81 | 82 | function start(yang_model, language, tmp_dir, callback) { 83 | 84 | // create folder structure 85 | if (yang_model == '/') { 86 | try { var files = fs.readdirSync(tmp_dir + '/ietf-yang'); } 87 | catch(e) { return; } 88 | if (files.length > 0) 89 | var totalCalls = files.length 90 | for (var i = 0; i < files.length; i++) { 91 | (function(i) { 92 | var populate = function() { 93 | generate_yang_model(files[i], language, tmp_dir) 94 | } 95 | create_folder_structure(files[i], language, tmp_dir, populate) 96 | totalCalls = totalCalls -1 97 | })(i); 98 | } 99 | 100 | } else { 101 | var populate = function() { 102 | generate_yang_model(yang_model, language, tmp_dir) 103 | } 104 | create_folder_structure(yang_model, language, tmp_dir, populate) 105 | } 106 | 107 | callback() 108 | }; 109 | 110 | exports.generate = function (yang_model, language, tmp_dir, callback) { 111 | start(yang_model, language, tmp_dir, callback) 112 | }; 113 | -------------------------------------------------------------------------------- /yang2src/template/C/application/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.6) 2 | PROJECT({{yang_name_short}} C) 3 | 4 | # check the supported platform 5 | if(NOT UNIX) 6 | message(FATAL_ERROR "Only *nix like systems are supported.") 7 | endif() 8 | 9 | # set default build type if not specified by user 10 | if(NOT CMAKE_BUILD_TYPE) 11 | set(CMAKE_BUILD_TYPE debug) 12 | endif() 13 | 14 | 15 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wpedantic -std=gnu11") 16 | if(CMAKE_COMPILER_IS_GNUCC) 17 | # disable strict aliasing in GCC, since it produces false alarams in libev 18 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-strict-aliasing") 19 | endif() 20 | set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O2") 21 | set(CMAKE_C_FLAGS_DEBUG "-g -O0") 22 | 23 | ADD_DEFINITIONS(-D_PROJECT_NAME="${PROJECT_NAME}") 24 | 25 | SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 26 | SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 27 | SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 28 | 29 | SET(CMAKE_INSTALL_PREFIX "/usr") 30 | 31 | set(srcs 32 | src/main.c 33 | ) 34 | 35 | add_executable(${PROJECT_NAME} ${srcs}) 36 | 37 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/") 38 | 39 | # dependencies - sysrepo 40 | find_package(SYSREPO REQUIRED) 41 | target_link_libraries(${PROJECT_NAME} ${SYSREPO_LIBRARIES}) 42 | include_directories(${SYSREPO_INCLUDE_DIRS}) 43 | FIND_PACKAGE(SYSREPO REQUIRED) 44 | 45 | -------------------------------------------------------------------------------- /yang2src/template/C/application/FindSYSREPO.cmake: -------------------------------------------------------------------------------- 1 | # SYSREPO_FOUND - System has SYSREPO 2 | # SYSREPO_INCLUDE_DIRS - The SYSREPO include directories 3 | # SYSREPO_LIBRARIES - The libraries needed to use SYSREPO 4 | # SYSREPO_DEFINITIONS - Compiler switches required for using SYSREPO 5 | 6 | find_package(PkgConfig) 7 | pkg_check_modules(PC_SYSREPO QUIET sysrepo) 8 | set(SYSREPO_DEFINITIONS ${PC_SYSREPO_CFLAGS_OTHER}) 9 | 10 | find_path(SYSREPO_INCLUDE_DIR sysrepo.h 11 | HINTS ${PC_SYSREPO_INCLUDEDIR} ${PC_SYSREPO_INCLUDE_DIRS} 12 | PATH_SUFFIXES sysrepo ) 13 | 14 | find_library(SYSREPO_LIBRARY NAMES sysrepo 15 | HINTS ${PC_SYSREPO_LIBDIR} ${PC_SYSREPO_LIBRARY_DIRS} ) 16 | 17 | set(SYSREPO_LIBRARIES ${SYSREPO_LIBRARY} ) 18 | set(SYSREPO_INCLUDE_DIRS ${SYSREPO_INCLUDE_DIR} ) 19 | 20 | include(FindPackageHandleStandardArgs) 21 | # handle the QUIETLY and REQUIRED arguments and set SYSREPO_FOUND to TRUE 22 | # if all listed variables are TRUE 23 | find_package_handle_standard_args(sysrepo DEFAULT_MSG 24 | SYSREPO_LIBRARY SYSREPO_INCLUDE_DIR) 25 | 26 | mark_as_advanced(SYSREPO_INCLUDE_DIR SYSREPO_LIBRARY ) 27 | -------------------------------------------------------------------------------- /yang2src/template/C/application/README.asciidoc: -------------------------------------------------------------------------------- 1 | = YANG Creator 2 | 3 | To run the program inside docker simply run the bash script run.sh with: 4 | 5 | ---- 6 | bash run.sh 7 | ---- 8 | 9 | This bash script will pull the docker images 'sartura/sysrepo-netopeer2' and 10 | 'sartura/tesconf' which contains and runs programs needed for yang-creator. 11 | When the docker is run it mounts the folder "above", that is, it mounts the 12 | 'sources_code' folder into docker. This enables us to access that folder as 13 | well as edit it and the changes will be viewable in docker. 14 | 15 | When it runs the docker will bind this folder and the folder 16 | '../../ietf-yangs'. After that it will pass the current username and groupname 17 | in order to preserve folder ownership once docker closes. 18 | 19 | The default name of the docker container is sysrepo, it can be set to anything. 20 | 21 | For the entry point it uses the bash script 'entrypoint.sh'. This script 22 | compiles the program if it has not been compiled yet and generates a skeleton 23 | xml file based on the yang model and its default values. 24 | 25 | We can get those values through _testconf_, an utility from the freenetconf 26 | project. To run testconf, run the docker image with the command: 27 | 28 | ---- 29 | docker run -i -t -w /opt/dev/testconf/netconf_client/tests --link sysrepo --rm sartura/testconf:latest bash 30 | ---- 31 | 32 | and once we are in docker we run: 33 | 34 | ---- 35 | node xpath.js "/{{yang_name_short}}://*" 36 | ---- 37 | 38 | If the first container has a different name than sysrepo, update the name in 39 | the docker run command (--link sysrepo) and inside the container run: 40 | 41 | ---- 42 | sed -i "s/config.netconf.host = 'sysrepo'/config.netconf.host = 'new_name'/" ../../core/config.js 43 | ---- 44 | 45 | Video demonstration via asciinema: 46 | 47 | https://asciinema.org/a/46548 48 | 49 | XPath is used for getting values. Learn more about XPath: + 50 | link:http://www.w3schools.com/xsl/xpath_intro.asp[] + 51 | link:https://en.wikipedia.org/wiki/XPath[] + 52 | link:http://www.tutorialspoint.com/xpath/xpath_overview.htm.[] 53 | -------------------------------------------------------------------------------- /yang2src/template/C/application/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # compile program 4 | if [ ! -d "build" ]; then 5 | mkdir build 6 | cd build 7 | cmake .. 8 | make -j2 9 | cd .. 10 | 11 | # perserve folder ownership 12 | useradd -c 'container user' -u $APP_UID -g $APP_G $APP_U 13 | chown -R $APP_U:$APP_G * 14 | fi 15 | 16 | # create skeleton xml file 17 | if [ ! -d "xml" ]; then 18 | mkdir xml 19 | apt-get update 20 | apt-get install libxml2-utils 21 | 22 | pyang -p ../ietf-yang --sample-xml-skeleton-annotations --sample-xml-skeleton-defaults --sample-xml-skeleton-doctype=data yang/{{yang_name_full}} --format sample-xml-skeleton | xmllint --format - > xml/{{yang_name_full}}.data.xml 23 | 24 | # rmove second and last line from the xml 25 | head -n -1 xml/{{yang_name_full}}.data.xml | sed '2d' > xml/tmp.xml 26 | mv xml/tmp.xml xml/{{yang_name_full}}.data.xml 27 | 28 | # perserve folder ownership 29 | useradd -c 'container user' -u $APP_UID -g $APP_G $APP_U 30 | chown -R $APP_U:$APP_G * 31 | fi 32 | 33 | /usr/bin/sysrepoctl --install --yang=yang/{{yang_name_full}} --search-dir ../ietf-yang 34 | /usr/bin/sysrepoctl --import=xml --module={{yang_name_short}} < xml/{{yang_name_full}}.data.xml 35 | 36 | /usr/bin/sysrepod 37 | /usr/bin/netopeer2-server 38 | 39 | ./build/bin/{{yang_name_short}} 40 | -------------------------------------------------------------------------------- /yang2src/template/C/application/main.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file {{yang_name_short}}.c 3 | * @brief Example application that uses sysrepo as the configuraton datastore. 4 | * 5 | * @copyright 6 | * Copyright 2016 Cisco Systems, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | volatile int exit_application = 0; 29 | 30 | static void 31 | print_value(sr_val_t *value) 32 | { 33 | printf("%s ", value->xpath); 34 | 35 | switch (value->type) { 36 | case SR_CONTAINER_T: 37 | case SR_CONTAINER_PRESENCE_T: 38 | printf("(container)\n"); 39 | break; 40 | case SR_LIST_T: 41 | printf("(list instance)\n"); 42 | break; 43 | case SR_STRING_T: 44 | printf("= %s\n", value->data.string_val); 45 | break; 46 | case SR_BOOL_T: 47 | printf("= %s\n", value->data.bool_val ? "true" : "false"); 48 | break; 49 | case SR_UINT8_T: 50 | printf("= %u\n", value->data.uint8_val); 51 | break; 52 | case SR_UINT16_T: 53 | printf("= %u\n", value->data.uint16_val); 54 | break; 55 | case SR_UINT32_T: 56 | printf("= %u\n", value->data.uint32_val); 57 | break; 58 | case SR_IDENTITYREF_T: 59 | printf("= %s\n", value->data.identityref_val); 60 | break; 61 | default: 62 | printf("(unprintable)\n"); 63 | } 64 | } 65 | 66 | static void 67 | print_current_config(sr_session_ctx_t *session) 68 | { 69 | sr_val_t *values = NULL; 70 | size_t count = 0; 71 | int rc = SR_ERR_OK; 72 | 73 | rc = sr_get_items(session, "/{{yang_name_short}}:*//*", &values, &count); 74 | if (SR_ERR_OK != rc) { 75 | printf("Error by sr_get_items: %s", sr_strerror(rc)); 76 | return; 77 | } 78 | for (size_t i = 0; i < count; i++){ 79 | print_value(&values[i]); 80 | } 81 | sr_free_values(values, count); 82 | } 83 | 84 | static void 85 | module_change_cb(sr_session_ctx_t *session, const char *module_name, void *private_ctx) 86 | { 87 | printf("\n\n ========== CONFIG HAS CHANGED, CURRENT RUNNING CONFIG: ==========\n\n"); 88 | print_current_config(session); 89 | } 90 | 91 | static void 92 | sigint_handler(int signum) 93 | { 94 | exit_application = 1; 95 | } 96 | 97 | int 98 | main(int argc, char **argv) 99 | { 100 | sr_conn_ctx_t *connection = NULL; 101 | sr_session_ctx_t *session = NULL; 102 | sr_subscription_ctx_t *subscription = NULL; 103 | int rc = SR_ERR_OK; 104 | 105 | /* connect to sysrepo */ 106 | rc = sr_connect("{{yang_name_short}}", SR_CONN_DEFAULT, &connection); 107 | if (SR_ERR_OK != rc) { 108 | fprintf(stderr, "Error by sr_connect: %s\n", sr_strerror(rc)); 109 | goto cleanup; 110 | } 111 | 112 | /* start session */ 113 | rc = sr_session_start(connection, SR_DS_STARTUP, SR_SESS_DEFAULT, &session); 114 | if (SR_ERR_OK != rc) { 115 | fprintf(stderr, "Error by sr_session_start: %s\n", sr_strerror(rc)); 116 | goto cleanup; 117 | } 118 | 119 | /* read startup config */ 120 | printf("\n\n ========== READING STARTUP CONFIG: ==========\n\n"); 121 | print_current_config(session); 122 | 123 | /* subscribe for changes in running config */ 124 | rc = sr_module_change_subscribe(session, "{{yang_name_short}}", true, module_change_cb, NULL, &subscription); 125 | if (SR_ERR_OK != rc) { 126 | fprintf(stderr, "Error by sr_module_change_subscribe: %s\n", sr_strerror(rc)); 127 | goto cleanup; 128 | } 129 | 130 | printf("\n\n ========== STARTUP CONFIG APPLIED AS RUNNING ==========\n\n"); 131 | 132 | /* loop until ctrl-c is pressed / SIGINT is received */ 133 | signal(SIGINT, sigint_handler); 134 | while (!exit_application) { 135 | sleep(1000); /* or do some more useful work... */ 136 | } 137 | 138 | printf("Application exit requested, exiting.\n"); 139 | 140 | cleanup: 141 | if (NULL != subscription) { 142 | sr_unsubscribe(session, subscription); 143 | } 144 | if (NULL != session) { 145 | sr_session_stop(session); 146 | } 147 | if (NULL != connection) { 148 | sr_disconnect(connection); 149 | } 150 | return rc; 151 | } 152 | 153 | -------------------------------------------------------------------------------- /yang2src/template/C/application/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | user=$USER 4 | group=$( id -g -n ${user}) 5 | id=$( id -u $user) 6 | 7 | parentdir="$(dirname "$(pwd)")" 8 | grandparentdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 9 | 10 | # pull sysrepo 11 | docker pull sartura/sysrepo-netopeer2:latest 12 | 13 | # pull testconf 14 | docker pull sartura/testconf:latest 15 | 16 | docker run -i -t -e APP_U=$user -e APP_G=$group -e APP_UID=$id -v ${parentdir}:${parentdir} -v ${grandparentdir}/ietf-yang:${parentdir}/ietf-yang -w ${PWD} --name {{yang_name_short}} --rm --name sysrepo sartura/sysrepo-netopeer2:latest bash entrypoint.sh 17 | -------------------------------------------------------------------------------- /yang2src/template/C/plugin/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.6) 2 | project({{yang_name_short}} C) 3 | 4 | # check the supported platform 5 | if(NOT UNIX) 6 | message(FATAL_ERROR "Only *nix like systems are supported.") 7 | endif() 8 | 9 | # set default build type if not specified by user 10 | if(NOT CMAKE_BUILD_TYPE) 11 | set(CMAKE_BUILD_TYPE debug) 12 | endif() 13 | 14 | 15 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wpedantic -std=gnu11") 16 | if(CMAKE_COMPILER_IS_GNUCC) 17 | # disable strict aliasing in GCC, since it produces false alarams in libev 18 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-strict-aliasing") 19 | endif() 20 | set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O2") 21 | set(CMAKE_C_FLAGS_DEBUG "-g -O0") 22 | 23 | add_definitions(-D_PROJECT_NAME="${PROJECT_NAME}") 24 | 25 | SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 26 | SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 27 | SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 28 | 29 | set(PLUGINS_DIR "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/sysrepo/plugins/" CACHE PATH "Sysrepo plugins directory.") 30 | 31 | # install plugins directory 32 | install(DIRECTORY DESTINATION ${PLUGINS_DIR}) 33 | 34 | SET(CMAKE_INSTALL_PREFIX "/usr") 35 | 36 | set(srcs 37 | src/main.c 38 | ) 39 | 40 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/") 41 | 42 | # dependencies - sysrepo 43 | find_package(SYSREPO REQUIRED) 44 | 45 | # {{yang_name_short}} plugin 46 | add_library({{yang_name_short}} SHARED ${srcs}) 47 | target_link_libraries({{yang_name_short}} ${SYSREPO_LIBRARIES}) 48 | include_directories(${SYSREPO_INCLUDE_DIRS}) 49 | 50 | install(TARGETS {{yang_name_short}} DESTINATION ${PLUGINS_DIR}) 51 | -------------------------------------------------------------------------------- /yang2src/template/C/plugin/FindSYSREPO.cmake: -------------------------------------------------------------------------------- 1 | # SYSREPO_FOUND - System has SYSREPO 2 | # SYSREPO_INCLUDE_DIRS - The SYSREPO include directories 3 | # SYSREPO_LIBRARIES - The libraries needed to use SYSREPO 4 | # SYSREPO_DEFINITIONS - Compiler switches required for using SYSREPO 5 | 6 | find_package(PkgConfig) 7 | pkg_check_modules(PC_SYSREPO QUIET sysrepo) 8 | set(SYSREPO_DEFINITIONS ${PC_SYSREPO_CFLAGS_OTHER}) 9 | 10 | find_path(SYSREPO_INCLUDE_DIR sysrepo.h 11 | HINTS ${PC_SYSREPO_INCLUDEDIR} ${PC_SYSREPO_INCLUDE_DIRS} 12 | PATH_SUFFIXES sysrepo ) 13 | 14 | find_library(SYSREPO_LIBRARY NAMES sysrepo 15 | HINTS ${PC_SYSREPO_LIBDIR} ${PC_SYSREPO_LIBRARY_DIRS} ) 16 | 17 | set(SYSREPO_LIBRARIES ${SYSREPO_LIBRARY} ) 18 | set(SYSREPO_INCLUDE_DIRS ${SYSREPO_INCLUDE_DIR} ) 19 | 20 | include(FindPackageHandleStandardArgs) 21 | # handle the QUIETLY and REQUIRED arguments and set SYSREPO_FOUND to TRUE 22 | # if all listed variables are TRUE 23 | find_package_handle_standard_args(sysrepo DEFAULT_MSG 24 | SYSREPO_LIBRARY SYSREPO_INCLUDE_DIR) 25 | 26 | mark_as_advanced(SYSREPO_INCLUDE_DIR SYSREPO_LIBRARY ) 27 | -------------------------------------------------------------------------------- /yang2src/template/C/plugin/README.asciidoc: -------------------------------------------------------------------------------- 1 | = YANG Creator 2 | 3 | To run the program inside docker simply run the bash script run.sh with: 4 | 5 | ---- 6 | bash run.sh 7 | ---- 8 | 9 | This bash script will pull the docker images 'sartura/sysrepo-netopeer2' and 10 | 'sartura/tesconf' which contains and runs programs needed for yang-creator. 11 | When the docker is run it mounts the folder "above", that is, it mounts the 12 | 'sources_code' folder into docker. This enables us to access that folder as 13 | well as edit it and the changes will be viewable in docker. 14 | 15 | When it runs the docker will bind this folder and the folder 16 | '../../ietf-yangs'. After that it will pass the current username and groupname 17 | in order to preserve folder ownership once docker closes. 18 | 19 | The default name of the docker container is sysrepo, it can be set to anything. 20 | 21 | For the entry point it uses the bash script 'entrypoint.sh'. This script 22 | compiles the program if it has not been compiled yet and generates a skeleton 23 | xml file based on the yang model and its default values. 24 | 25 | We can get those values through _testconf_, an utility from the freenetconf 26 | project. To run testconf, run the docker image with the command: 27 | 28 | ---- 29 | docker run -i -t -w /opt/dev/testconf/netconf_client/tests --link sysrepo --rm sartura/testconf:latest bash 30 | ---- 31 | 32 | and once we are in docker we run: 33 | 34 | ---- 35 | node xpath.js "/{{yang_name_short}}://*" 36 | ---- 37 | 38 | If the first container has a different name than sysrepo, update the name in 39 | the docker run command (--link sysrepo) and inside the container run: 40 | 41 | ---- 42 | sed -i "s/config.netconf.host = 'sysrepo'/config.netconf.host = 'new_name'/" ../../core/config.js 43 | ---- 44 | 45 | Video demonstration via asciinema: 46 | 47 | https://asciinema.org/a/46549 48 | 49 | XPath is used for getting values. Learn more about XPath: + 50 | link:http://www.w3schools.com/xsl/xpath_intro.asp[] + 51 | link:https://en.wikipedia.org/wiki/XPath[] + 52 | link:http://www.tutorialspoint.com/xpath/xpath_overview.htm.[] 53 | -------------------------------------------------------------------------------- /yang2src/template/C/plugin/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # compile program 4 | if [ ! -d "build" ]; then 5 | mkdir build 6 | cd build 7 | cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr/lib .. 8 | make -j2 9 | cd .. 10 | 11 | # perserve folder ownership 12 | useradd -c 'container user' -u $APP_UID -g $APP_G $APP_U 13 | chown -R $APP_U:$APP_G * 14 | fi 15 | 16 | # create skeleton xml file 17 | if [ ! -d "xml" ]; then 18 | mkdir xml 19 | apt-get update 20 | apt-get install libxml2-utils 21 | 22 | pyang -p ../ietf-yang --sample-xml-skeleton-annotations --sample-xml-skeleton-defaults --sample-xml-skeleton-doctype=data yang/{{yang_name_full}} --format sample-xml-skeleton | xmllint --format - > xml/{{yang_name_full}}.data.xml 23 | 24 | # rmove second and last line from the xml 25 | head -n -1 xml/{{yang_name_full}}.data.xml | sed '2d' > xml/tmp.xml 26 | mv xml/tmp.xml xml/{{yang_name_full}}.data.xml 27 | 28 | # perserve folder ownership 29 | useradd -c 'container user' -u $APP_UID -g $APP_G $APP_U 30 | chown -R $APP_U:$APP_G * 31 | fi 32 | 33 | cd build 34 | make install 35 | cd .. 36 | 37 | /usr/bin/sysrepoctl --install --yang=yang/{{yang_name_full}} --search-dir ../ietf-yang 38 | /usr/bin/sysrepoctl --import=xml --module={{yang_name_short}} < xml/{{yang_name_full}}.data.xml 39 | 40 | /usr/bin/sysrepo-plugind 41 | /usr/bin/netopeer2-server -d 42 | -------------------------------------------------------------------------------- /yang2src/template/C/plugin/main.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file {{yang_name_short}}.c 3 | * @brief Example plugin for sysrepo datastore - {{yang_name_short}}. 4 | * 5 | * @copyright 6 | * Copyright 2016 Cisco Systems, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | /* logging macro for unformatted messages */ 26 | #define log_msg(MSG) \ 27 | do { \ 28 | fprintf(stderr, MSG "\n"); \ 29 | syslog(LOG_INFO, MSG); \ 30 | } while(0) 31 | 32 | /* logging macro for formatted messages */ 33 | #define log_fmt(MSG, ...) \ 34 | do { \ 35 | fprintf(stderr, MSG "\n", __VA_ARGS__); \ 36 | syslog(LOG_INFO, MSG, __VA_ARGS__); \ 37 | } while(0) 38 | 39 | /* prints one value retrieved from sysrepo */ 40 | static void 41 | print_value(sr_val_t *value) 42 | { 43 | switch (value->type) { 44 | case SR_CONTAINER_T: 45 | case SR_CONTAINER_PRESENCE_T: 46 | case SR_LIST_T: 47 | /* do not print */ 48 | break; 49 | case SR_STRING_T: 50 | log_fmt("%s = '%s'", value->xpath, value->data.string_val); 51 | break; 52 | case SR_BOOL_T: 53 | log_fmt("%s = %s", value->xpath, value->data.bool_val ? "true" : "false"); 54 | break; 55 | case SR_UINT8_T: 56 | log_fmt("%s = %u", value->xpath, value->data.uint8_val); 57 | break; 58 | case SR_UINT16_T: 59 | log_fmt("%s = %u", value->xpath, value->data.uint16_val); 60 | break; 61 | case SR_UINT32_T: 62 | log_fmt("%s = %u", value->xpath, value->data.uint32_val); 63 | break; 64 | case SR_IDENTITYREF_T: 65 | log_fmt("%s = %s", value->xpath, value->data.identityref_val); 66 | break; 67 | case SR_ENUM_T: 68 | log_fmt("%s = %s", value->xpath, value->data.enum_val); 69 | break; 70 | default: 71 | log_fmt("%s (unprintable)", value->xpath); 72 | } 73 | } 74 | 75 | /* retrieves & prints current {{yang_name_short}} configuration */ 76 | static void 77 | retrieve_current_config(sr_session_ctx_t *session) 78 | { 79 | sr_val_t *values = NULL; 80 | size_t count = 0; 81 | int rc = SR_ERR_OK; 82 | 83 | log_msg("current {{yang_name_short}} configuration:"); 84 | 85 | rc = sr_get_items(session, "/{{yang_name_short}}:*//*", &values, &count); 86 | if (SR_ERR_OK != rc) { 87 | printf("Error by sr_get_items: %s", sr_strerror(rc)); 88 | return; 89 | } 90 | for (size_t i = 0; i < count; i++){ 91 | print_value(&values[i]); 92 | } 93 | sr_free_values(values, count); 94 | } 95 | 96 | static void 97 | module_change_cb(sr_session_ctx_t *session, const char *module_name, void *private_ctx) 98 | { 99 | log_msg("{{yang_name_short}} configuration has changed"); 100 | retrieve_current_config(session); 101 | } 102 | 103 | static int 104 | rpc_initialize_cb(const char *xpath, const sr_val_t *input, const size_t input_cnt, 105 | sr_val_t **output, size_t *output_cnt, void *private_ctx) 106 | { 107 | log_msg("{{yang_name_short}} 'initialize' RPC called"); 108 | 109 | if (input_cnt > 0) { 110 | log_fmt("{{yang_name_short}} tape content: %s", input[0].data.string_val); 111 | } 112 | 113 | return SR_ERR_OK; 114 | } 115 | 116 | static int 117 | rpc_run_cb(const char *xpath, const sr_val_t *input, const size_t input_cnt, 118 | sr_val_t **output, size_t *output_cnt, void *private_ctx) 119 | { 120 | log_msg("{{yang_name_short}} 'run' RPC called"); 121 | 122 | return SR_ERR_OK; 123 | } 124 | 125 | int 126 | sr_plugin_init_cb(sr_session_ctx_t *session, void **private_ctx) 127 | { 128 | sr_subscription_ctx_t *subscription = NULL; 129 | int rc = SR_ERR_OK; 130 | 131 | rc = sr_module_change_subscribe(session, "{{yang_name_short}}", true, module_change_cb, NULL, &subscription); 132 | if (SR_ERR_OK != rc) { 133 | goto error; 134 | } 135 | 136 | rc = sr_rpc_subscribe(session, "/{{yang_name_short}}:initialize", rpc_initialize_cb, NULL, &subscription); 137 | if (SR_ERR_OK != rc) { 138 | goto error; 139 | } 140 | 141 | rc = sr_rpc_subscribe(session, "/{{yang_name_short}}:run", rpc_run_cb, NULL, &subscription); 142 | if (SR_ERR_OK != rc) { 143 | goto error; 144 | } 145 | 146 | log_msg("{{yang_name_short}} plugin initialized successfully"); 147 | 148 | retrieve_current_config(session); 149 | 150 | /* set subscription as our private context */ 151 | *private_ctx = subscription; 152 | 153 | return SR_ERR_OK; 154 | 155 | error: 156 | log_fmt("{{yang_name_short}} plugin initialization failed: %s", sr_strerror(rc)); 157 | sr_unsubscribe(session, subscription); 158 | return rc; 159 | } 160 | 161 | void 162 | sr_plugin_cleanup_cb(sr_session_ctx_t *session, void *private_ctx) 163 | { 164 | /* subscription was set as our private context */ 165 | sr_unsubscribe(session, private_ctx); 166 | 167 | log_msg("{{yang_name_short}} plugin cleanup finished"); 168 | } 169 | -------------------------------------------------------------------------------- /yang2src/template/C/plugin/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | user=$USER 4 | group=$( id -g -n ${user}) 5 | id=$( id -u $user) 6 | 7 | parentdir="$(dirname "$(pwd)")" 8 | grandparentdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 9 | 10 | # pull sysrepo 11 | docker pull sartura/sysrepo-netopeer2:latest 12 | 13 | # pull testconf 14 | docker pull sartura/testconf:latest 15 | 16 | docker run -i -t -e APP_U=$user -e APP_G=$group -e APP_UID=$id -v ${parentdir}:${parentdir} -v ${grandparentdir}/ietf-yang:${parentdir}/ietf-yang -w ${PWD} --name {{yang_name_short}} --rm --name sysrepo sartura/sysrepo-netopeer2:latest bash entrypoint.sh 17 | --------------------------------------------------------------------------------