Mercurial > hg > freeDiameter
comparison include/freeDiameter/libfdcore.h @ 1425:b09f1b4c9fad
fd_msg_add_result: add function
Add fd_msg_add_result() as a superset of fd_msg_rescode_set()
to allow setting of either Result-Code or Experimental-Result (Grouped),
depending upon whether the supplied vendor is 0 or not.
Reimplement fd_msg_rescode_set() in terms of fd_msg_add_result().
author | Luke Mewburn <luke@mewburn.net> |
---|---|
date | Wed, 19 Feb 2020 10:26:29 +1100 |
parents | 239ba25870d8 |
children | 407e0a889c7e |
comparison
equal
deleted
inserted
replaced
1424:c8057892e56b | 1425:b09f1b4c9fad |
---|---|
550 */ | 550 */ |
551 int fd_msg_send ( struct msg ** pmsg, void (*anscb)(void *, struct msg **), void * data ); | 551 int fd_msg_send ( struct msg ** pmsg, void (*anscb)(void *, struct msg **), void * data ); |
552 int fd_msg_send_timeout ( struct msg ** pmsg, void (*anscb)(void *, struct msg **), void * data, void (*expirecb)(void *, DiamId_t, size_t, struct msg **), const struct timespec *timeout ); | 552 int fd_msg_send_timeout ( struct msg ** pmsg, void (*anscb)(void *, struct msg **), void * data, void (*expirecb)(void *, DiamId_t, size_t, struct msg **), const struct timespec *timeout ); |
553 | 553 |
554 /* | 554 /* |
555 * FUNCTION: fd_msg_add_result | |
556 * | |
557 * PARAMETERS: | |
558 * msg : A msg object -- it must be an answer. | |
559 * vendor : Vendor. If 0, add Result-Code else add Experimental-Result. | |
560 * restype : DICT_TYPE containing rescode (ex: from TYPE_BY_NAME "Enumerated(Result-Code)"). | |
561 * rescode : The name of the returned error code (ex: "DIAMETER_INVALID_AVP"). | |
562 * errormsg : (optional) human-readable error message to put in Error-Message AVP. | |
563 * optavp : (optional) If provided, the content will be put inside a Failed-AVP. | |
564 * type_id : 0 => nothing; 1 => adds Origin-Host and Origin-Realm with local info. 2=> adds Error-Reporting-Host. | |
565 * | |
566 * DESCRIPTION: | |
567 * This function adds a Result-Code AVP (if vendor is 0) or Experimental-Result AVP (vendor is not 0) | |
568 * to a message, and optionally | |
569 * - sets the 'E' error flag in the header, | |
570 * - adds Error-Message, Error-Reporting-Host and Failed-AVP AVPs. | |
571 * | |
572 * RETURN VALUE: | |
573 * 0 : Operation complete. | |
574 * !0 : an error occurred. | |
575 */ | |
576 int fd_msg_add_result( struct msg * msg, vendor_id_t vendor, struct dict_object * restype, char * rescode, char * errormsg, struct avp * optavp, int type_id ); | |
577 | |
578 /* | |
555 * FUNCTION: fd_msg_rescode_set | 579 * FUNCTION: fd_msg_rescode_set |
556 * | 580 * |
557 * PARAMETERS: | 581 * PARAMETERS: |
558 * msg : A msg object -- it must be an answer. | 582 * msg : A msg object -- it must be an answer. |
559 * rescode : The name of the returned error code (ex: "DIAMETER_INVALID_AVP") | 583 * rescode : The name of the returned error code (ex: "DIAMETER_INVALID_AVP") |
560 * errormsg : (optional) human-readable error message to put in Error-Message AVP | 584 * errormsg : (optional) human-readable error message to put in Error-Message AVP |
561 * optavp : (optional) If provided, the content will be put inside a Failed-AVP | 585 * optavp : (optional) If provided, the content will be put inside a Failed-AVP |
562 * type_id : 0 => nothing; 1 => adds Origin-Host and Origin-Realm with local info. 2=> adds Error-Reporting-Host. | 586 * type_id : 0 => nothing; 1 => adds Origin-Host and Origin-Realm with local info. 2=> adds Error-Reporting-Host. |
563 * | 587 * |
564 * DESCRIPTION: | 588 * DESCRIPTION: |
565 * This function adds a Result-Code AVP to a message, and optionally | 589 * This function adds a Result-Code AVP to a message, and optionally |
566 * - sets the 'E' error flag in the header, | 590 * - sets the 'E' error flag in the header, |
567 * - adds Error-Message, Error-Reporting-Host and Failed-AVP AVPs. | 591 * - adds Error-Message, Error-Reporting-Host and Failed-AVP AVPs. |
568 * | 592 * Uses fd_msg_add_result with vendor 0 and restype for Enumerated(Result-Code). |
569 * RETURN VALUE: | 593 * |
570 * 0 : Operation complete. | 594 * RETURN VALUE: |
571 * !0 : an error occurred. | 595 * 0 : Operation complete. |
596 * !0 : an error occurred. | |
572 */ | 597 */ |
573 int fd_msg_rescode_set( struct msg * msg, char * rescode, char * errormsg, struct avp * optavp, int type_id ); | 598 int fd_msg_rescode_set( struct msg * msg, char * rescode, char * errormsg, struct avp * optavp, int type_id ); |
574 | 599 |
575 /* Add Origin-Host, Origin-Realm, (if osi) Origin-State-Id AVPS at the end of the message */ | 600 /* Add Origin-Host, Origin-Realm, (if osi) Origin-State-Id AVPS at the end of the message */ |
576 int fd_msg_add_origin ( struct msg * msg, int osi ); | 601 int fd_msg_add_origin ( struct msg * msg, int osi ); |