Mercurial > hg > freeDiameter
comparison libfdproto/messages.c @ 1113:eb4ce68b6e5c
Added calls to remaining hooks
author | Sebastien Decugis <sdecugis@freediameter.net> |
---|---|
date | Mon, 13 May 2013 19:17:13 +0800 |
parents | d8591b1c56cd |
children | 79dd22145f52 |
comparison
equal
deleted
inserted
replaced
1112:d87cee14b051 | 1113:eb4ce68b6e5c |
---|---|
2667 #define TEST_ACTION_STOP() \ | 2667 #define TEST_ACTION_STOP() \ |
2668 if ((*msg == NULL) || (*action != DISP_ACT_CONT)) \ | 2668 if ((*msg == NULL) || (*action != DISP_ACT_CONT)) \ |
2669 goto out; | 2669 goto out; |
2670 | 2670 |
2671 /* Call all dispatch callbacks for a given message */ | 2671 /* Call all dispatch callbacks for a given message */ |
2672 int fd_msg_dispatch ( struct msg ** msg, struct session * session, enum disp_action *action, char ** error_code) | 2672 int fd_msg_dispatch ( struct msg ** msg, struct session * session, enum disp_action *action, char ** error_code, char ** drop_reason, struct msg ** drop_msg) |
2673 { | 2673 { |
2674 struct dictionary * dict; | 2674 struct dictionary * dict; |
2675 struct dict_object * app; | 2675 struct dict_object * app; |
2676 struct dict_object * cmd; | 2676 struct dict_object * cmd; |
2677 struct avp * avp; | 2677 struct avp * avp; |
2681 TRACE_ENTRY("%p %p %p %p", msg, session, action, error_code); | 2681 TRACE_ENTRY("%p %p %p %p", msg, session, action, error_code); |
2682 CHECK_PARAMS( msg && CHECK_MSG(*msg) && action); | 2682 CHECK_PARAMS( msg && CHECK_MSG(*msg) && action); |
2683 | 2683 |
2684 if (error_code) | 2684 if (error_code) |
2685 *error_code = NULL; | 2685 *error_code = NULL; |
2686 if (drop_reason) | |
2687 *drop_reason = NULL; | |
2686 *action = DISP_ACT_CONT; | 2688 *action = DISP_ACT_CONT; |
2687 | 2689 |
2688 /* Take the dispatch lock */ | 2690 /* Take the dispatch lock */ |
2689 CHECK_FCT( pthread_rwlock_rdlock(&fd_disp_lock) ); | 2691 CHECK_FCT( pthread_rwlock_rdlock(&fd_disp_lock) ); |
2690 pthread_cleanup_push( fd_cleanup_rwlock, &fd_disp_lock ); | 2692 pthread_cleanup_push( fd_cleanup_rwlock, &fd_disp_lock ); |
2691 | 2693 |
2692 /* First, call the DISP_HOW_ANY callbacks */ | 2694 /* First, call the DISP_HOW_ANY callbacks */ |
2693 CHECK_FCT_DO( ret = fd_disp_call_cb_int( NULL, msg, NULL, session, action, NULL, NULL, NULL, NULL ), goto out ); | 2695 CHECK_FCT_DO( ret = fd_disp_call_cb_int( NULL, msg, NULL, session, action, NULL, NULL, NULL, NULL, drop_reason, drop_msg ), goto out ); |
2694 | 2696 |
2695 TEST_ACTION_STOP(); | 2697 TEST_ACTION_STOP(); |
2696 | 2698 |
2697 /* If we don't know the model at this point, we stop cause we cannot get the dictionary. It's invalid: an error should already have been trigged by ANY callbacks */ | 2699 /* If we don't know the model at this point, we stop cause we cannot get the dictionary. It's invalid: an error should already have been trigged by ANY callbacks */ |
2698 CHECK_PARAMS_DO(cmd = (*msg)->msg_model, { ret = EINVAL; goto out; } ); | 2700 CHECK_PARAMS_DO(cmd = (*msg)->msg_model, { ret = EINVAL; goto out; } ); |
2705 if ((*msg)->msg_public.msg_flags & CMD_FLAG_REQUEST) { | 2707 if ((*msg)->msg_public.msg_flags & CMD_FLAG_REQUEST) { |
2706 if (error_code) | 2708 if (error_code) |
2707 *error_code = "DIAMETER_APPLICATION_UNSUPPORTED"; | 2709 *error_code = "DIAMETER_APPLICATION_UNSUPPORTED"; |
2708 *action = DISP_ACT_ERROR; | 2710 *action = DISP_ACT_ERROR; |
2709 } else { | 2711 } else { |
2710 //fd_msg_log( FD_MSG_LOG_DROPPED, *msg, "Internal error: Received this answer to a local query with an unsupported application %d", (*msg)->msg_public.msg_appl); | 2712 *drop_reason = "Internal error: Received this answer to a local query with an unsupported application"; |
2711 fd_msg_free(*msg); | 2713 *drop_msg = *msg; |
2712 *msg = NULL; | 2714 *msg = NULL; |
2713 } | 2715 } |
2714 goto out; | 2716 goto out; |
2715 } | 2717 } |
2716 | 2718 |
2737 CHECK_FCT_DO( ret = fd_dict_search(dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &req, &enumval, 0), goto out ); | 2739 CHECK_FCT_DO( ret = fd_dict_search(dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &req, &enumval, 0), goto out ); |
2738 } | 2740 } |
2739 } | 2741 } |
2740 | 2742 |
2741 /* Call the callbacks */ | 2743 /* Call the callbacks */ |
2742 CHECK_FCT_DO( ret = fd_disp_call_cb_int( cb_list, msg, avp, session, action, app, cmd, avp->avp_model, enumval ), goto out ); | 2744 CHECK_FCT_DO( ret = fd_disp_call_cb_int( cb_list, msg, avp, session, action, app, cmd, avp->avp_model, enumval, drop_reason, drop_msg ), goto out ); |
2743 TEST_ACTION_STOP(); | 2745 TEST_ACTION_STOP(); |
2744 } | 2746 } |
2745 /* Go to next AVP */ | 2747 /* Go to next AVP */ |
2746 CHECK_FCT_DO( ret = fd_msg_browse( avp, MSG_BRW_WALK, &avp, NULL ), goto out ); | 2748 CHECK_FCT_DO( ret = fd_msg_browse( avp, MSG_BRW_WALK, &avp, NULL ), goto out ); |
2747 } | 2749 } |
2748 | 2750 |
2749 /* Now call command and application callbacks */ | 2751 /* Now call command and application callbacks */ |
2750 CHECK_FCT_DO( ret = fd_dict_disp_cb(DICT_COMMAND, cmd, &cb_list), goto out ); | 2752 CHECK_FCT_DO( ret = fd_dict_disp_cb(DICT_COMMAND, cmd, &cb_list), goto out ); |
2751 CHECK_FCT_DO( ret = fd_disp_call_cb_int( cb_list, msg, NULL, session, action, app, cmd, NULL, NULL ), goto out ); | 2753 CHECK_FCT_DO( ret = fd_disp_call_cb_int( cb_list, msg, NULL, session, action, app, cmd, NULL, NULL, drop_reason, drop_msg ), goto out ); |
2752 TEST_ACTION_STOP(); | 2754 TEST_ACTION_STOP(); |
2753 | 2755 |
2754 if (app) { | 2756 if (app) { |
2755 CHECK_FCT_DO( ret = fd_dict_disp_cb(DICT_APPLICATION, app, &cb_list), goto out ); | 2757 CHECK_FCT_DO( ret = fd_dict_disp_cb(DICT_APPLICATION, app, &cb_list), goto out ); |
2756 CHECK_FCT_DO( ret = fd_disp_call_cb_int( cb_list, msg, NULL, session, action, app, cmd, NULL, NULL ), goto out ); | 2758 CHECK_FCT_DO( ret = fd_disp_call_cb_int( cb_list, msg, NULL, session, action, app, cmd, NULL, NULL, drop_reason, drop_msg ), goto out ); |
2757 TEST_ACTION_STOP(); | 2759 TEST_ACTION_STOP(); |
2758 } | 2760 } |
2759 out: | 2761 out: |
2760 ; /* some systems would complain without this */ | 2762 ; /* some systems would complain without this */ |
2761 pthread_cleanup_pop(0); | 2763 pthread_cleanup_pop(0); |