本文整理汇总了C++中AF函数的典型用法代码示例。如果您正苦于以下问题:C++ AF函数的具体用法?C++ AF怎么用?C++ AF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AF函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AF
int HVS_B0307::Init(__u16 v)
{
int rc=Base::Init();
if( rc ) return rc;
rc = AF(afClearLAM)
| AF(afWrite,&v)|AF(afOn);
return rc;
}
示例2: restrict_source
/*
* restrict_source - maintains dynamic "restrict source ..." entries as
* peers come and go.
*/
void
restrict_source(
sockaddr_u * addr,
int farewell, /* 0 to add, 1 to remove */
u_long expire /* 0 is infinite, valid until */
)
{
sockaddr_u onesmask;
restrict_u * res;
int found_specific;
if (!restrict_source_enabled || SOCK_UNSPEC(addr) ||
IS_MCAST(addr) || ISREFCLOCKADR(addr))
return;
REQUIRE(AF_INET == AF(addr) || AF_INET6 == AF(addr));
SET_HOSTMASK(&onesmask, AF(addr));
if (farewell) {
hack_restrict(RESTRICT_REMOVE, addr, &onesmask,
0, 0, 0);
DPRINTF(1, ("restrict_source: %s removed", stoa(addr)));
return;
}
/*
* If there is a specific entry for this address, hands
* off, as it is condidered more specific than "restrict
* server ...".
* However, if the specific entry found is a fleeting one
* added by pool_xmit() before soliciting, replace it
* immediately regardless of the expire value to make way
* for the more persistent entry.
*/
if (IS_IPV4(addr)) {
res = match_restrict4_addr(SRCADR(addr), SRCPORT(addr));
INSIST(res != NULL);
found_specific = (SRCADR(&onesmask) == res->u.v4.mask);
} else {
res = match_restrict6_addr(&SOCK_ADDR6(addr),
SRCPORT(addr));
INSIST(res != NULL);
found_specific = ADDR6_EQ(&res->u.v6.mask,
&SOCK_ADDR6(&onesmask));
}
if (!expire && found_specific && res->expire) {
found_specific = 0;
free_res(res, IS_IPV6(addr));
}
if (found_specific)
return;
hack_restrict(RESTRICT_FLAGS, addr, &onesmask,
restrict_source_mflags, restrict_source_flags,
expire);
DPRINTF(1, ("restrict_source: %s host restriction added\n",
stoa(addr)));
}
示例3: create_socket
/* Creates a socket and returns. */
void
create_socket (
SOCKET *rsock,
sockaddr_u *dest
)
{
*rsock = socket(AF(dest), SOCK_DGRAM, 0);
if (-1 == *rsock && ENABLED_OPT(NORMALVERBOSE))
printf("Failed to create UDP socket with family %d\n", AF(dest));
}
示例4: test_IPv6AddressWithPort
void
test_IPv6AddressWithPort(void) {
#ifdef ISC_PLATFORM_WANTIPV6
const struct in6_addr address = {
0x20, 0x01, 0x0d, 0xb8,
0x85, 0xa3, 0x08, 0xd3,
0x13, 0x19, 0x8a, 0x2e,
0x03, 0x70, 0x73, 0x34
};
const char* expected =
"2001:db8:85a3:8d3:1319:8a2e:370:7334";
const char* expected_port =
"[2001:db8:85a3:8d3:1319:8a2e:370:7334]:123";
sockaddr_u input;
memset(&input, 0, sizeof(input));
AF(&input) = AF_INET6;
SET_ADDR6N(&input, address);
SET_PORT(&input, 123);
TEST_ASSERT_EQUAL_STRING(expected, socktoa(&input));
TEST_ASSERT_EQUAL_STRING(expected_port, sockporttoa(&input));
#else
TEST_IGNORE_MESSAGE("IPV6 disabled in build, skipping.");
#endif /* ISC_PLATFORM_HAVEIPV6 */
}
示例5: test_AddrMatch_anull
void test_AddrMatch_anull(void)
{
/* Check the not-an-address logic with a prefix/check length of
* zero bits. Any compare with a NULL or AF_UNSPEC address
* returns inequality (aka FALSE).
*/
sockaddr_u ip4, ip6, ipn;
memset(&ipn, 0, sizeof(ipn));
AF(&ipn) = AF_UNSPEC;
TEST_ASSERT_TRUE(getaddr(AF_INET , "192.128.1.1", &ip4));
TEST_ASSERT_TRUE(getaddr(AF_INET6, "::1" , &ip6));
TEST_ASSERT_FALSE(keyacc_amatch(NULL, NULL, 0));
TEST_ASSERT_FALSE(keyacc_amatch(NULL, &ipn, 0));
TEST_ASSERT_FALSE(keyacc_amatch(NULL, &ip4, 0));
TEST_ASSERT_FALSE(keyacc_amatch(NULL, &ip6, 0));
TEST_ASSERT_FALSE(keyacc_amatch(&ipn, NULL, 0));
TEST_ASSERT_FALSE(keyacc_amatch(&ipn, &ipn, 0));
TEST_ASSERT_FALSE(keyacc_amatch(&ipn, &ip4, 0));
TEST_ASSERT_FALSE(keyacc_amatch(&ipn, &ip6, 0));
TEST_ASSERT_FALSE(keyacc_amatch(&ip4, NULL, 0));
TEST_ASSERT_FALSE(keyacc_amatch(&ip4, &ipn, 0));
TEST_ASSERT_FALSE(keyacc_amatch(&ip6, NULL, 0));
TEST_ASSERT_FALSE(keyacc_amatch(&ip6, &ipn, 0));
}
示例6: _inet_ntop
string CAddress::ToString() const
{
char Dest[65] = {'\0'};
if(m_eAF != None)
_inet_ntop(AF(), m_IP, Dest, 65);
return Dest;
}
示例7: test_ScopedIPv6AddressWithPort
void
test_ScopedIPv6AddressWithPort(void) {
#ifdef ISC_PLATFORM_HAVESCOPEID
const struct in6_addr address = { { {
0xfe, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x02, 0x12, 0x3f, 0xff,
0xfe, 0x29, 0xff, 0xfa
} } };
const char* expected =
"fe80::212:3fff:fe29:fffa%5";
const char* expected_port =
"[fe80::212:3fff:fe29:fffa%5]:123";
sockaddr_u input;
memset(&input, 0, sizeof(input));
AF(&input) = AF_INET6;
SET_ADDR6N(&input, address);
SET_PORT(&input, 123);
SCOPE_VAR(&input) = 5;
TEST_ASSERT_EQUAL_STRING(expected, socktoa(&input));
TEST_ASSERT_EQUAL_STRING(expected_port, sockporttoa(&input));
#else
TEST_IGNORE_MESSAGE("Skipping because ISC_PLATFORM does not have Scope ID");
#endif
}
示例8: AF
int Coincide_C0308::GetMaskAND(u8_t* mask, COI_ch_t ch)
{
u16_t tmp;
int rc = AF(afGetAND[ch], &tmp);
*mask = tmp & maxAndMask;
return rc;
}
示例9: decodeaddrtype
static char
decodeaddrtype(
sockaddr_u *sock
)
{
char ch = '-';
u_int32 dummy;
switch(AF(sock)) {
case AF_INET:
dummy = SRCADR(sock);
ch = (char)(((dummy&0xf0000000)==0xe0000000) ? 'm' :
((dummy&0x000000ff)==0x000000ff) ? 'b' :
((dummy&0xffffffff)==0x7f000001) ? 'l' :
((dummy&0xffffffe0)==0x00000000) ? '-' :
'u');
break;
case AF_INET6:
if (IN6_IS_ADDR_MULTICAST(PSOCK_ADDR6(sock)))
ch = 'm';
else
ch = 'u';
break;
default:
ch = '-';
break;
}
return ch;
}
示例10: socktoa
/*
* socktoa - return a numeric host name from a sockaddr_storage structure
*/
const char *
socktoa(
const sockaddr_u *sock
)
{
int saved_errno;
char * res;
char * addr;
u_long scope;
saved_errno = errno;
LIB_GETBUF(res);
if (NULL == sock) {
strlcpy(res, "(null)", LIB_BUFLENGTH);
} else {
switch(AF(sock)) {
case AF_INET:
case AF_UNSPEC:
inet_ntop(AF_INET, PSOCK_ADDR4(sock), res,
LIB_BUFLENGTH);
break;
case AF_INET6:
inet_ntop(AF_INET6, PSOCK_ADDR6(sock), res,
LIB_BUFLENGTH);
scope = SCOPE_VAR(sock);
if (0 != scope && !strchr(res, '%')) {
addr = res;
LIB_GETBUF(res);
snprintf(res, LIB_BUFLENGTH, "%s%%%lu",
addr, scope);
res[LIB_BUFLENGTH - 1] = '\0';
}
break;
default:
snprintf(res, LIB_BUFLENGTH,
"(socktoa unknown family %d)",
AF(sock));
}
}
errno = saved_errno;
return res;
}
示例11:
int HVS_B0307::ReadCode(__u16* pcode)
{
u16_t data;
int rc=AF(afRead, &data);
if ( rc&CAMAC_CC_ERRORS ) return rc;
*pcode = data;
return rc;
}
示例12: main
int main()
{
FILE *input, *output;
input=fopen("input.dat","r");
output=fopen("output.dat","w");
int x;
char c[1024];
lista = (SENTINEL*) malloc(sizeof(SENTINEL));
lista->head=0;
lista->tail=0;
while(fscanf(input,"%s",c)!=EOF)
{
if(strcmp(c,"PRINT_ALL")==0)
PRINT_ALL(output);
else
if(strcmp(c,"AF")==0)
{
fscanf(input,"%d",&x);
AF(x);
}
else
if(strcmp(c,"AL")==0)
{
fscanf(input,"%d",&x);
AL(x);
}
else
if(strcmp(c,"DF")==0)
DF();
else
if(strcmp(c,"DL")==0)
DL();
else
if(strcmp(c,"DOOM_THE_LIST")==0)
DOOM_THE_LIST();
else
if(strcmp(c,"DE")==0)
{
fscanf(input,"%d",&x);
DE(x);
}
else
if(strcmp(c,"PRINT_F")==0)
{
fscanf(input,"%d",&x);
PRINT_F(x,output);
}
else
if(strcmp(c,"PRINT_L")==0)
{
fscanf(input,"%d",&x);
PRINT_L(x,output);
}
}
return 0;
}
示例13: if
bool CAddress::FromString(const std::string& Str)
{
if(Str.find(".") != string::npos)
m_eAF = IPv4;
else if(Str.find(":") != string::npos)
m_eAF = IPv6;
else
return false;
return _inet_pton(AF(), Str.c_str(), m_IP) == 1;
}
示例14: getMinARead
int64_t getMinARead() const
{
libmaus2::aio::InputStreamInstance AISI(lasfn);
libmaus2::dazzler::align::AlignmentFile AF(AISI);
libmaus2::dazzler::align::Overlap OVL;
if ( AF.getNextOverlap(AISI,OVL) )
return OVL.aread;
else
return -1;
}
示例15: main
int main()
{
FILE *g;
l=0;
head=NULL;
tail=NULL;
g=fopen("input.txt", "r");
char cuvant[15];
int n;
if (g==NULL)
{
printf("Error in opening the file.");
exit(1);
}
while(fscanf(g,"%s",cuvant)>0)
{
if (strcmp(cuvant,"AF")==0)
{
fscanf(g,"%d",&n);
AF(n);
}
else if (strcmp(cuvant,"AL")==0)
{
fscanf(g,"%d",&n);
AL(n);
}
else if (strcmp(cuvant,"DF")==0)
DF();
else if(strcmp(cuvant,"DL")==0)
DL();
else if(strcmp(cuvant,"DE")==0)
{
fscanf(g,"%d",&n);
DE(n);
}
else if(strcmp(cuvant,"PRINT_ALL")==0)
PRINT_ALL();
else if(strcmp(cuvant,"PRINT_F")==0)
{
fscanf(g,"%d",&n);
PRINT_F(n);
}
else if(strcmp(cuvant,"PRINT_L")==0)
{
fscanf(g,"%d",&n);
PRINT_L(n);
}
else if(strcmp(cuvant,"DOOM_THE_LIST")==0)
DOOM_THE_LIST();
}
fclose(g);
printf("%d",l);
return 0;
}