diff options
8 files changed, 797 insertions, 0 deletions
diff --git a/meta-networking/recipes-protocols/freediameter/files/Replace-murmurhash-algorithm-with-Robert-Jenkin-s-ha.patch b/meta-networking/recipes-protocols/freediameter/files/Replace-murmurhash-algorithm-with-Robert-Jenkin-s-ha.patch new file mode 100644 index 0000000000..71a5a1ae44 --- /dev/null +++ b/meta-networking/recipes-protocols/freediameter/files/Replace-murmurhash-algorithm-with-Robert-Jenkin-s-ha.patch | |||
| @@ -0,0 +1,223 @@ | |||
| 1 | Replace murmurhash algorithm with Robert Jenkin's hash algorithm | ||
| 2 | |||
| 3 | Upstream-Status: Pending | ||
| 4 | |||
| 5 | From test result, murmurhash algorithm does not work in big endian | ||
| 6 | processor, so replace it with Robert Jenkin's hash which has worked | ||
| 7 | in linux kernel for many years and has more adaptability. | ||
| 8 | |||
| 9 | Signed-off-by: Roy.Li <rongqing.li@windriver.com> | ||
| 10 | --- | ||
| 11 | libfdproto/ostr.c | 192 +++++++++++++++++++++-------------------------------- | ||
| 12 | 1 file changed, 74 insertions(+), 118 deletions(-) | ||
| 13 | |||
| 14 | diff --git a/libfdproto/ostr.c b/libfdproto/ostr.c | ||
| 15 | index 8f29b48..ce1f4dd 100644 | ||
| 16 | --- a/libfdproto/ostr.c | ||
| 17 | +++ b/libfdproto/ostr.c | ||
| 18 | @@ -430,128 +430,84 @@ after_proto: | ||
| 19 | |||
| 20 | |||
| 21 | /********************************************************************************************************/ | ||
| 22 | -/* Hash function -- credits to Austin Appleby, thank you ^^ */ | ||
| 23 | -/* See http://murmurhash.googlepages.com for more information on this function */ | ||
| 24 | - | ||
| 25 | -/* the strings are NOT always aligned properly (ex: received in RADIUS message), so we use the aligned MurmurHash2 function as needed */ | ||
| 26 | -#define _HASH_MIX(h,k,m) { k *= m; k ^= k >> r; k *= m; h *= m; h ^= k; } | ||
| 27 | -uint32_t fd_os_hash ( uint8_t * string, size_t len ) | ||
| 28 | +/* | ||
| 29 | + * Robert Jenkin's hash function. | ||
| 30 | + * http://burtleburtle.net/bob/hash/evahash.html | ||
| 31 | + * This is in the public domain. | ||
| 32 | + */ | ||
| 33 | +#define mix(a, b, c) \ | ||
| 34 | + do { \ | ||
| 35 | + a = a - b; a = a - c; a = a ^ (c >> 13); \ | ||
| 36 | + b = b - c; b = b - a; b = b ^ (a << 8); \ | ||
| 37 | + c = c - a; c = c - b; c = c ^ (b >> 13); \ | ||
| 38 | + a = a - b; a = a - c; a = a ^ (c >> 12); \ | ||
| 39 | + b = b - c; b = b - a; b = b ^ (a << 16); \ | ||
| 40 | + c = c - a; c = c - b; c = c ^ (b >> 5); \ | ||
| 41 | + a = a - b; a = a - c; a = a ^ (c >> 3); \ | ||
| 42 | + b = b - c; b = b - a; b = b ^ (a << 10); \ | ||
| 43 | + c = c - a; c = c - b; c = c ^ (b >> 15); \ | ||
| 44 | + } while (0) | ||
| 45 | + | ||
| 46 | +unsigned hash_rjenkins(const char *str, unsigned length) | ||
| 47 | { | ||
| 48 | - uint32_t hash = len; | ||
| 49 | - uint8_t * data = string; | ||
| 50 | - | ||
| 51 | - const unsigned int m = 0x5bd1e995; | ||
| 52 | - const int r = 24; | ||
| 53 | - int align = (long)string & 3; | ||
| 54 | - | ||
| 55 | - if (!align || (len < 4)) { | ||
| 56 | - /* In case data is aligned, MurmurHash2 function */ | ||
| 57 | - while(len >= 4) | ||
| 58 | - { | ||
| 59 | - /* Mix 4 bytes at a time into the hash */ | ||
| 60 | - uint32_t k = *(uint32_t *)data; /* We don't care about the byte order */ | ||
| 61 | - | ||
| 62 | - _HASH_MIX(hash, k, m); | ||
| 63 | - | ||
| 64 | - data += 4; | ||
| 65 | - len -= 4; | ||
| 66 | - } | ||
| 67 | - | ||
| 68 | - /* Handle the last few bytes of the input */ | ||
| 69 | - switch(len) { | ||
| 70 | - case 3: hash ^= data[2] << 16; | ||
| 71 | - case 2: hash ^= data[1] << 8; | ||
| 72 | - case 1: hash ^= data[0]; | ||
| 73 | - hash *= m; | ||
| 74 | - } | ||
| 75 | - | ||
| 76 | - } else { | ||
| 77 | - /* Unaligned data, use alignment-safe slower version */ | ||
| 78 | - | ||
| 79 | - /* Pre-load the temp registers */ | ||
| 80 | - uint32_t t = 0, d = 0; | ||
| 81 | - switch(align) | ||
| 82 | - { | ||
| 83 | - case 1: t |= data[2] << 16; | ||
| 84 | - case 2: t |= data[1] << 8; | ||
| 85 | - case 3: t |= data[0]; | ||
| 86 | - } | ||
| 87 | - t <<= (8 * align); | ||
| 88 | - | ||
| 89 | - data += 4-align; | ||
| 90 | - len -= 4-align; | ||
| 91 | - | ||
| 92 | - /* From this point, "data" can be read by chunks of 4 bytes */ | ||
| 93 | - | ||
| 94 | - int sl = 8 * (4-align); | ||
| 95 | - int sr = 8 * align; | ||
| 96 | - | ||
| 97 | - /* Mix */ | ||
| 98 | - while(len >= 4) | ||
| 99 | - { | ||
| 100 | - uint32_t k; | ||
| 101 | - | ||
| 102 | - d = *(unsigned int *)data; | ||
| 103 | - k = (t >> sr) | (d << sl); | ||
| 104 | - | ||
| 105 | - _HASH_MIX(hash, k, m); | ||
| 106 | - | ||
| 107 | - t = d; | ||
| 108 | - | ||
| 109 | - data += 4; | ||
| 110 | - len -= 4; | ||
| 111 | - } | ||
| 112 | - | ||
| 113 | - /* Handle leftover data in temp registers */ | ||
| 114 | - d = 0; | ||
| 115 | - if(len >= align) | ||
| 116 | - { | ||
| 117 | - uint32_t k; | ||
| 118 | - | ||
| 119 | - switch(align) | ||
| 120 | - { | ||
| 121 | - case 3: d |= data[2] << 16; | ||
| 122 | - case 2: d |= data[1] << 8; | ||
| 123 | - case 1: d |= data[0]; | ||
| 124 | - } | ||
| 125 | - | ||
| 126 | - k = (t >> sr) | (d << sl); | ||
| 127 | - _HASH_MIX(hash, k, m); | ||
| 128 | - | ||
| 129 | - data += align; | ||
| 130 | - len -= align; | ||
| 131 | - | ||
| 132 | - /* Handle tail bytes */ | ||
| 133 | - | ||
| 134 | - switch(len) | ||
| 135 | - { | ||
| 136 | - case 3: hash ^= data[2] << 16; | ||
| 137 | - case 2: hash ^= data[1] << 8; | ||
| 138 | - case 1: hash ^= data[0]; | ||
| 139 | - hash *= m; | ||
| 140 | - }; | ||
| 141 | - } | ||
| 142 | - else | ||
| 143 | - { | ||
| 144 | - switch(len) | ||
| 145 | - { | ||
| 146 | - case 3: d |= data[2] << 16; | ||
| 147 | - case 2: d |= data[1] << 8; | ||
| 148 | - case 1: d |= data[0]; | ||
| 149 | - case 0: hash ^= (t >> sr) | (d << sl); | ||
| 150 | - hash *= m; | ||
| 151 | - } | ||
| 152 | - } | ||
| 153 | - | ||
| 154 | + const unsigned char *k = (const unsigned char *)str; | ||
| 155 | + uint32_t a, b, c; /* the internal state */ | ||
| 156 | + uint32_t len; /* how many key bytes still need mixing */ | ||
| 157 | + | ||
| 158 | + /* Set up the internal state */ | ||
| 159 | + len = length; | ||
| 160 | + a = 0x9e3779b9; /* the golden ratio; an arbitrary value */ | ||
| 161 | + b = a; | ||
| 162 | + c = 0; /* variable initialization of internal state */ | ||
| 163 | + | ||
| 164 | + /* handle most of the key */ | ||
| 165 | + while (len >= 12) { | ||
| 166 | + a = a + (k[0] + ((uint32_t)k[1] << 8) + ((uint32_t)k[2] << 16) + | ||
| 167 | + ((uint32_t)k[3] << 24)); | ||
| 168 | + b = b + (k[4] + ((uint32_t)k[5] << 8) + ((uint32_t)k[6] << 16) + | ||
| 169 | + ((uint32_t)k[7] << 24)); | ||
| 170 | + c = c + (k[8] + ((uint32_t)k[9] << 8) + ((uint32_t)k[10] << 16) + | ||
| 171 | + ((uint32_t)k[11] << 24)); | ||
| 172 | + mix(a, b, c); | ||
| 173 | + k = k + 12; | ||
| 174 | + len = len - 12; | ||
| 175 | + } | ||
| 176 | |||
| 177 | + /* handle the last 11 bytes */ | ||
| 178 | + c = c + length; | ||
| 179 | + switch (len) { /* all the case statements fall through */ | ||
| 180 | + case 11: | ||
| 181 | + c = c + ((uint32_t)k[10] << 24); | ||
| 182 | + case 10: | ||
| 183 | + c = c + ((uint32_t)k[9] << 16); | ||
| 184 | + case 9: | ||
| 185 | + c = c + ((uint32_t)k[8] << 8); | ||
| 186 | + /* the first byte of c is reserved for the length */ | ||
| 187 | + case 8: | ||
| 188 | + b = b + ((uint32_t)k[7] << 24); | ||
| 189 | + case 7: | ||
| 190 | + b = b + ((uint32_t)k[6] << 16); | ||
| 191 | + case 6: | ||
| 192 | + b = b + ((uint32_t)k[5] << 8); | ||
| 193 | + case 5: | ||
| 194 | + b = b + k[4]; | ||
| 195 | + case 4: | ||
| 196 | + a = a + ((uint32_t)k[3] << 24); | ||
| 197 | + case 3: | ||
| 198 | + a = a + ((uint32_t)k[2] << 16); | ||
| 199 | + case 2: | ||
| 200 | + a = a + ((uint32_t)k[1] << 8); | ||
| 201 | + case 1: | ||
| 202 | + a = a + k[0]; | ||
| 203 | + /* case 0: nothing left to add */ | ||
| 204 | } | ||
| 205 | + mix(a, b, c); | ||
| 206 | |||
| 207 | - /* Do a few final mixes of the hash to ensure the last few | ||
| 208 | - bytes are well-incorporated. */ | ||
| 209 | - hash ^= hash >> 13; | ||
| 210 | - hash *= m; | ||
| 211 | - hash ^= hash >> 15; | ||
| 212 | + return c; | ||
| 213 | +} | ||
| 214 | |||
| 215 | - return hash; | ||
| 216 | +uint32_t fd_os_hash ( uint8_t * string, size_t len ) | ||
| 217 | +{ | ||
| 218 | + return hash_rjenkins(string, len); | ||
| 219 | } | ||
| 220 | |||
| 221 | -- | ||
| 222 | 1.7.10.4 | ||
| 223 | |||
diff --git a/meta-networking/recipes-protocols/freediameter/files/freeDiameter.conf b/meta-networking/recipes-protocols/freediameter/files/freeDiameter.conf new file mode 100644 index 0000000000..7b56d748a0 --- /dev/null +++ b/meta-networking/recipes-protocols/freediameter/files/freeDiameter.conf | |||
| @@ -0,0 +1,250 @@ | |||
| 1 | # This is a sample configuration file for freeDiameter daemon. | ||
| 2 | |||
| 3 | # Most of the options can be omitted, as they default to reasonable values. | ||
| 4 | # Only TLS-related options must be configured properly in usual setups. | ||
| 5 | |||
| 6 | # It is possible to use "include" keyword to import additional files | ||
| 7 | # e.g.: include "/etc/freeDiameter.d/*.conf" | ||
| 8 | # This is exactly equivalent as copy & paste the content of the included file(s) | ||
| 9 | # where the "include" keyword is found. | ||
| 10 | |||
| 11 | |||
| 12 | ############################################################## | ||
| 13 | ## Peer identity and realm | ||
| 14 | |||
| 15 | # The Diameter Identity of this daemon. | ||
| 16 | # This must be a valid FQDN that resolves to the local host. | ||
| 17 | # Default: hostname's FQDN | ||
| 18 | #Identity = "aaa.koganei.freediameter.net"; | ||
| 19 | |||
| 20 | # The Diameter Realm of this daemon. | ||
| 21 | # Default: the domain part of Identity (after the first dot). | ||
| 22 | #Realm = "koganei.freediameter.net"; | ||
| 23 | |||
| 24 | ############################################################## | ||
| 25 | ## Transport protocol configuration | ||
| 26 | |||
| 27 | # The port this peer is listening on for incoming connections (TCP and SCTP). | ||
| 28 | # Default: 3868. Use 0 to disable. | ||
| 29 | #Port = 3868; | ||
| 30 | |||
| 31 | # The port this peer is listening on for incoming TLS-protected connections (TCP and SCTP). | ||
| 32 | # See TLS_old_method for more information about TLS flavours. | ||
| 33 | # Note: we use TLS/SCTP instead of DTLS/SCTP at the moment. This will change in future version of freeDiameter. | ||
| 34 | # Default: 5868. Use 0 to disable. | ||
| 35 | #SecPort = 5868; | ||
| 36 | |||
| 37 | # Use RFC3588 method for TLS protection, where TLS is negociated after CER/CEA exchange is completed | ||
| 38 | # on the unsecure connection. The alternative is RFC6733 mechanism, where TLS protects also the | ||
| 39 | # CER/CEA exchange on a dedicated secure port. | ||
| 40 | # This parameter only affects outgoing connections. | ||
| 41 | # The setting can be also defined per-peer (see Peers configuration section). | ||
| 42 | # Default: use RFC6733 method with separate port for TLS. | ||
| 43 | #TLS_old_method; | ||
| 44 | |||
| 45 | # Disable use of TCP protocol (only listen and connect over SCTP) | ||
| 46 | # Default : TCP enabled | ||
| 47 | #No_TCP; | ||
| 48 | |||
| 49 | # Disable use of SCTP protocol (only listen and connect over TCP) | ||
| 50 | # Default : SCTP enabled | ||
| 51 | #No_SCTP; | ||
| 52 | # This option is ignored if freeDiameter is compiled with DISABLE_SCTP option. | ||
| 53 | |||
| 54 | # Prefer TCP instead of SCTP for establishing new connections. | ||
| 55 | # This setting may be overwritten per peer in peer configuration blocs. | ||
| 56 | # Default : SCTP is attempted first. | ||
| 57 | #Prefer_TCP; | ||
| 58 | |||
| 59 | # Default number of streams per SCTP associations. | ||
| 60 | # This setting may be overwritten per peer basis. | ||
| 61 | # Default : 30 streams | ||
| 62 | #SCTP_streams = 30; | ||
| 63 | |||
| 64 | ############################################################## | ||
| 65 | ## Endpoint configuration | ||
| 66 | |||
| 67 | # Disable use of IP addresses (only IPv6) | ||
| 68 | # Default : IP enabled | ||
| 69 | #No_IP; | ||
| 70 | |||
| 71 | # Disable use of IPv6 addresses (only IP) | ||
| 72 | # Default : IPv6 enabled | ||
| 73 | #No_IPv6; | ||
| 74 | |||
| 75 | # Specify local addresses the server must bind to | ||
| 76 | # Default : listen on all addresses available. | ||
| 77 | #ListenOn = "202.249.37.5"; | ||
| 78 | #ListenOn = "2001:200:903:2::202:1"; | ||
| 79 | #ListenOn = "fe80::21c:5ff:fe98:7d62%eth0"; | ||
| 80 | |||
| 81 | |||
| 82 | ############################################################## | ||
| 83 | ## Server configuration | ||
| 84 | |||
| 85 | # How many Diameter peers are allowed to be connecting at the same time ? | ||
| 86 | # This parameter limits the number of incoming connections from the time | ||
| 87 | # the connection is accepted until the first CER is received. | ||
| 88 | # Default: 5 unidentified clients in paralel. | ||
| 89 | #ThreadsPerServer = 5; | ||
| 90 | |||
| 91 | ############################################################## | ||
| 92 | ## TLS Configuration | ||
| 93 | |||
| 94 | # TLS is managed by the GNUTLS library in the freeDiameter daemon. | ||
| 95 | # You may find more information about parameters and special behaviors | ||
| 96 | # in the relevant documentation. | ||
| 97 | # http://www.gnu.org/software/gnutls/manual/ | ||
| 98 | |||
| 99 | # Credentials of the local peer | ||
| 100 | # The X509 certificate and private key file to use for the local peer. | ||
| 101 | # The files must contain PKCS-1 encoded RSA key, in PEM format. | ||
| 102 | # (These parameters are passed to gnutls_certificate_set_x509_key_file function) | ||
| 103 | # Default : NO DEFAULT | ||
| 104 | #TLS_Cred = "<x509 certif file.PEM>" , "<x509 private key file.PEM>"; | ||
| 105 | #TLS_Cred = "/etc/ssl/certs/freeDiameter.pem", "/etc/ssl/private/freeDiameter.key"; | ||
| 106 | |||
| 107 | # Certificate authority / trust anchors | ||
| 108 | # The file containing the list of trusted Certificate Authorities (PEM list) | ||
| 109 | # (This parameter is passed to gnutls_certificate_set_x509_trust_file function) | ||
| 110 | # The directive can appear several times to specify several files. | ||
| 111 | # Default : GNUTLS default behavior | ||
| 112 | #TLS_CA = "<file.PEM>"; | ||
| 113 | |||
| 114 | # Certificate Revocation List file | ||
| 115 | # The information about revoked certificates. | ||
| 116 | # The file contains a list of trusted CRLs in PEM format. They should have been verified before. | ||
| 117 | # (This parameter is passed to gnutls_certificate_set_x509_crl_file function) | ||
| 118 | # Note: openssl CRL format might have interoperability issue with GNUTLS format. | ||
| 119 | # Default : GNUTLS default behavior | ||
| 120 | #TLS_CRL = "<file.PEM>"; | ||
| 121 | |||
| 122 | # GNU TLS Priority string | ||
| 123 | # This string allows to configure the behavior of GNUTLS key exchanges | ||
| 124 | # algorithms. See gnutls_priority_init function documentation for information. | ||
| 125 | # You should also refer to the Diameter required TLS support here: | ||
| 126 | # http://tools.ietf.org/html/rfc6733#section-13.1 | ||
| 127 | # Default : "NORMAL" | ||
| 128 | # Example: TLS_Prio = "NONE:+VERS-TLS1.1:+AES-128-CBC:+RSA:+SHA1:+COMP-NULL"; | ||
| 129 | #TLS_Prio = "NORMAL"; | ||
| 130 | |||
| 131 | # Diffie-Hellman parameters size | ||
| 132 | # Set the number of bits for generated DH parameters | ||
| 133 | # Valid value should be 768, 1024, 2048, 3072 or 4096. | ||
| 134 | # (This parameter is passed to gnutls_dh_params_generate2 function, | ||
| 135 | # it usually should match RSA key size) | ||
| 136 | # Default : 1024 | ||
| 137 | #TLS_DH_Bits = 1024; | ||
| 138 | |||
| 139 | # Alternatively, you can specify a file to load the PKCS#3 encoded | ||
| 140 | # DH parameters directly from. This accelerates the daemon start | ||
| 141 | # but is slightly less secure. If this file is provided, the | ||
| 142 | # TLS_DH_Bits parameters has no effect. | ||
| 143 | # Default : no default. | ||
| 144 | #TLS_DH_File = "<file.PEM>"; | ||
| 145 | |||
| 146 | |||
| 147 | ############################################################## | ||
| 148 | ## Timers configuration | ||
| 149 | |||
| 150 | # The Tc timer of this peer. | ||
| 151 | # It is the delay before a new attempt is made to reconnect a disconnected peer. | ||
| 152 | # The value is expressed in seconds. The recommended value is 30 seconds. | ||
| 153 | # Default: 30 | ||
| 154 | #TcTimer = 30; | ||
| 155 | |||
| 156 | # The Tw timer of this peer. | ||
| 157 | # It is the delay before a watchdog message is sent, as described in RFC 3539. | ||
| 158 | # The value is expressed in seconds. The default value is 30 seconds. Value must | ||
| 159 | # be greater or equal to 6 seconds. See details in the RFC. | ||
| 160 | # Default: 30 | ||
| 161 | #TwTimer = 30; | ||
| 162 | |||
| 163 | ############################################################## | ||
| 164 | ## Applications configuration | ||
| 165 | |||
| 166 | # Disable the relaying of Diameter messages? | ||
| 167 | # For messages not handled locally, the default behavior is to forward the | ||
| 168 | # message to another peer if any is available, according to the routing | ||
| 169 | # algorithms. In addition the "0xffffff" application is advertised in CER/CEA | ||
| 170 | # exchanges. | ||
| 171 | # Default: Relaying is enabled. | ||
| 172 | #NoRelay; | ||
| 173 | |||
| 174 | # Number of server threads that can handle incoming messages at the same time. | ||
| 175 | # Default: 4 | ||
| 176 | #AppServThreads = 4; | ||
| 177 | |||
| 178 | # Other applications are configured by loaded extensions. | ||
| 179 | |||
| 180 | ############################################################## | ||
| 181 | ## Extensions configuration | ||
| 182 | |||
| 183 | # The freeDiameter framework merely provides support for | ||
| 184 | # Diameter Base Protocol. The specific application behaviors, | ||
| 185 | # as well as advanced functions, are provided | ||
| 186 | # by loadable extensions (plug-ins). | ||
| 187 | # These extensions may in addition receive the name of a | ||
| 188 | # configuration file, the format of which is extension-specific. | ||
| 189 | # | ||
| 190 | # Format: | ||
| 191 | #LoadExtension = "/path/to/extension" [ : "/optional/configuration/file" ] ; | ||
| 192 | # | ||
| 193 | # Examples: | ||
| 194 | #LoadExtension = "extensions/sample.fdx"; | ||
| 195 | #LoadExtension = "extensions/sample.fdx":"conf/sample.conf"; | ||
| 196 | |||
| 197 | # Extensions are named as follow: | ||
| 198 | # dict_* for extensions that add content to the dictionary definitions. | ||
| 199 | # dbg_* for extensions useful only to retrieve more information on the framework execution. | ||
| 200 | # acl_* : Access control list, to control which peers are allowed to connect. | ||
| 201 | # rt_* : routing extensions that impact how messages are forwarded to other peers. | ||
| 202 | # app_* : applications, these extensions usually register callbacks to handle specific messages. | ||
| 203 | # test_* : dummy extensions that are useful only in testing environments. | ||
| 204 | |||
| 205 | |||
| 206 | # The dbg_msg_dump.fdx extension allows you to tweak the way freeDiameter displays some | ||
| 207 | # information about some events. This extension does not actually use a configuration file | ||
| 208 | # but receives directly a parameter in the string passed to the extension. Here are some examples: | ||
| 209 | ## LoadExtension = "dbg_msg_dumps.fdx" : "0x1111"; # Removes all default hooks, very quiet even in case of errors. | ||
| 210 | ## LoadExtension = "dbg_msg_dumps.fdx" : "0x2222"; # Display all events with few details. | ||
| 211 | ## LoadExtension = "dbg_msg_dumps.fdx" : "0x0080"; # Dump complete information about sent and received messages. | ||
| 212 | # The four digits respectively control: connections, routing decisions, sent/received messages, errors. | ||
| 213 | # The values for each digit are: | ||
| 214 | # 0 - default - keep the default behavior | ||
| 215 | # 1 - quiet - remove any specific log | ||
| 216 | # 2 - compact - display only a summary of the information | ||
| 217 | # 4 - full - display the complete information on a single long line | ||
| 218 | # 8 - tree - display the complete information in an easier to read format spanning several lines. | ||
| 219 | |||
| 220 | |||
| 221 | ############################################################## | ||
| 222 | ## Peers configuration | ||
| 223 | |||
| 224 | # The local server listens for incoming connections. By default, | ||
| 225 | # all unknown connecting peers are rejected. Extensions can override this behavior (e.g., acl_wl). | ||
| 226 | # | ||
| 227 | # In addition to incoming connections, the local peer can | ||
| 228 | # be configured to establish and maintain connections to some | ||
| 229 | # Diameter nodes and allow connections from these nodes. | ||
| 230 | # This is achieved with the ConnectPeer directive described below. | ||
| 231 | # | ||
| 232 | # Note that the configured Diameter Identity MUST match | ||
| 233 | # the information received inside CEA, or the connection will be aborted. | ||
| 234 | # | ||
| 235 | # Format: | ||
| 236 | #ConnectPeer = "diameterid" [ { parameter1; parameter2; ...} ] ; | ||
| 237 | # Parameters that can be specified in the peer's parameter list: | ||
| 238 | # No_TCP; No_SCTP; No_IP; No_IPv6; Prefer_TCP; TLS_old_method; | ||
| 239 | # No_TLS; # assume transparent security instead of TLS. DTLS is not supported yet (will change in future versions). | ||
| 240 | # Port = 5868; # The port to connect to | ||
| 241 | # TcTimer = 30; | ||
| 242 | # TwTimer = 30; | ||
| 243 | # ConnectTo = "202.249.37.5"; | ||
| 244 | # ConnectTo = "2001:200:903:2::202:1"; | ||
| 245 | # TLS_Prio = "NORMAL"; | ||
| 246 | # Realm = "realm.net"; # Reject the peer if it does not advertise this realm. | ||
| 247 | # Examples: | ||
| 248 | #ConnectPeer = "aaa.wide.ad.jp"; | ||
| 249 | #ConnectPeer = "old.diameter.serv" { TcTimer = 60; TLS_old_method; No_SCTP; Port=3868; } ; | ||
| 250 | ############################################################## | ||
diff --git a/meta-networking/recipes-protocols/freediameter/files/freediameter.init b/meta-networking/recipes-protocols/freediameter/files/freediameter.init new file mode 100755 index 0000000000..e63a42a7cb --- /dev/null +++ b/meta-networking/recipes-protocols/freediameter/files/freediameter.init | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # | ||
| 3 | ### BEGIN INIT INFO | ||
| 4 | # Provides: freediameter | ||
| 5 | # Default-Start: 2 3 4 5 | ||
| 6 | # Default-Stop: 0 1 6 | ||
| 7 | # Required-Start: $remote_fs $syslog | ||
| 8 | # Required-Stop: $remote_fs $syslog | ||
| 9 | # Short-Description: Start freeDiameter daemon at boot time | ||
| 10 | # Description: Start the freeDiameter daemon at boot time. | ||
| 11 | # freeDiameter is an extensible implementation of the Diameter protocol, | ||
| 12 | # designed for Authentication, Authorization and Accounting. Diameter is | ||
| 13 | # an evolution of the RADIUS protocol. | ||
| 14 | ### END INIT INFO# | ||
| 15 | DAEMON=/usr/bin/freeDiameterd | ||
| 16 | CONF=/etc/freeDiameter/freeDiameter.conf | ||
| 17 | NAME=freediameter | ||
| 18 | DESC="freeDiameter daemon" | ||
| 19 | |||
| 20 | . /etc/init.d/functions | ||
| 21 | start() { | ||
| 22 | [ -x $DAEMON ] || exit 5 | ||
| 23 | echo -n $"Starting $DAEMON: " | ||
| 24 | start-stop-daemon -S -b -x ${DAEMON} && success || failure | ||
| 25 | retval=$? | ||
| 26 | echo "" | ||
| 27 | return $retval | ||
| 28 | } | ||
| 29 | |||
| 30 | stop() { | ||
| 31 | echo -n $"Stopping $prog: " | ||
| 32 | start-stop-daemon -K -x $DAEMON | ||
| 33 | retval=$? | ||
| 34 | echo "" | ||
| 35 | return $retval | ||
| 36 | } | ||
| 37 | |||
| 38 | restart() { | ||
| 39 | stop | ||
| 40 | sleep 3 | ||
| 41 | start | ||
| 42 | } | ||
| 43 | |||
| 44 | rh_status() { | ||
| 45 | status $DAEMON | ||
| 46 | } | ||
| 47 | |||
| 48 | rh_status_q() { | ||
| 49 | rh_status > /dev/null 2>&1 | ||
| 50 | } | ||
| 51 | |||
| 52 | case "$1" in | ||
| 53 | start) | ||
| 54 | rh_status_q && exit 0 | ||
| 55 | start | ||
| 56 | ;; | ||
| 57 | stop) | ||
| 58 | rh_status_q || exit 0 | ||
| 59 | stop | ||
| 60 | ;; | ||
| 61 | restart) | ||
| 62 | restart | ||
| 63 | ;; | ||
| 64 | status) | ||
| 65 | rh_status | ||
| 66 | ;; | ||
| 67 | *) | ||
| 68 | echo $"Usage: $prog {start|stop|status|restart}" | ||
| 69 | exit 2 | ||
| 70 | esac | ||
| 71 | |||
| 72 | exit $? | ||
diff --git a/meta-networking/recipes-protocols/freediameter/files/freediameter.service b/meta-networking/recipes-protocols/freediameter/files/freediameter.service new file mode 100644 index 0000000000..514481b431 --- /dev/null +++ b/meta-networking/recipes-protocols/freediameter/files/freediameter.service | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | [Unit] | ||
| 2 | Description=freediameter daemon | ||
| 3 | After=network.target | ||
| 4 | |||
| 5 | [Service] | ||
| 6 | Type=simple | ||
| 7 | PIDFile=/var/run/freediameter.pid | ||
| 8 | ExecStart=@BINDIR@/freeDiameterd | ||
| 9 | |||
| 10 | [Install] | ||
| 11 | WantedBy=multi-user.target | ||
diff --git a/meta-networking/recipes-protocols/freediameter/files/install_test.patch b/meta-networking/recipes-protocols/freediameter/files/install_test.patch new file mode 100644 index 0000000000..151037d69b --- /dev/null +++ b/meta-networking/recipes-protocols/freediameter/files/install_test.patch | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | CMakeLists: add an option to install tests | ||
| 2 | |||
| 3 | Upstream-Status: Inappropriate [OE ptest specific] | ||
| 4 | |||
| 5 | Original author: Yao Zhao <yao.zhao@windriver.com> | ||
| 6 | Signed-off-by: Jackie Huang <jackie.huang@windriver.com> | ||
| 7 | |||
| 8 | diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt | ||
| 9 | index da8da1b..de04059 100644 | ||
| 10 | --- a/tests/CMakeLists.txt | ||
| 11 | +++ b/tests/CMakeLists.txt | ||
| 12 | @@ -113,4 +113,9 @@ ENDFOREACH( TEST ) | ||
| 13 | #### | ||
| 14 | ## INSTALL section ## | ||
| 15 | |||
| 16 | -# we do not install the tests | ||
| 17 | +# install the tests | ||
| 18 | +SET(INSTALL_TEST_SUFFIX /opt/${FD_PROJECT_NAME}-tests CACHE PATH "Directory where the test binary is installed.") | ||
| 19 | + | ||
| 20 | +INSTALL(TARGETS ${TEST_LIST} | ||
| 21 | + RUNTIME DESTINATION ${INSTALL_TEST_SUFFIX} | ||
| 22 | + COMPONENT freeDiameter-common) | ||
diff --git a/meta-networking/recipes-protocols/freediameter/files/pass-ptest-env.patch b/meta-networking/recipes-protocols/freediameter/files/pass-ptest-env.patch new file mode 100644 index 0000000000..ea857af7d6 --- /dev/null +++ b/meta-networking/recipes-protocols/freediameter/files/pass-ptest-env.patch | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | freediameter ptest cases testmesg_stress.c and testloadext.c need load | ||
| 2 | extensions both build time and runtime. Then they search extensions with | ||
| 3 | build directory that causes runtime failures. | ||
| 4 | |||
| 5 | Pass an environment variable to define runtime extension path. | ||
| 6 | |||
| 7 | Upstream-Status: Inappropriate [OE ptest specific] | ||
| 8 | |||
| 9 | Signed-off-by: Kai Kang <kai.kang@windriver.com> | ||
| 10 | Signed-off-by: Jackie Huang <jackie.huang@windriver.com> | ||
| 11 | |||
| 12 | diff -Nur freeDiameter-1.2.0.orig/tests/testloadext.c freeDiameter-1.2.0/tests/testloadext.c | ||
| 13 | --- freeDiameter-1.2.0.orig/tests/testloadext.c 2014-02-19 17:33:24.785405032 +0800 | ||
| 14 | +++ freeDiameter-1.2.0/tests/testloadext.c 2014-02-19 20:08:03.871403924 +0800 | ||
| 15 | @@ -49,7 +49,7 @@ | ||
| 16 | { | ||
| 17 | DIR *dir; | ||
| 18 | struct dirent *dp; | ||
| 19 | - char fullname[512]; | ||
| 20 | + char fullname[1024]; | ||
| 21 | int pathlen; | ||
| 22 | |||
| 23 | /* First, initialize the daemon modules */ | ||
| 24 | @@ -57,11 +57,16 @@ | ||
| 25 | CHECK( 0, fd_queues_init() ); | ||
| 26 | CHECK( 0, fd_msg_init() ); | ||
| 27 | CHECK( 0, fd_rtdisp_init() ); | ||
| 28 | - | ||
| 29 | + | ||
| 30 | + char *ext_dir = getenv("EXTENSIONS_DIR"); | ||
| 31 | + if (ext_dir) | ||
| 32 | + pathlen = snprintf(fullname, sizeof(fullname), "%s", ext_dir); | ||
| 33 | + else | ||
| 34 | + pathlen = snprintf(fullname, sizeof(fullname), BUILD_DIR "/extensions/"); | ||
| 35 | + | ||
| 36 | /* Find all extensions which have been compiled along the test */ | ||
| 37 | - TRACE_DEBUG(INFO, "Loading from: '%s'", BUILD_DIR "/extensions"); | ||
| 38 | - CHECK( 0, (dir = opendir (BUILD_DIR "/extensions")) == NULL ? 1 : 0 ); | ||
| 39 | - pathlen = snprintf(fullname, sizeof(fullname), BUILD_DIR "/extensions/"); | ||
| 40 | + TRACE_DEBUG(INFO, "Loading from: '%s'", fullname); | ||
| 41 | + CHECK( 0, (dir = opendir (fullname)) == NULL ? 1 : 0 ); | ||
| 42 | |||
| 43 | while ((dp = readdir (dir)) != NULL) { | ||
| 44 | char * dot = strrchr(dp->d_name, '.'); | ||
| 45 | diff -Nur freeDiameter-1.2.0.orig/tests/testmesg_stress.c freeDiameter-1.2.0/tests/testmesg_stress.c | ||
| 46 | --- freeDiameter-1.2.0.orig/tests/testmesg_stress.c 2014-02-19 17:33:24.785405032 +0800 | ||
| 47 | +++ freeDiameter-1.2.0/tests/testmesg_stress.c 2014-02-19 20:08:03.928403924 +0800 | ||
| 48 | @@ -67,15 +67,20 @@ | ||
| 49 | { | ||
| 50 | DIR *dir; | ||
| 51 | struct dirent *dp; | ||
| 52 | - char fullname[512]; | ||
| 53 | + char fullname[1024]; | ||
| 54 | int pathlen; | ||
| 55 | struct fd_list all_extensions = FD_LIST_INITIALIZER(all_extensions); | ||
| 56 | struct fd_list ext_with_depends = FD_LIST_INITIALIZER(ext_with_depends); | ||
| 57 | |||
| 58 | + char *ext_dir = getenv("EXTENSIONS_DIR"); | ||
| 59 | + if (ext_dir) | ||
| 60 | + pathlen = snprintf(fullname, sizeof(fullname), "%s", ext_dir); | ||
| 61 | + else | ||
| 62 | + pathlen = snprintf(fullname, sizeof(fullname), BUILD_DIR "/extensions/"); | ||
| 63 | + | ||
| 64 | /* Find all extensions which have been compiled along the test */ | ||
| 65 | - LOG_D("Loading %s*.fdx from: '%s'", BUILD_DIR "/extensions", prefix ?: ""); | ||
| 66 | - CHECK( 0, (dir = opendir (BUILD_DIR "/extensions")) == NULL ? 1 : 0 ); | ||
| 67 | - pathlen = snprintf(fullname, sizeof(fullname), BUILD_DIR "/extensions/"); | ||
| 68 | + TRACE_DEBUG(INFO, "Loading from: '%s'", fullname); | ||
| 69 | + CHECK( 0, (dir = opendir (fullname)) == NULL ? 1 : 0 ); | ||
| 70 | |||
| 71 | while ((dp = readdir (dir)) != NULL) { | ||
| 72 | char * dot = strrchr(dp->d_name, '.'); | ||
diff --git a/meta-networking/recipes-protocols/freediameter/files/run-ptest b/meta-networking/recipes-protocols/freediameter/files/run-ptest new file mode 100644 index 0000000000..d0ca8d9621 --- /dev/null +++ b/meta-networking/recipes-protocols/freediameter/files/run-ptest | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | if ! lsmod | grep -q sctp && ! modprobe sctp 2>/dev/null; then | ||
| 4 | echo "Couldn't load kernel module sctp." | ||
| 5 | echo "Test cases testsctp and testcnx will fail." | ||
| 6 | echo | ||
| 7 | fi | ||
| 8 | |||
| 9 | export EXTENSIONS_DIR=$EXTENSIONS_DIR | ||
| 10 | cmake -E cmake_echo_color --cyan "Running tests..." | ||
| 11 | ctest --force-new-ctest-process | ||
diff --git a/meta-networking/recipes-protocols/freediameter/freediameter_1.2.1.bb b/meta-networking/recipes-protocols/freediameter/freediameter_1.2.1.bb new file mode 100644 index 0000000000..92cd24c3ae --- /dev/null +++ b/meta-networking/recipes-protocols/freediameter/freediameter_1.2.1.bb | |||
| @@ -0,0 +1,136 @@ | |||
| 1 | SUMMARY = "An open source implementation of the diameter protocol" | ||
| 2 | DESCRIPTION = "\ | ||
| 3 | freeDiameter is an open source Diameter protocol implementation \ | ||
| 4 | (RFC3588). It provides an extensible platform for deploying a \ | ||
| 5 | Diameter network for your Authentication, Authorization and \ | ||
| 6 | Accounting needs." | ||
| 7 | |||
| 8 | HOMEPAGE = "http://www.freediameter.net" | ||
| 9 | |||
| 10 | DEPENDS = "flex bison cmake-native libgcrypt gnutls libidn lksctp-tools" | ||
| 11 | |||
| 12 | fd_pkgname = "freeDiameter" | ||
| 13 | |||
| 14 | SRC_URI = "\ | ||
| 15 | http://www.freediameter.net/hg/${fd_pkgname}/archive/${PV}.tar.gz;downloadfilename=${fd_pkgname}-${PV}.tar.gz \ | ||
| 16 | file://Replace-murmurhash-algorithm-with-Robert-Jenkin-s-ha.patch \ | ||
| 17 | file://freediameter.service \ | ||
| 18 | file://freediameter.init \ | ||
| 19 | ${@bb.utils.contains('DISTRO_FEATURES', 'ptest', 'file://install_test.patch file://run-ptest file://pass-ptest-env.patch', '', d)} \ | ||
| 20 | file://freeDiameter.conf \ | ||
| 21 | " | ||
| 22 | |||
| 23 | SRC_URI[md5sum] = "61b1062aa144b5f12eed514611e6d697" | ||
| 24 | SRC_URI[sha256sum] = "bd7f105542e9903e776aa006c6931c1f5d3d477cb59af33a9162422efa477097" | ||
| 25 | |||
| 26 | S = "${WORKDIR}/${fd_pkgname}-${PV}" | ||
| 27 | |||
| 28 | LICENSE = "BSD" | ||
| 29 | LIC_FILES_CHKSUM = "file://LICENSE;md5=892b2ed6ae815488a08416ff7ee74a35" | ||
| 30 | |||
| 31 | PTEST_PATH = "${libdir}/${fd_pkgname}/ptest" | ||
| 32 | |||
| 33 | inherit cmake pkgconfig update-rc.d ptest systemd | ||
| 34 | |||
| 35 | EXTRA_OECMAKE = " \ | ||
| 36 | -DDEFAULT_CONF_PATH:PATH=${sysconfdir}/${fd_pkgname} \ | ||
| 37 | -DBUILD_DBG_MONITOR:BOOL=ON \ | ||
| 38 | -DBUILD_TEST_APP:BOOL=ON \ | ||
| 39 | -DBUILD_TESTING:BOOL=ON \ | ||
| 40 | -DBUILD_APP_RADGW:BOOL=ON \ | ||
| 41 | -DBUILD_APP_REDIRECT:BOOL=ON \ | ||
| 42 | -DBUILD_TEST_ACCT:BOOL=ON \ | ||
| 43 | -DBUILD_TEST_NETEMUL:BOOL=ON \ | ||
| 44 | -DBUILD_TEST_RT_ANY:BOOL=ON \ | ||
| 45 | -DINSTALL_LIBRARY_SUFFIX:PATH=${baselib} \ | ||
| 46 | -DINSTALL_EXTENSIONS_SUFFIX:PATH=${baselib}/${fd_pkgname} \ | ||
| 47 | -DINSTALL_TEST_SUFFIX:PATH=${PTEST_PATH}-tests \ | ||
| 48 | -DCMAKE_SKIP_RPATH:BOOL=ON \ | ||
| 49 | " | ||
| 50 | # INSTALL_LIBRARY_SUFFIX is relative to CMAKE_INSTALL_PREFIX | ||
| 51 | # specify it on cmd line will fix the SET bug in CMakeList.txt | ||
| 52 | |||
| 53 | # -DBUILD_APP_ACCT:BOOL=ON This needs POSTGRESQL support | ||
| 54 | |||
| 55 | # -DBUILD_APP_DIAMEAP:BOOL=ON -DBUILD_APP_SIP:BOOL=ON -DBUILD_TEST_SIP:BOOL=ON | ||
| 56 | # These need MySQL support | ||
| 57 | |||
| 58 | # -DBUILD_DBG_INTERACTIVE:BOOL=ON This needs SWIG support | ||
| 59 | |||
| 60 | # -DALL_EXTENSIONS=ON will enable all | ||
| 61 | |||
| 62 | FD_KEY ?="${BPN}.key" | ||
| 63 | FD_PEM ?= "${BPN}.pem" | ||
| 64 | FD_CA ?= "${BPN}.pem" | ||
| 65 | FD_DH_PEM ?= "${BPN}-dh.pem" | ||
| 66 | FD_HOSTNAME ?= "${MACHINE}" | ||
| 67 | FD_REALM ?= "openembedded.org" | ||
| 68 | |||
| 69 | do_install_append() { | ||
| 70 | # install the sample configuration files | ||
| 71 | install -d -m 0755 ${D}${sysconfdir}/${fd_pkgname} | ||
| 72 | for i in ${S}/doc/*.conf.sample; do | ||
| 73 | install -m 0644 $i ${D}${sysconfdir}/${fd_pkgname}/ | ||
| 74 | done | ||
| 75 | mv ${D}${sysconfdir}/${fd_pkgname}/freediameter.conf.sample \ | ||
| 76 | ${D}${sysconfdir}/${fd_pkgname}/freeDiameter.conf.sample | ||
| 77 | install -d ${D}${sysconfdir}/freeDiameter | ||
| 78 | install ${WORKDIR}/freeDiameter.conf ${D}${sysconfdir}/${fd_pkgname}/freeDiameter.conf | ||
| 79 | |||
| 80 | # install daemon init related files | ||
| 81 | install -d -m 0755 ${D}${sysconfdir}/default | ||
| 82 | install -d -m 0755 ${D}${sysconfdir}/init.d | ||
| 83 | install -m 0644 ${S}/contrib/debian/freediameter-daemon.default \ | ||
| 84 | ${D}${sysconfdir}/default/${BPN} | ||
| 85 | install -m 0755 ${WORKDIR}/freediameter.init ${D}${sysconfdir}/init.d/${BPN} | ||
| 86 | |||
| 87 | # install for systemd | ||
| 88 | install -d ${D}${systemd_system_unitdir} | ||
| 89 | install -m 0644 ${WORKDIR}/freediameter.service ${D}${systemd_system_unitdir} | ||
| 90 | sed -i -e 's,@BINDIR@,${bindir},g' ${D}${systemd_system_unitdir}/*.service | ||
| 91 | |||
| 92 | cat >> ${D}${sysconfdir}/freeDiameter/freeDiameter.conf <<EOF | ||
| 93 | ## OE specific ## | ||
| 94 | #Identity="${FD_HOSTNAME}"; | ||
| 95 | Identity = "${FD_HOSTNAME}.${FD_REALM}"; | ||
| 96 | Realm = "${FD_REALM}"; | ||
| 97 | Port = 30868; | ||
| 98 | SecPort = 30869; | ||
| 99 | TLS_Cred = "/etc/freeDiameter/${FD_PEM}" , "/etc/freeDiameter/${FD_KEY}"; | ||
| 100 | TLS_CA = "/etc/freeDiameter/${FD_CA}"; | ||
| 101 | TLS_DH_File = "/etc/freeDiameter/${FD_DH_PEM}"; | ||
| 102 | EOF | ||
| 103 | |||
| 104 | # create self cert | ||
| 105 | openssl req -x509 -config ${STAGING_DIR_NATIVE}/etc/ssl/openssl.cnf -newkey rsa:4096 -sha256 -nodes -out ${D}${sysconfdir}/freeDiameter/${FD_PEM} -keyout ${D}${sysconfdir}/freeDiameter/${FD_KEY} -days 3650 -subj '/CN=${FD_HOSTNAME}.${FD_REALM}' | ||
| 106 | openssl dhparam -out ${D}${sysconfdir}/freeDiameter/${FD_DH_PEM} 1024 | ||
| 107 | |||
| 108 | } | ||
| 109 | |||
| 110 | do_install_ptest() { | ||
| 111 | sed -i "s#\(EXTENSIONS_DIR=\).*\$#\1${libdir}/${fd_pkgname}/#" ${D}${PTEST_PATH}/run-ptest | ||
| 112 | mv ${D}${PTEST_PATH}-tests/* ${D}${PTEST_PATH}/ | ||
| 113 | rmdir ${D}${PTEST_PATH}-tests | ||
| 114 | install -m 0644 ${B}/tests/CTestTestfile.cmake ${D}${PTEST_PATH}/ | ||
| 115 | } | ||
| 116 | |||
| 117 | FILES_${PN}-dbg += "${libdir}/${fd_pkgname}/.debug/*" | ||
| 118 | |||
| 119 | # include the extensions in main package | ||
| 120 | FILES_${PN} += "${libdir}/${fd_pkgname}/*" | ||
| 121 | |||
| 122 | RDEPENDS_${PN} = "glib-2.0 gnutls libidn" | ||
| 123 | RDEPENDS_${PN} += "openssl openssl-conf openssl-engines" | ||
| 124 | RDEPENDS_${PN} += "kernel-module-tipc kernel-module-sctp" | ||
| 125 | RDEPENDS_${PN} += "kernel-module-udp-tunnel kernel-module-ipip" | ||
| 126 | RDEPENDS_${PN}-ptest = "cmake" | ||
| 127 | |||
| 128 | INITSCRIPT_PACKAGES = "${PN}" | ||
| 129 | INITSCRIPT_NAME_${PN} = "${BPN}" | ||
| 130 | INITSCRIPT_PARAMS$_${PN} = "start 30 . stop 70 0 1 2 3 4 5 6 ." | ||
| 131 | |||
| 132 | SYSTEMD_SERVICE_${PN} = "freediameter.service" | ||
| 133 | SYSTEMD_AUTO_ENABLE = "disable" | ||
| 134 | |||
| 135 | CONFFILES_${PN} = "${sysconfdir}/freediameter.conf" | ||
| 136 | |||
