Mercurial > hg > freeDiameter
changeset 403:26aafbbc1640
Cleanup all compilation warnings in base code for 32 bit arch
line wrap: on
line diff
--- a/extensions/acl_wl/aw_tree.c Thu Jul 08 12:50:10 2010 +0900 +++ b/extensions/acl_wl/aw_tree.c Thu Jul 08 14:24:19 2010 +0900 @@ -87,7 +87,6 @@ static int parse_name(char * name, struct split_name * result) { int i, l, prev_offset; - char * c; TRACE_ENTRY("%p %p", name, result);
--- a/extensions/app_acct/acct_conf.y Thu Jul 08 12:50:10 2010 +0900 +++ b/extensions/app_acct/acct_conf.y Thu Jul 08 14:24:19 2010 +0900 @@ -58,6 +58,9 @@ /* Forward declaration */ int yyparse(char * conffile); +/* The Lex parser prototype */ +int acct_conflex(YYSTYPE *lvalp, YYLTYPE *llocp); + /* the global configuration */ struct acct_conf * acct_config = NULL; @@ -88,9 +91,10 @@ return EINVAL; } + if (!TRACE_BOOL(FULL)) + return 0; + struct fd_list * li; - if (!TRACE_BOOL(FULL)) - return; fd_log_debug("[app_acct] Configuration dump:\n"); fd_log_debug(" Database:\n"); @@ -109,6 +113,7 @@ fd_log_debug("as ::%s\n", diam2db_types_mapping[a->avptype]); } fd_log_debug("[app_acct] Complete.\n"); + return 0; } void acct_conf_free(void)
--- a/extensions/app_acct/acct_db.c Thu Jul 08 12:50:10 2010 +0900 +++ b/extensions/app_acct/acct_db.c Thu Jul 08 14:24:19 2010 +0900 @@ -63,7 +63,6 @@ char * sql=NULL; /* The buffer that will contain the SQL query */ size_t sql_allocd = 0; /* The malloc'd size of the buffer */ size_t sql_offset = 0; /* The actual data already written in this buffer */ - size_t p; int idx = 0; PGresult * res; #define REALLOC_SIZE 1024 /* We extend the buffer by this amount */
--- a/extensions/app_acct/app_acct.c Thu Jul 08 12:50:10 2010 +0900 +++ b/extensions/app_acct/app_acct.c Thu Jul 08 14:24:19 2010 +0900 @@ -47,11 +47,9 @@ /* Callback for incoming Base Accounting Accounting-Request messages */ static int acct_cb( struct msg ** msg, struct avp * avp, struct session * sess, enum disp_action * act) { - struct msg_hdr *hdr = NULL; struct msg * m; struct avp * a = NULL; struct avp_hdr * art=NULL, *arn=NULL; /* We keep a pointer on the Accounting-Record-{Type, Number} AVPs from the query */ - char * s; struct acct_record_list rl; TRACE_ENTRY("%p %p %p %p", msg, avp, sess, act);
--- a/extensions/app_radgw/md5.c Thu Jul 08 12:50:10 2010 +0900 +++ b/extensions/app_radgw/md5.c Thu Jul 08 14:24:19 2010 +0900 @@ -6,8 +6,6 @@ * In addition to this notice, only the #include directives have been modified. */ #include "rgw_common.h" -/* Forward declaration: */ -void md5_vector(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac); /*********************************************************************************/
--- a/extensions/app_radgw/md5.h Thu Jul 08 12:50:10 2010 +0900 +++ b/extensions/app_radgw/md5.h Thu Jul 08 14:24:19 2010 +0900 @@ -3,8 +3,8 @@ * The content from this file comes directly from the hostap project. * It is redistributed under the terms of the BSD license, as allowed * by the original copyright reproduced bellow. - * The file has not been modified, except for this notice. */ + /*********************************************************************************/ /* @@ -40,4 +40,7 @@ void MD5Final(unsigned char digest[16], struct MD5Context *context); #endif /* CONFIG_CRYPTO_INTERNAL */ + /* Forward declaration: */ +void md5_vector(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac); + #endif /* MD5_H */
--- a/extensions/app_radgw/rgw.h Thu Jul 08 12:50:10 2010 +0900 +++ b/extensions/app_radgw/rgw.h Thu Jul 08 14:24:19 2010 +0900 @@ -101,8 +101,6 @@ int rgw_clients_search(struct sockaddr * ip_port, struct rgw_client ** ref); int rgw_clients_check_dup(struct rgw_radius_msg_meta **msg, struct rgw_client *cli); int rgw_clients_check_origin(struct rgw_radius_msg_meta *msg, struct rgw_client *cli); -int rgw_clients_get_origin(struct rgw_client *cli, char **fqdn, char **realm); -char * rgw_clients_id(struct rgw_client *cli); int rgw_client_finish_send(struct radius_msg ** msg, struct rgw_radius_msg_meta * req, struct rgw_client * cli); void rgw_clients_dispose(struct rgw_client ** ref); void rgw_clients_dump(void);
--- a/extensions/app_radgw/rgw_clients.c Thu Jul 08 12:50:10 2010 +0900 +++ b/extensions/app_radgw/rgw_clients.c Thu Jul 08 14:24:19 2010 +0900 @@ -188,7 +188,6 @@ Returns other error code on other error. */ static int client_search(struct rgw_client ** res, struct sockaddr * ip_port ) { - int ret = 0; int cmp; struct fd_list *ref = NULL; @@ -300,7 +299,6 @@ /* Find the relevant attributes, if any */ for (idx = 0; idx < msg->radius.attr_used; idx++) { struct radius_attr_hdr * attr = (struct radius_attr_hdr *)(msg->radius.buf + msg->radius.attr_pos[idx]); - unsigned char * attr_val = (unsigned char *)(attr + 1); size_t attr_len = attr->length - sizeof(struct radius_attr_hdr); if ((attr->type == RADIUS_ATTR_NAS_IP_ADDRESS) && (attr_len = 4)) {
--- a/extensions/app_radgw/rgw_common.h Thu Jul 08 12:50:10 2010 +0900 +++ b/extensions/app_radgw/rgw_common.h Thu Jul 08 14:24:19 2010 +0900 @@ -55,8 +55,10 @@ /* This structure points to a RADIUS client description, the definition is not known to plugins */ struct rgw_client; -/* This function is required to be able to translate user paswords */ -int rgw_clients_getkey(struct rgw_client * cli, unsigned char **key, size_t *key_len); + +int rgw_clients_getkey(struct rgw_client * cli, unsigned char **key, size_t *key_len); +char * rgw_clients_id(struct rgw_client *cli); +int rgw_clients_get_origin(struct rgw_client *cli, char **fqdn, char **realm); /* Each plugin must provide the following structure. */ extern struct rgw_api {
--- a/extensions/app_radgw/rgw_conf.l Thu Jul 08 12:50:10 2010 +0900 +++ b/extensions/app_radgw/rgw_conf.l Thu Jul 08 14:24:19 2010 +0900 @@ -135,7 +135,7 @@ return LEX_ERROR; /* trig an error in yacc parser */ } - if (port = strchr(work, '[')) { + if ((port = strchr(work, '[')) != NULL) { *port = '\0'; port++; if (sscanf(port, "%hu]", &p) != 1) {
--- a/extensions/app_radgw/rgw_plugins.c Thu Jul 08 12:50:10 2010 +0900 +++ b/extensions/app_radgw/rgw_plugins.c Thu Jul 08 14:24:19 2010 +0900 @@ -172,7 +172,6 @@ int rgw_plg_add( char * plgfile, char * conffile, int type, unsigned char ** codes_array, size_t codes_sz ) { struct plg_descr * new; - int ret = 0; TRACE_ENTRY("%p %p %d %p %zi", plgfile, conffile, type, codes_array, codes_sz);
--- a/extensions/app_radgw/rgw_worker.c Thu Jul 08 12:50:10 2010 +0900 +++ b/extensions/app_radgw/rgw_worker.c Thu Jul 08 14:24:19 2010 +0900 @@ -62,8 +62,6 @@ /* Worker thread, processing incoming RADIUS messages (after parsing) */ static void * work_th(void * arg) { - char thname[10]; - TRACE_ENTRY("%p", arg); /* Set the thread name */
--- a/extensions/app_radgw/rgwx_acct.c Thu Jul 08 12:50:10 2010 +0900 +++ b/extensions/app_radgw/rgwx_acct.c Thu Jul 08 14:24:19 2010 +0900 @@ -300,9 +300,9 @@ const char * prefix = "Diameter/"; size_t pref_len; - char * si = NULL; + uint8_t * si = NULL; size_t si_len = 0; - char * un = NULL; + uint8_t * un = NULL; size_t un_len = 0; TRACE_ENTRY("%p %p %p %p %p %p", cs, session, rad_req, rad_ans, diam_fw, cli); @@ -356,7 +356,7 @@ case RADIUS_ATTR_CLASS: if ((attr_len > pref_len ) && ! strncmp((char *)v, prefix, pref_len)) { int i; - si = (char *)v + pref_len; + si = v + pref_len; si_len = attr_len - pref_len; TRACE_DEBUG(ANNOYING, "Found Class attribute with '%s' prefix (attr #%d), SI:'%.*s'.", prefix, idx, si_len, si); /* Remove from the message */ @@ -368,7 +368,7 @@ case RADIUS_ATTR_USER_NAME: if (attr_len) { - un = (char *)v; + un = v; un_len = attr_len; TRACE_DEBUG(ANNOYING, "Found a User-Name attribute: '%.*s'", un_len, un); } @@ -470,7 +470,7 @@ } if (idx == 0) { /* Not found in the User-Name => we use the local domain of this gateway */ - value.os.data = fd_g_config->cnf_diamrlm; + value.os.data = (uint8_t *)fd_g_config->cnf_diamrlm; value.os.len = fd_g_config->cnf_diamrlm_len; } else { value.os.data = un + idx; @@ -481,7 +481,7 @@ /* Create the Session-Id AVP if needed */ if (!*session) { - CHECK_FCT( fd_sess_fromsid ( si, si_len, session, NULL) ); + CHECK_FCT( fd_sess_fromsid ( (char *)/* cast should be removed later */si, si_len, session, NULL) ); TRACE_DEBUG(FULL, "[auth.rgwx] Translating new accounting message for session '%.*s'...", si_len, si);
--- a/extensions/app_radgw/rgwx_auth.c Thu Jul 08 12:50:10 2010 +0900 +++ b/extensions/app_radgw/rgwx_auth.c Thu Jul 08 14:24:19 2010 +0900 @@ -235,15 +235,14 @@ int got_empty_eap = 0; const char * prefix = "Diameter/"; size_t pref_len; - char * dh = NULL; + uint8_t * dh = NULL; size_t dh_len = 0; - char * dr = NULL; + uint8_t * dr = NULL; size_t dr_len = 0; - char * si = NULL; + uint8_t * si = NULL; size_t si_len = 0; - char * un = NULL; + uint8_t * un = NULL; size_t un_len = 0; - uint32_t status_type; size_t nattr_used = 0; struct avp ** avp_tun = NULL, *avp = NULL; union avp_value value; @@ -315,7 +314,7 @@ /* Check basic information is there, and also retrieve some attribute information */ for (idx = 0; idx < rad_req->attr_used; idx++) { struct radius_attr_hdr * attr = (struct radius_attr_hdr *)(rad_req->buf + rad_req->attr_pos[idx]); - char * attr_val = (char *)(attr + 1); + uint8_t * attr_val = (uint8_t *)(attr + 1); size_t attr_len = attr->length - sizeof(struct radius_attr_hdr); switch (attr->type) { @@ -342,7 +341,7 @@ /* NOTE: RFC4005 says "Origin-Host" here, but it's not coherent with the rules for answers. Destination-Host makes more sense */ case RADIUS_ATTR_STATE: if ((attr_len > pref_len + 5 /* for the '/'s and non empty strings */ ) - && ! strncmp(attr_val, prefix, pref_len)) { /* should we make it strncasecmp? */ + && ! memcmp(attr_val, prefix, pref_len)) { int i, start; TRACE_DEBUG(ANNOYING, "Found a State attribute with '%s' prefix (attr #%d).", prefix, idx); @@ -375,7 +374,7 @@ break; case RADIUS_ATTR_USER_NAME: - TRACE_DEBUG(ANNOYING, "Found a User-Name attribute: '%.*s'", attr_len, attr_len ? attr_val : ""); + TRACE_DEBUG(ANNOYING, "Found a User-Name attribute: '%.*s'", attr_len, attr_len ? (char *)attr_val : ""); un = attr_val; un_len = attr_len; break; @@ -429,7 +428,7 @@ } if (i <= 0) { /* Not found in the User-Name => we use the local domain of this gateway */ - value.os.data = fd_g_config->cnf_diamrlm; + value.os.data = (uint8_t *)fd_g_config->cnf_diamrlm; value.os.len = fd_g_config->cnf_diamrlm_len; } else { value.os.data = un + i; @@ -454,7 +453,7 @@ if (si_len) { /* We already have the Session-Id, just use it */ - CHECK_FCT( fd_sess_fromsid ( si, si_len, session, NULL) ); + CHECK_FCT( fd_sess_fromsid ( (char *) /* this cast will be removed later */ si, si_len, session, NULL) ); } else { /* Create a new Session-Id string */ @@ -543,7 +542,7 @@ EAP-Start, and it is translated to an empty EAP-Payload AVP. */ if (got_empty_eap) { value.os.len = 0; - value.os.data = ""; + value.os.data = (uint8_t *)""; } else { CHECK_MALLOC( value.os.data = radius_msg_get_eap(rad_req, &value.os.len) ); } @@ -1065,7 +1064,8 @@ struct msg_hdr * hdr; struct avp *avp, *next, *avp_x, *avp_y, *asid, *aoh; struct avp_hdr *ahdr, *sid, *oh; - char buf[254]; /* to store some attributes values (with final '\0') */ + uint8_t buf[254]; /* to store some attributes values (with final '\0') */ + size_t sz; int ta_set = 0; int no_str = 0; /* indicate if an STR is required for this server */ uint8_t tuntag = 0; @@ -1188,22 +1188,22 @@ /* Now, save the session-id and eventually server info in a STATE or CLASS attribute */ if ((*rad_fw)->hdr->code == RADIUS_CODE_ACCESS_CHALLENGE) { - if (sizeof(buf) < snprintf(buf, sizeof(buf), "Diameter/%.*s/%.*s/%.*s", - oh->avp_value->os.len, oh->avp_value->os.data, - ahdr->avp_value->os.len, ahdr->avp_value->os.data, - sid->avp_value->os.len, sid->avp_value->os.data)) { + if (sizeof(buf) < (sz = snprintf((char *)buf, sizeof(buf), "Diameter/%.*s/%.*s/%.*s", + oh->avp_value->os.len, (char *)oh->avp_value->os.data, + ahdr->avp_value->os.len, (char *)ahdr->avp_value->os.data, + sid->avp_value->os.len, (char *)sid->avp_value->os.data))) { TRACE_DEBUG(INFO, "Data truncated in State attribute: %s", buf); } - CONV2RAD_STR(RADIUS_ATTR_STATE, buf, strlen(buf), 0); + CONV2RAD_STR(RADIUS_ATTR_STATE, buf, sz, 0); } if ((*rad_fw)->hdr->code == RADIUS_CODE_ACCESS_ACCEPT) { /* Add the Session-Id */ - if (sizeof(buf) < snprintf(buf, sizeof(buf), "Diameter/%.*s", - sid->avp_value->os.len, sid->avp_value->os.data)) { + if (sizeof(buf) < (sz = snprintf((char *)buf, sizeof(buf), "Diameter/%.*s", + sid->avp_value->os.len, sid->avp_value->os.data))) { TRACE_DEBUG(INFO, "Data truncated in Class attribute: %s", buf); } - CONV2RAD_STR(RADIUS_ATTR_CLASS, buf, strlen(buf), 0); + CONV2RAD_STR(RADIUS_ATTR_CLASS, buf, sz, 0); } /* Unlink the Origin-Realm now; the others are unlinked at the end of this function */ @@ -1586,7 +1586,7 @@ CHECK_FCT( fd_msg_browse(inavp, MSG_BRW_NEXT, &innext, NULL) ); CHECK_FCT( fd_msg_avp_hdr ( inavp, &ahdr ) ); - if (ahdr->avp_flags & AVP_FLAG_VENDOR == 0) { + if ( ! (ahdr->avp_flags & AVP_FLAG_VENDOR)) { switch (ahdr->avp_code) { case DIAM_ATTR_TUNNEL_TYPE: CONV2RAD_TUN_32B( RADIUS_ATTR_TUNNEL_TYPE, ahdr->avp_value->u32); @@ -1633,7 +1633,6 @@ */ size_t pos; int i; - size_t buflen; uint8_t * secret; /* S */ size_t secret_len; uint8_t hash[16]; /* b(i) */ @@ -1652,7 +1651,7 @@ buf[2] = (uint8_t)(lrand48()); /* A (low bits) */ /* The plain text string P */ - CHECK_PARAM(ahdr->avp_value->os.len < 240); + CHECK_PARAMS(ahdr->avp_value->os.len < 240); buf[3] = ahdr->avp_value->os.len; memcpy(&buf[4], ahdr->avp_value->os.data, ahdr->avp_value->os.len); memset(&buf[4 + ahdr->avp_value->os.len], 0, sizeof(buf) - 4 - ahdr->avp_value->os.len); @@ -1816,11 +1815,11 @@ if ((*rad_fw)->hdr->code == RADIUS_CODE_ACCESS_ACCEPT) { /* Add the auth-application-id required for STR, or 0 if no STR is required */ CHECK_FCT( fd_msg_hdr( *diam_ans, &hdr ) ); - if (sizeof(buf) < snprintf(buf, sizeof(buf), CLASS_AAI_PREFIX "%u", - no_str ? 0 : hdr->msg_appl)) { + if (sizeof(buf) < (sz = snprintf((char *)buf, sizeof(buf), CLASS_AAI_PREFIX "%u", + no_str ? 0 : hdr->msg_appl))) { TRACE_DEBUG(INFO, "Data truncated in Class attribute: %s", buf); } - CONV2RAD_STR(RADIUS_ATTR_CLASS, buf, strlen(buf), 0); + CONV2RAD_STR(RADIUS_ATTR_CLASS, buf, sz, 0); } return 0;
--- a/extensions/app_radgw/rgwx_echodrop.c Thu Jul 08 12:50:10 2010 +0900 +++ b/extensions/app_radgw/rgwx_echodrop.c Thu Jul 08 14:24:19 2010 +0900 @@ -239,7 +239,6 @@ /* Process an answer: add the ECHO attributes back, if any */ static int ed_diam_ans( struct rgwp_config * cs, struct session * session, struct msg ** diam_ans, struct radius_msg ** rad_fw, struct rgw_client * cli, int * stateful ) { - int ret; struct fd_list * list = NULL; TRACE_ENTRY("%p %p %p %p %p %p", cs, session, diam_ans, rad_fw, cli, stateful); @@ -264,7 +263,6 @@ while (! FD_IS_LIST_EMPTY(list) ) { struct ed_saved_attribute * esa = (struct ed_saved_attribute *)(list->next); - struct radius_attr_hdr * rc; fd_list_unlink(&esa->chain);
--- a/extensions/app_radgw/rgwx_echodrop.y Thu Jul 08 12:50:10 2010 +0900 +++ b/extensions/app_radgw/rgwx_echodrop.y Thu Jul 08 14:24:19 2010 +0900 @@ -53,6 +53,14 @@ #include "rgwx_echodrop.h" #include "rgwx_echodrop.tab.h" /* bison is not smart enough to define the YYLTYPE before including this code, so... */ + +/* Forward declaration */ +int yyparse(char * conffile, struct rgwp_config *cs); + +/* The Lex parser prototype */ +int rgwx_echodroplex(YYSTYPE *lvalp, YYLTYPE *llocp); + + /* Parse the configuration file */ int ed_conffile_parse(char * conffile, struct rgwp_config *cs) {
--- a/extensions/rt_default/rtd_rules.c Thu Jul 08 12:50:10 2010 +0900 +++ b/extensions/rt_default/rtd_rules.c Thu Jul 08 14:24:19 2010 +0900 @@ -306,7 +306,7 @@ return (err == REG_ESPACE) ? ENOMEM : EINVAL; } -/* Search in list (targets or rules) the next matching item for string str(len). Returned in next_match, or *next_match == NULL if no more match. Re-enter with same next_match for the next one. */ +/* Search in list (targets or rules) the next matching item for octet string str(len). Returned in next_match, or *next_match == NULL if no more match. Re-enter with same next_match for the next one. */ static int get_next_match(struct fd_list * list, char * str, size_t len, struct fd_list ** next_match) { struct fd_list * li; @@ -576,7 +576,7 @@ /* OK, we can now check if one of our rule's criteria match the message content */ r = NULL; do { - CHECK_FCT ( get_next_match( &target->rules[j], parsed_msg_avp[j].avp->os.data, parsed_msg_avp[j].avp->os.len, (void *)&r) ); + CHECK_FCT ( get_next_match( &target->rules[j], (char *) /* is this cast safe? */ parsed_msg_avp[j].avp->os.data, parsed_msg_avp[j].avp->os.len, (void *)&r) ); if (!r) break;
--- a/extensions/test_app/ta_cli.c Thu Jul 08 12:50:10 2010 +0900 +++ b/extensions/test_app/ta_cli.c Thu Jul 08 14:24:19 2010 +0900 @@ -167,7 +167,7 @@ char * sid; CHECK_FCT_DO( fd_sess_getsid ( sess, &sid ), goto out ); CHECK_FCT_DO( fd_msg_avp_new ( ta_sess_id, 0, &avp ), goto out ); - val.os.data = sid; + val.os.data = (uint8_t *)sid; val.os.len = strlen(sid); CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out ); CHECK_FCT_DO( fd_msg_avp_add( req, MSG_BRW_FIRST_CHILD, avp ), goto out );
--- a/extensions/test_app/ta_serv.c Thu Jul 08 12:50:10 2010 +0900 +++ b/extensions/test_app/ta_serv.c Thu Jul 08 14:24:19 2010 +0900 @@ -56,7 +56,6 @@ { struct msg *ans, *qry; struct avp * a; - union avp_value val; TRACE_ENTRY("%p %p %p %p", msg, avp, sess, act); @@ -65,10 +64,10 @@ /* Value of Origin-Host */ fprintf(stderr, "ECHO Test-Request received from "); - CHECK_FCT_DO( fd_msg_search_avp ( *msg, ta_origin_host, &a), return ); + CHECK_FCT( fd_msg_search_avp ( *msg, ta_origin_host, &a) ); if (a) { struct avp_hdr * hdr; - CHECK_FCT_DO( fd_msg_avp_hdr( a, &hdr ), return ); + CHECK_FCT( fd_msg_avp_hdr( a, &hdr ) ); fprintf(stderr, "'%.*s'", hdr->avp_value->os.len, hdr->avp_value->os.data); } else { fprintf(stderr, "no_Origin-Host");
--- a/freeDiameter/cnxctx.c Thu Jul 08 12:50:10 2010 +0900 +++ b/freeDiameter/cnxctx.c Thu Jul 08 14:24:19 2010 +0900 @@ -161,8 +161,6 @@ CHECK_FCT_DO( ENOTSUP, return NULL); #else /* DISABLE_SCTP */ struct cnxctx * cnx = NULL; - sSS dummy; - sSA * sa = (sSA *) &dummy; TRACE_ENTRY("%hu %p", port, ep_list); @@ -223,7 +221,6 @@ sSS ss; socklen_t ss_len = sizeof(ss); int cli_sock = 0; - struct fd_endpoint * ep; TRACE_ENTRY("%p", serv); CHECK_PARAMS_DO(serv, return NULL); @@ -987,7 +984,8 @@ /* Verify remote credentials after successful handshake (return 0 if OK, EINVAL otherwise) */ int fd_tls_verify_credentials(gnutls_session_t session, struct cnxctx * conn, int verbose) { - int ret, i; + int i; + unsigned int gtret; const gnutls_datum_t *cert_list; unsigned int cert_list_size; gnutls_x509_crt_t cert; @@ -1018,14 +1016,6 @@ fd_log_debug("\t - TLS/IA session\n"); break; - - #ifdef ENABLE_SRP - case GNUTLS_CRD_SRP: - fd_log_debug("\t - SRP session with username %s\n", - gnutls_srp_server_get_username (session)); - break; - #endif - case GNUTLS_CRD_PSK: /* This returns NULL in server side. */ if (gnutls_psk_client_get_hint (session) != NULL) @@ -1048,6 +1038,17 @@ fd_log_debug("\t - Ephemeral DH using prime of %d bits\n", gnutls_dh_get_prime_bits (session)); } + break; + + case GNUTLS_CRD_SRP: + fd_log_debug("\t - SRP session with username %s\n", + gnutls_srp_server_get_username (session)); + break; + + default: + fd_log_debug("\t - Different type of credentials for the session (%d).\n", cred); + break; + } /* print the protocol's name (ie TLS 1.0) */ @@ -1072,19 +1073,19 @@ } /* First, use built-in verification */ - CHECK_GNUTLS_DO( gnutls_certificate_verify_peers2 (session, &ret), return EINVAL ); - if (ret) { + CHECK_GNUTLS_DO( gnutls_certificate_verify_peers2 (session, >ret), return EINVAL ); + if (gtret) { if (TRACE_BOOL(INFO)) { fd_log_debug("TLS: Remote certificate invalid on socket %d (Remote: '%s')(Connection: '%s') :\n", conn->cc_socket, conn->cc_remid, conn->cc_id); - if (ret & GNUTLS_CERT_INVALID) + if (gtret & GNUTLS_CERT_INVALID) fd_log_debug(" - The certificate is not trusted (unknown CA? expired?)\n"); - if (ret & GNUTLS_CERT_REVOKED) + if (gtret & GNUTLS_CERT_REVOKED) fd_log_debug(" - The certificate has been revoked.\n"); - if (ret & GNUTLS_CERT_SIGNER_NOT_FOUND) + if (gtret & GNUTLS_CERT_SIGNER_NOT_FOUND) fd_log_debug(" - The certificate hasn't got a known issuer.\n"); - if (ret & GNUTLS_CERT_SIGNER_NOT_CA) + if (gtret & GNUTLS_CERT_SIGNER_NOT_CA) fd_log_debug(" - The certificate signer is not a CA, or uses version 1, or 3 without basic constraints.\n"); - if (ret & GNUTLS_CERT_INSECURE_ALGORITHM) + if (gtret & GNUTLS_CERT_INSECURE_ALGORITHM) fd_log_debug(" - The certificate signature uses a weak algorithm.\n"); } return EINVAL;
--- a/freeDiameter/cnxctx.h Thu Jul 08 12:50:10 2010 +0900 +++ b/freeDiameter/cnxctx.h Thu Jul 08 14:24:19 2010 +0900 @@ -108,8 +108,8 @@ int fd_sctp_get_local_ep(int sock, struct fd_list * list); int fd_sctp_get_remote_ep(int sock, struct fd_list * list); int fd_sctp_get_str_info( int sock, uint16_t *in, uint16_t *out, sSS *primary ); -int fd_sctp_sendstr(int sock, uint16_t strid, uint8_t * buf, size_t len, int * cc_closing); -int fd_sctp_recvmeta(int sock, uint16_t * strid, uint8_t ** buf, size_t * len, int *event, int * cc_closing); +int fd_sctp_sendstr(int sock, uint16_t strid, uint8_t * buf, size_t len, uint32_t * cc_closing); +int fd_sctp_recvmeta(int sock, uint16_t * strid, uint8_t ** buf, size_t * len, int *event, uint32_t * cc_closing); /* TLS over SCTP (multi-stream) */ struct sctps_ctx { @@ -136,8 +136,6 @@ #endif /* DISABLE_SCTP */ -/* UDP */ -int fd_cnx_get_local_eps(struct fd_list * list); #endif /* _CNXCTX_H */
--- a/freeDiameter/config.c Thu Jul 08 12:50:10 2010 +0900 +++ b/freeDiameter/config.c Thu Jul 08 14:24:19 2010 +0900 @@ -96,7 +96,6 @@ if (FD_IS_LIST_EMPTY(&fd_g_config->cnf_endpoints)) { fd_log_debug(" Local endpoints ........ : Default (use all available)\n"); } else { - struct fd_list * li = fd_g_config->cnf_endpoints.next; fd_log_debug(" Local endpoints ........ : \n"); fd_ep_dump( 29, &fd_g_config->cnf_endpoints ); }
--- a/freeDiameter/fD.h Thu Jul 08 12:50:10 2010 +0900 +++ b/freeDiameter/fD.h Thu Jul 08 14:24:19 2010 +0900 @@ -326,6 +326,7 @@ int fd_cnx_getproto(struct cnxctx * conn); int fd_cnx_getTLS(struct cnxctx * conn); int fd_cnx_getcred(struct cnxctx * conn, const gnutls_datum_t **cert_list, unsigned int *cert_list_size); +int fd_cnx_get_local_eps(struct fd_list * list); int fd_cnx_getremoteeps(struct cnxctx * conn, struct fd_list * eps); char * fd_cnx_getremoteid(struct cnxctx * conn); int fd_cnx_receive(struct cnxctx * conn, struct timespec * timeout, unsigned char **buf, size_t * len);
--- a/freeDiameter/p_ce.c Thu Jul 08 12:50:10 2010 +0900 +++ b/freeDiameter/p_ce.c Thu Jul 08 14:24:19 2010 +0900 @@ -308,7 +308,8 @@ } /* We check that the value matches what we know, otherwise disconnect the peer */ - if (strncasecmp(hdr->avp_value->os.data, peer->p_hdr.info.pi_diamid, hdr->avp_value->os.len)) { + /* here also, using strcasecmp on (supposed) UTF8 data might be bad idea... to be improved */ + if (strncasecmp((char *)hdr->avp_value->os.data, peer->p_hdr.info.pi_diamid, hdr->avp_value->os.len)) { TRACE_DEBUG(INFO, "Received a message with Origin-Host set to '%.*s' while expecting '%s'\n", hdr->avp_value->os.len, hdr->avp_value->os.data, peer->p_hdr.info.pi_diamid); *error_code = "DIAMETER_UNKNOWN_PEER";
--- a/freeDiameter/p_dp.c Thu Jul 08 12:50:10 2010 +0900 +++ b/freeDiameter/p_dp.c Thu Jul 08 14:24:19 2010 +0900 @@ -47,11 +47,11 @@ struct avp * dc; int delay = peer->p_hdr.info.config.pic_tctimer ?: fd_g_config->cnf_timer_tc; - CHECK_FCT_DO( fd_msg_search_avp ( *msg, fd_dict_avp_DC, &dc ), return ); + CHECK_FCT( fd_msg_search_avp ( *msg, fd_dict_avp_DC, &dc )); if (dc) { /* Check the value is consistent with the saved one */ struct avp_hdr * hdr; - CHECK_FCT_DO( fd_msg_avp_hdr( dc, &hdr ), return ); + CHECK_FCT( fd_msg_avp_hdr( dc, &hdr ) ); if (hdr->avp_value == NULL) { /* This is a sanity check */ TRACE_DEBUG(NONE, "BUG: Unset value in Disconnect-Cause in DPR");
--- a/freeDiameter/p_psm.c Thu Jul 08 12:50:10 2010 +0900 +++ b/freeDiameter/p_psm.c Thu Jul 08 14:24:19 2010 +0900 @@ -688,6 +688,9 @@ /* Process the receiver side */ CHECK_FCT_DO( fd_p_ce_process_receiver(peer), goto psm_end ); goto psm_loop; + + default: + ASSERT(0); /* implementation problem, we did not foresee this case? */ } }
--- a/freeDiameter/peers.c Thu Jul 08 12:50:10 2010 +0900 +++ b/freeDiameter/peers.c Thu Jul 08 14:24:19 2010 +0900 @@ -223,7 +223,6 @@ int fd_peer_free(struct fd_peer ** ptr) { struct fd_peer *p; - void * t; TRACE_ENTRY("%p", ptr); CHECK_PARAMS(ptr); @@ -428,7 +427,8 @@ for (li = fd_g_peers.next; li != &fd_g_peers; li = li->next) { peer = (struct fd_peer *)li; - int cmp = strncasecmp( avp_hdr->avp_value->os.data, peer->p_hdr.info.pi_diamid, avp_hdr->avp_value->os.len ); + /* It is probably unwise to use strcasecmp on UTF8 data... To be improved! */ + int cmp = strncasecmp( (char *)avp_hdr->avp_value->os.data, peer->p_hdr.info.pi_diamid, avp_hdr->avp_value->os.len ); if (cmp > 0) continue; if (cmp == 0)
--- a/freeDiameter/routing_dispatch.c Thu Jul 08 12:50:10 2010 +0900 +++ b/freeDiameter/routing_dispatch.c Thu Jul 08 14:24:19 2010 +0900 @@ -268,13 +268,15 @@ if (peer) { if (dh && (dh->os.len == strlen(peer->p_hdr.info.pi_diamid)) - && (strncasecmp(peer->p_hdr.info.pi_diamid, dh->os.data, dh->os.len) == 0)) { + /* Here again we use strncasecmp on UTF8 data... This should probably be changed. */ + && (strncasecmp(peer->p_hdr.info.pi_diamid, (char *)dh->os.data, dh->os.len) == 0)) { /* The candidate is the Destination-Host */ c->score += FD_SCORE_FINALDEST; } else { if (dr && peer->p_hdr.info.runtime.pir_realm && (dr->os.len == strlen(peer->p_hdr.info.runtime.pir_realm)) - && (strncasecmp(peer->p_hdr.info.runtime.pir_realm, dr->os.data, dr->os.len) == 0)) { + /* Yet another case where we use strncasecmp on UTF8 data... Hmmm :-( */ + && (strncasecmp(peer->p_hdr.info.runtime.pir_realm, (char *)dr->os.data, dr->os.len) == 0)) { /* The candidate's realm matchs the Destination-Realm */ c->score += FD_SCORE_REALM; } @@ -354,7 +356,7 @@ /* Create new User-Name and Destination-Realm values */ static int process_decorated_NAI(union avp_value * un, union avp_value * dr) { - int i, at_idx = 0, sep_idx = 0; + int at_idx = 0, sep_idx = 0; unsigned char * old_un; TRACE_ENTRY("%p %p", un, dr); CHECK_PARAMS(un && dr); @@ -364,7 +366,7 @@ /* Search the positions of the first '!' and the '@' in the string */ nai_get_indexes(un, &sep_idx, &at_idx); - CHECK_PARAMS( 0 < sep_idx < at_idx < un->os.len); + CHECK_PARAMS( (0 < sep_idx) && (sep_idx < at_idx) && (at_idx < un->os.len)); /* Create the new User-Name value */ CHECK_MALLOC( un->os.data = malloc( at_idx ) );
--- a/freeDiameter/sctp.c Thu Jul 08 12:50:10 2010 +0900 +++ b/freeDiameter/sctp.c Thu Jul 08 14:24:19 2010 +0900 @@ -996,7 +996,7 @@ } /* Send a buffer over a specified stream */ -int fd_sctp_sendstr(int sock, uint16_t strid, uint8_t * buf, size_t len, int * cc_status) +int fd_sctp_sendstr(int sock, uint16_t strid, uint8_t * buf, size_t len, uint32_t * cc_status) { struct msghdr mhdr; struct iovec iov; @@ -1053,7 +1053,7 @@ } /* Receive the next data from the socket, or next notification */ -int fd_sctp_recvmeta(int sock, uint16_t * strid, uint8_t ** buf, size_t * len, int *event, int * cc_status) +int fd_sctp_recvmeta(int sock, uint16_t * strid, uint8_t ** buf, size_t * len, int *event, uint32_t * cc_status) { ssize_t ret = 0; struct msghdr mhdr;
--- a/freeDiameter/sctps.c Thu Jul 08 12:50:10 2010 +0900 +++ b/freeDiameter/sctps.c Thu Jul 08 14:24:19 2010 +0900 @@ -619,7 +619,7 @@ /* End all TLS sessions, in series (not as efficient as paralel, but simpler) */ for (i = 1; i < conn->cc_sctp_para.pairs; i++) { - if (!conn->cc_status & CC_STATUS_ERROR) { + if ( ! (conn->cc_status & CC_STATUS_ERROR)) { CHECK_GNUTLS_DO( gnutls_bye(conn->cc_sctps_data.array[i].session, GNUTLS_SHUT_WR), fd_cnx_markerror(conn) ); } }
--- a/freeDiameter/tests/testappacct.c Thu Jul 08 12:50:10 2010 +0900 +++ b/freeDiameter/tests/testappacct.c Thu Jul 08 14:24:19 2010 +0900 @@ -88,9 +88,10 @@ int main(int argc, char *argv[]) { extern PGconn *conn; /* in acct_db.c */ + extern int fd_ext_init(int major, int minor, char * conffile); /* defined in include's extension.h */ + extern void fd_ext_fini(void); /* defined in the extension itself */ struct msg * msg; char * sess_bkp; - struct dict_object * session_id = NULL; /* First, initialize the daemon modules */ INIT_FD();
--- a/freeDiameter/tests/testcnx.c Thu Jul 08 12:50:10 2010 +0900 +++ b/freeDiameter/tests/testcnx.c Thu Jul 08 14:24:19 2010 +0900 @@ -530,16 +530,16 @@ /* Main test routine */ int main(int argc, char *argv[]) { - gnutls_datum_t ca = { ca_data, sizeof(ca_data) }; - gnutls_datum_t server_cert = { server_cert_data, sizeof(server_cert_data) }; - gnutls_datum_t server_priv = { server_priv_data, sizeof(server_priv_data) }; - gnutls_datum_t client_cert = { client_cert_data, sizeof(client_cert_data) }; - gnutls_datum_t client_priv = { client_priv_data, sizeof(client_priv_data) }; - gnutls_datum_t expired_cert = { expired_cert_data, sizeof(expired_cert_data) }; - gnutls_datum_t expired_priv = { expired_priv_data, sizeof(expired_priv_data) }; - gnutls_datum_t notrust_ca = { notrust_ca_data, sizeof(notrust_ca_data) }; - gnutls_datum_t notrust_cert = { notrust_cert_data, sizeof(notrust_cert_data) }; - gnutls_datum_t notrust_priv = { notrust_priv_data, sizeof(notrust_priv_data) }; + gnutls_datum_t ca = { (uint8_t *)ca_data, sizeof(ca_data) }; + gnutls_datum_t server_cert = { (uint8_t *)server_cert_data, sizeof(server_cert_data) }; + gnutls_datum_t server_priv = { (uint8_t *)server_priv_data, sizeof(server_priv_data) }; + gnutls_datum_t client_cert = { (uint8_t *)client_cert_data, sizeof(client_cert_data) }; + gnutls_datum_t client_priv = { (uint8_t *)client_priv_data, sizeof(client_priv_data) }; + gnutls_datum_t expired_cert = { (uint8_t *)expired_cert_data, sizeof(expired_cert_data) }; + gnutls_datum_t expired_priv = { (uint8_t *)expired_priv_data, sizeof(expired_priv_data) }; + gnutls_datum_t notrust_ca = { (uint8_t *)notrust_ca_data, sizeof(notrust_ca_data) }; + gnutls_datum_t notrust_cert = { (uint8_t *)notrust_cert_data, sizeof(notrust_cert_data) }; + gnutls_datum_t notrust_priv = { (uint8_t *)notrust_priv_data, sizeof(notrust_priv_data) }; struct cnxctx * listener; #ifndef DISABLE_SCTP @@ -634,8 +634,8 @@ /* Create the instance */ CHECK( 0, fd_msg_avp_new ( model, 0, &oh ) ); - value.os.data = "Client.side"; - value.os.len = strlen(value.os.data); + value.os.data = (uint8_t *)"Client.side"; + value.os.len = strlen((char *)value.os.data); CHECK( 0, fd_msg_avp_setvalue ( oh, &value ) ); /* Add the AVP */ @@ -1384,7 +1384,6 @@ char * str; const gnutls_datum_t *cert_list; unsigned int cert_list_size; - struct fd_list local, remote; struct fifo * myfifo = NULL; struct timespec now; int ev_code; @@ -1501,7 +1500,6 @@ char * str; const gnutls_datum_t *cert_list; unsigned int cert_list_size; - struct fd_list local, remote; struct fifo * myfifo = NULL; struct timespec now; int ev_code;
--- a/freeDiameter/tests/testdict.c Thu Jul 08 12:50:10 2010 +0900 +++ b/freeDiameter/tests/testdict.c Thu Jul 08 14:24:19 2010 +0900 @@ -54,7 +54,6 @@ /* Test creating and searching all types of objects */ { - enum dict_object_type type; struct dict_object * obj1 = NULL; struct dict_object * obj2 = NULL; struct dict_object * obj3 = NULL;
--- a/freeDiameter/tests/testmesg.c Thu Jul 08 12:50:10 2010 +0900 +++ b/freeDiameter/tests/testmesg.c Thu Jul 08 14:24:19 2010 +0900 @@ -1020,11 +1020,9 @@ { struct dict_object * cmd_model = NULL; struct msg * msg = NULL; - struct dict_object * avp_model = NULL; struct avp * avp = NULL; union avp_value value; struct avp * avpi = NULL; - struct avp * avpch = NULL; struct avp_hdr * avpdata = NULL; struct msg_hdr * msgdata = NULL;
--- a/freeDiameter/tests/tests.h Thu Jul 08 12:50:10 2010 +0900 +++ b/freeDiameter/tests/tests.h Thu Jul 08 14:24:19 2010 +0900 @@ -41,6 +41,7 @@ #ifndef _TESTS_H #define _TESTS_H +#include "libfD.h" #include "fD.h" #include <pthread.h>
--- a/freeDiameter/tests/testsess.c Thu Jul 08 12:50:10 2010 +0900 +++ b/freeDiameter/tests/testsess.c Thu Jul 08 14:24:19 2010 +0900 @@ -235,7 +235,6 @@ { struct mystate * ms[6], *tms; int freed[6]; - int i; struct timespec timeout; /* Create three sessions */
--- a/include/freeDiameter/freeDiameter.h Thu Jul 08 12:50:10 2010 +0900 +++ b/include/freeDiameter/freeDiameter.h Thu Jul 08 14:24:19 2010 +0900 @@ -703,6 +703,7 @@ int fd_ep_add_merge( struct fd_list * list, sSA * sa, socklen_t sl, uint32_t flags ); int fd_ep_filter( struct fd_list * list, uint32_t flags ); int fd_ep_filter_family( struct fd_list * list, int af ); +int fd_ep_filter_list( struct fd_list * list, struct fd_list * exclude_list ); int fd_ep_clearflags( struct fd_list * list, uint32_t flags ); void fd_ep_dump_one( char * prefix, struct fd_endpoint * ep, char * suffix ); void fd_ep_dump( int indent, struct fd_list * eps );
--- a/libfreeDiameter/rt_data.c Thu Jul 08 12:50:10 2010 +0900 +++ b/libfreeDiameter/rt_data.c Thu Jul 08 14:24:19 2010 +0900 @@ -222,7 +222,7 @@ /* Finally, remove this (these) peers from the candidate list */ fd_rtd_candidate_del(rtd, sentto, 0); if (origin) - fd_rtd_candidate_del(rtd, origin, originsz); + fd_rtd_candidate_del(rtd, (char *)origin, originsz); /* Done! */ return 0;
--- a/libfreeDiameter/sessions.c Thu Jul 08 12:50:10 2010 +0900 +++ b/libfreeDiameter/sessions.c Thu Jul 08 14:24:19 2010 +0900 @@ -296,7 +296,6 @@ CHECK_POSIX( pthread_mutex_lock(&sess->stlock) ); for (li_st = sess->states.next; li_st != &sess->states; li_st = li_st->next) { struct state * st = (struct state *)(li_st->o); - char * sid_cpy; /* The list is ordered */ if (st->hdl->id < del->id) continue; @@ -333,7 +332,6 @@ { char * sid = NULL; size_t sidlen; - uint32_t hash; struct session * sess; struct fd_list * li; int found = 0;