00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <config.h>
00020
00021 #include <atf-c.h>
00022
00023 #include <unistd.h>
00024
00025 #include <dns/peer.h>
00026
00027 #include "dnstest.h"
00028
00029
00030
00031
00032 ATF_TC(dscp);
00033 ATF_TC_HEAD(dscp, tc) {
00034 atf_tc_set_md_var(tc, "descr",
00035 "Test DSCP set/get functions");
00036 }
00037 ATF_TC_BODY(dscp, tc) {
00038 isc_result_t result;
00039 isc_netaddr_t netaddr;
00040 struct in_addr ina;
00041 dns_peer_t *peer = NULL;
00042 isc_dscp_t dscp;
00043
00044 result = dns_test_begin(NULL, ISC_TRUE);
00045 ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00046
00047
00048
00049
00050 ina.s_addr = INADDR_LOOPBACK;
00051 isc_netaddr_fromin(&netaddr, &ina);
00052 result = dns_peer_new(mctx, &netaddr, &peer);
00053 ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00054
00055
00056
00057
00058
00059 dscp = 100;
00060 result = dns_peer_getquerydscp(peer, &dscp);
00061 ATF_REQUIRE_EQ(result, ISC_R_NOTFOUND);
00062 ATF_REQUIRE_EQ(dscp, 100);
00063
00064 result = dns_peer_getnotifydscp(peer, &dscp);
00065 ATF_REQUIRE_EQ(result, ISC_R_NOTFOUND);
00066 ATF_REQUIRE_EQ(dscp, 100);
00067
00068 result = dns_peer_gettransferdscp(peer, &dscp);
00069 ATF_REQUIRE_EQ(result, ISC_R_NOTFOUND);
00070 ATF_REQUIRE_EQ(dscp, 100);
00071
00072
00073
00074
00075
00076
00077 dscp = 100;
00078 result = dns_peer_setquerydscp(peer, 1);
00079 ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00080
00081 result = dns_peer_getnotifydscp(peer, &dscp);
00082 ATF_REQUIRE_EQ(result, ISC_R_NOTFOUND);
00083 ATF_REQUIRE_EQ(dscp, 100);
00084
00085 result = dns_peer_gettransferdscp(peer, &dscp);
00086 ATF_REQUIRE_EQ(result, ISC_R_NOTFOUND);
00087 ATF_REQUIRE_EQ(dscp, 100);
00088
00089 result = dns_peer_getquerydscp(peer, &dscp);
00090 ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00091 ATF_REQUIRE_EQ(dscp, 1);
00092
00093
00094
00095
00096
00097
00098
00099 dscp = 100;
00100 result = dns_peer_setnotifydscp(peer, 2);
00101 ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00102
00103 result = dns_peer_gettransferdscp(peer, &dscp);
00104 ATF_REQUIRE_EQ(result, ISC_R_NOTFOUND);
00105 ATF_REQUIRE_EQ(dscp, 100);
00106
00107 result = dns_peer_getquerydscp(peer, &dscp);
00108 ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00109 ATF_REQUIRE_EQ(dscp, 1);
00110
00111 result = dns_peer_getnotifydscp(peer, &dscp);
00112 ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00113 ATF_REQUIRE_EQ(dscp, 2);
00114
00115
00116
00117
00118
00119 dscp = 100;
00120 result = dns_peer_settransferdscp(peer, 3);
00121 ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00122
00123 result = dns_peer_getquerydscp(peer, &dscp);
00124 ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00125 ATF_REQUIRE_EQ(dscp, 1);
00126
00127 result = dns_peer_getnotifydscp(peer, &dscp);
00128 ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00129 ATF_REQUIRE_EQ(dscp, 2);
00130
00131 result = dns_peer_gettransferdscp(peer, &dscp);
00132 ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00133 ATF_REQUIRE_EQ(dscp, 3);
00134
00135 dns_peer_detach(&peer);
00136 dns_test_end();
00137 }
00138
00139
00140
00141
00142 ATF_TP_ADD_TCS(tp) {
00143 ATF_TP_ADD_TC(tp, dscp);
00144 return (atf_no_error());
00145 }