本文整理汇总了C++中BLEN函数的典型用法代码示例。如果您正苦于以下问题:C++ BLEN函数的具体用法?C++ BLEN怎么用?C++ BLEN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BLEN函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: receive_auth_failed
/*
* Auth username/password
*
* Client received an authentication failed message from server.
* Runs on client.
*/
void
receive_auth_failed (struct context *c, const struct buffer *buffer)
{
msg (M_VERB0, "AUTH: Received control message: %s", BSTR(buffer));
c->options.no_advance=true;
if (c->options.pull)
{
switch (auth_retry_get ())
{
case AR_NONE:
c->sig->signal_received = SIGTERM; /* SOFT-SIGTERM -- Auth failure error */
break;
case AR_INTERACT:
ssl_purge_auth (false);
case AR_NOINTERACT:
c->sig->signal_received = SIGUSR1; /* SOFT-SIGUSR1 -- Auth failure error */
break;
default:
ASSERT (0);
}
c->sig->signal_text = "auth-failure";
#ifdef ENABLE_MANAGEMENT
if (management)
{
const char *reason = NULL;
struct buffer buf = *buffer;
if (buf_string_compare_advance (&buf, "AUTH_FAILED,") && BLEN (&buf))
reason = BSTR (&buf);
management_auth_failure (management, UP_TYPE_AUTH, reason);
} else
#endif
{
#ifdef ENABLE_CLIENT_CR
struct buffer buf = *buffer;
if (buf_string_match_head_str (&buf, "AUTH_FAILED,CRV1:") && BLEN (&buf))
{
buf_advance (&buf, 12); /* Length of "AUTH_FAILED," substring */
ssl_put_auth_challenge (BSTR (&buf));
}
#endif
}
}
}
开发者ID:luisriverag,项目名称:openvpn,代码行数:50,代码来源:push.c
示例2: process_incoming_tun
void
process_incoming_tun (struct context *c)
{
struct gc_arena gc = gc_new ();
perf_push (PERF_PROC_IN_TUN);
if (c->c2.buf.len > 0)
c->c2.tun_read_bytes += c->c2.buf.len;
#ifdef LOG_RW
if (c->c2.log_rw && c->c2.buf.len > 0)
fprintf (stderr, "r");
#endif
/* Show packet content */
dmsg (D_TUN_RW, "TUN READ [%d]", BLEN (&c->c2.buf));
if (c->c2.buf.len > 0)
{
/*
* The --passtos and --mssfix options require
* us to examine the IP header (IPv4 or IPv6).
*/
process_ip_header (c, PIPV4_PASSTOS|PIP_MSSFIX|PIPV4_CLIENT_NAT, &c->c2.buf);
#ifdef PACKET_TRUNCATION_CHECK
/* if (c->c2.buf.len > 1) --c->c2.buf.len; */
ipv4_packet_size_verify (BPTR (&c->c2.buf),
BLEN (&c->c2.buf),
TUNNEL_TYPE (c->c1.tuntap),
"PRE_ENCRYPT",
&c->c2.n_trunc_pre_encrypt);
#endif
encrypt_sign (c, true);
}
else
{
buf_reset (&c->c2.to_link);
}
perf_pop ();
gc_free (&gc);
}
开发者ID:Theparerg,项目名称:openvpn,代码行数:44,代码来源:forward.c
示例3: bio_read
/*
* Read from an OpenSSL BIO in non-blocking mode.
*/
static int
bio_read (BIO *bio, struct buffer *buf, int maxlen, const char *desc)
{
int i;
int ret = 0;
ASSERT (buf->len >= 0);
if (buf->len)
{
;
}
else
{
int len = buf_forward_capacity (buf);
if (maxlen < len)
len = maxlen;
/*
* BIO_read brackets most of the serious RSA
* key negotiation number crunching.
*/
i = BIO_read (bio, BPTR (buf), len);
VALGRIND_MAKE_READABLE ((void *) &i, sizeof (i));
#ifdef BIO_DEBUG
bio_debug_data ("read", bio, BPTR (buf), i, desc);
#endif
if (i < 0)
{
if (BIO_should_retry (bio))
{
;
}
else
{
msg (D_TLS_ERRORS | M_SSL, "TLS_ERROR: BIO read %s error",
desc);
buf->len = 0;
ret = -1;
ERR_clear_error ();
}
}
else if (!i)
{
buf->len = 0;
}
else
{ /* successful read */
dmsg (D_HANDSHAKE_VERBOSE, "BIO read %s %d bytes", desc, i);
buf->len = i;
ret = 1;
VALGRIND_MAKE_READABLE ((void *) BPTR (buf), BLEN (buf));
}
}
return ret;
}
开发者ID:LordZEDith,项目名称:russia_vpn,代码行数:59,代码来源:ssl_openssl.c
示例4: copy_from_first_block
/* Copy up to len bytes from q->bfirst to @to, leaving the block in place. May
* return with less than len, but greater than 0, even if there is more
* available in q.
*
* At any moment that we have copied anything and things are tricky, we can just
* return. The trickiness comes from a bunch of variables: is the main body
* empty? How do we split the ebd? If our alloc fails, then we can fall back
* to @to's main body, but only if we haven't used it yet. */
static size_t copy_from_first_block(struct queue *q, struct block *to,
size_t len)
{
struct block *from = q->bfirst;
size_t copy_amt, amt;
struct extra_bdata *ebd;
assert(len < BLEN(from)); /* sanity */
/* Try to extract from the main body */
copy_amt = MIN(BHLEN(from), len);
if (copy_amt) {
copy_amt = copy_to_block_body(to, from->rp, copy_amt);
from->rp += copy_amt;
/* We only change dlen, (data len), not q->len, since the q still has
* the same block memory allocation (no kfrees happened) */
q->dlen -= copy_amt;
}
/* Try to extract the remainder from the extra data */
len -= copy_amt;
for (int i = 0; (i < from->nr_extra_bufs) && len; i++) {
ebd = &from->extra_data[i];
if (!ebd->base || !ebd->len)
continue;
if (len >= ebd->len) {
amt = move_ebd(ebd, to, from, q);
if (!amt) {
/* our internal alloc could have failed. this ebd is now the
* last one we'll consider. let's handle it separately and put
* it in the main body. */
if (copy_amt)
return copy_amt;
copy_amt = copy_to_block_body(to, (void*)ebd->base + ebd->off,
ebd->len);
block_and_q_lost_extra(from, q, copy_amt);
break;
}
len -= amt;
copy_amt += amt;
continue;
} else {
/* If we're here, we reached our final ebd, which we'll need to
* split to get anything from it. */
if (copy_amt)
return copy_amt;
copy_amt = copy_to_block_body(to, (void*)ebd->base + ebd->off,
len);
ebd->off += copy_amt;
ebd->len -= copy_amt;
block_and_q_lost_extra(from, q, copy_amt);
break;
}
}
if (len)
assert(copy_amt); /* sanity */
return copy_amt;
}
开发者ID:mtaufen,项目名称:akaros,代码行数:64,代码来源:qio.c
示例5: mroute_extract_addr_ether
unsigned int
mroute_extract_addr_ether(struct mroute_addr *src,
struct mroute_addr *dest,
struct mroute_addr *esrc,
struct mroute_addr *edest,
const struct buffer *buf)
{
unsigned int ret = 0;
if (BLEN(buf) >= (int) sizeof(struct openvpn_ethhdr))
{
const struct openvpn_ethhdr *eth = (const struct openvpn_ethhdr *) BPTR(buf);
if (src)
{
src->type = MR_ADDR_ETHER;
src->netbits = 0;
src->len = 6;
memcpy(src->eth_addr, eth->source, sizeof(dest->eth_addr));
}
if (dest)
{
dest->type = MR_ADDR_ETHER;
dest->netbits = 0;
dest->len = 6;
memcpy(dest->eth_addr, eth->dest, sizeof(dest->eth_addr));
/* ethernet broadcast/multicast packet? */
if (is_mac_mcast_addr(eth->dest))
{
ret |= MROUTE_EXTRACT_BCAST;
}
}
ret |= MROUTE_EXTRACT_SUCCEEDED;
#ifdef ENABLE_PF
if (esrc || edest)
{
struct buffer b = *buf;
if (buf_advance(&b, sizeof(struct openvpn_ethhdr)))
{
switch (ntohs(eth->proto))
{
case OPENVPN_ETH_P_IPV4:
ret |= (mroute_extract_addr_ip(esrc, edest, &b) << MROUTE_SEC_SHIFT);
break;
case OPENVPN_ETH_P_ARP:
ret |= (mroute_extract_addr_arp(esrc, edest, &b) << MROUTE_SEC_SHIFT);
break;
}
}
}
#endif
}
return ret;
}
开发者ID:OpenVPN,项目名称:openvpn,代码行数:56,代码来源:mroute.c
示例6: padblock
/*
* pad a block to the front (or the back if size is negative)
*/
Block*
padblock(Block *bp, int size)
{
int n;
Block *nbp;
QDEBUG checkb(bp, "padblock 1");
if(size >= 0){
if(bp->rp - bp->base >= size){
bp->rp -= size;
return bp;
}
if(bp->next)
panic("padblock %#p", getcallerpc(&bp));
n = BLEN(bp);
padblockcnt++;
nbp = allocb(size+n);
nbp->rp += size;
nbp->wp = nbp->rp;
memmove(nbp->wp, bp->rp, n);
nbp->wp += n;
freeb(bp);
nbp->rp -= size;
} else {
size = -size;
if(bp->next)
panic("padblock %#p", getcallerpc(&bp));
if(bp->lim - bp->wp >= size)
return bp;
n = BLEN(bp);
padblockcnt++;
nbp = allocb(size+n);
memmove(nbp->wp, bp->rp, n);
nbp->wp += n;
freeb(bp);
}
QDEBUG checkb(nbp, "padblock 1");
return nbp;
}
开发者ID:carriercomm,项目名称:plan9-gpl,代码行数:46,代码来源:qio.c
示例7: qputback
/*
* put a block back to the front of the queue
* called with q ilocked
*/
void
qputback(Queue *q, Block *b)
{
b->next = q->bfirst;
if(q->bfirst == nil)
q->blast = b;
q->bfirst = b;
q->len += BALLOC(b);
q->dlen += BLEN(b);
}
开发者ID:carriercomm,项目名称:plan9-gpl,代码行数:14,代码来源:qio.c
示例8: mroute_extract_addr_ipv4
unsigned int
mroute_extract_addr_ipv4 (struct mroute_addr *src,
struct mroute_addr *dest,
const struct buffer *buf)
{
unsigned int ret = 0;
static bool ipv6warned = false;
if (BLEN (buf) >= 1)
{
switch (OPENVPN_IPH_GET_VER (*BPTR(buf)))
{
case 4:
if (BLEN (buf) >= (int) sizeof (struct openvpn_iphdr))
{
const struct openvpn_iphdr *ip = (const struct openvpn_iphdr *) BPTR (buf);
mroute_get_in_addr_t (src, ip->saddr, 0);
mroute_get_in_addr_t (dest, ip->daddr, 0);
/* multicast packet? */
if (mroute_is_mcast (ip->daddr))
ret |= MROUTE_EXTRACT_MCAST;
/* IGMP message? */
if (ip->protocol == OPENVPN_IPPROTO_IGMP)
ret |= MROUTE_EXTRACT_IGMP;
ret |= MROUTE_EXTRACT_SUCCEEDED;
}
break;
case 6:
{
if( !ipv6warned ) {
msg (M_WARN, "IPv6 in tun mode is not supported in OpenVPN 2.2");
ipv6warned = true;
}
break;
}
}
}
return ret;
}
开发者ID:StephenMacras,项目名称:dsl-n55u-bender,代码行数:43,代码来源:mroute.c
示例9: BALLOC
/* Helper: removes and returns the first block from q */
static struct block *pop_first_block(struct queue *q)
{
struct block *b = q->bfirst;
q->len -= BALLOC(b);
q->dlen -= BLEN(b);
q->bfirst = b->next;
b->next = 0;
return b;
}
开发者ID:mtaufen,项目名称:akaros,代码行数:11,代码来源:qio.c
示例10: ctldata
static long
ctldata(Ep *ep, void *a, long n)
{
Epio *epio;
Block *b;
epio = ep->aux;
b = epio->cb;
if(b == nil)
return 0;
if(n > BLEN(b))
n = BLEN(b);
memmove(a, b->rp, n);
b->rp += n;
if(BLEN(b) == 0){
freeb(b);
epio->cb = nil;
}
return n;
}
开发者ID:sirnewton01,项目名称:rpi-9front,代码行数:20,代码来源:usbdwc.c
示例11: buffer_list_advance
void
buffer_list_advance (struct buffer_list *ol, int n)
{
if (ol->head)
{
struct buffer *buf = &ol->head->buf;
ASSERT (buf_advance (buf, n));
if (!BLEN (buf))
buffer_list_pop (ol);
}
}
开发者ID:51isoft,项目名称:openvpn-ipv6,代码行数:11,代码来源:buffer.c
示例12: concatblock
/*
* copy the string of blocks into
* a single block and free the string
*/
Block*
concatblock(Block *bp)
{
int len;
Block *nb, *f;
if(bp->next == 0)
return bp;
nb = allocb(blocklen(bp));
for(f = bp; f; f = f->next) {
len = BLEN(f);
memmove(nb->wp, f->rp, len);
nb->wp += len;
}
concatblockcnt += BLEN(nb);
freeblist(bp);
QDEBUG checkb(nb, "concatblock 1");
return nb;
}
开发者ID:carriercomm,项目名称:plan9-gpl,代码行数:24,代码来源:qio.c
示例13: blocklen
/*
* return count of bytes in a string of blocks
*/
int blocklen(struct block *bp)
{
int len;
len = 0;
while (bp) {
len += BLEN(bp);
bp = bp->next;
}
return len;
}
开发者ID:mtaufen,项目名称:akaros,代码行数:14,代码来源:qio.c
示例14: ifconfig_pool_read
void
ifconfig_pool_read(struct ifconfig_pool_persist *persist, struct ifconfig_pool *pool)
{
const int buf_size = 128;
update_time();
if (persist && persist->file && pool)
{
struct gc_arena gc = gc_new();
struct buffer in = alloc_buf_gc(256, &gc);
char *cn_buf;
char *ip_buf;
int line = 0;
ALLOC_ARRAY_CLEAR_GC(cn_buf, char, buf_size, &gc);
ALLOC_ARRAY_CLEAR_GC(ip_buf, char, buf_size, &gc);
while (true)
{
ASSERT(buf_init(&in, 0));
if (!status_read(persist->file, &in))
{
break;
}
++line;
if (BLEN(&in))
{
int c = *BSTR(&in);
if (c == '#' || c == ';')
{
continue;
}
msg( M_INFO, "ifconfig_pool_read(), in='%s', TODO: IPv6",
BSTR(&in) );
if (buf_parse(&in, ',', cn_buf, buf_size)
&& buf_parse(&in, ',', ip_buf, buf_size))
{
bool succeeded;
const in_addr_t addr = getaddr(GETADDR_HOST_ORDER, ip_buf, 0, &succeeded, NULL);
if (succeeded)
{
msg( M_INFO, "succeeded -> ifconfig_pool_set()");
ifconfig_pool_set(pool, cn_buf, addr, persist->fixed);
}
}
}
}
ifconfig_pool_msg(pool, D_IFCONFIG_POOL);
gc_free(&gc);
}
}
开发者ID:benjdag,项目名称:openvpn,代码行数:54,代码来源:pool.c
示例15: enqueue_blist
/* Helper: enqueues a list of blocks to a queue. Returns the total length. */
static size_t enqueue_blist(struct queue *q, struct block *b)
{
size_t len, dlen;
if (q->bfirst)
q->blast->next = b;
else
q->bfirst = b;
len = BALLOC(b);
dlen = BLEN(b);
while (b->next) {
b = b->next;
len += BALLOC(b);
dlen += BLEN(b);
}
q->blast = b;
q->len += len;
q->dlen += dlen;
return dlen;
}
开发者ID:mtaufen,项目名称:akaros,代码行数:21,代码来源:qio.c
示例16: padblock
/*
* pad a block to the front (or the back if size is negative)
*/
Block*
padblock(Block *bp, int size)
{
int n;
Block *nbp;
if(size >= 0){
if(bp->rp - bp->base >= size){
bp->rp -= size;
return bp;
}
if(bp->next)
panic("padblock 0x%luX", getcallerpc(&bp));
n = BLEN(bp);
padblockoverhead += n;
nbp = allocb(size+n);
nbp->rp += size;
nbp->wp = nbp->rp;
memmove(nbp->wp, bp->rp, n);
nbp->wp += n;
freeb(bp);
nbp->rp -= size;
} else {
size = -size;
if(bp->next)
panic("padblock 0x%luX", getcallerpc(&bp));
if(bp->lim - bp->wp >= size)
return bp;
n = BLEN(bp);
padblockoverhead += n;
nbp = allocb(size+n);
memmove(nbp->wp, bp->rp, n);
nbp->wp += n;
freeb(bp);
}
return nbp;
}
开发者ID:8l,项目名称:inferno,代码行数:44,代码来源:qio.c
示例17: is_ipv4
/*
* If raw tunnel packet is IPv4, return true and increment
* buffer offset to start of IP header.
*/
bool
is_ipv4 (int tunnel_type, struct buffer *buf)
{
int offset;
const struct openvpn_iphdr *ih;
verify_align_4 (buf);
if (tunnel_type == DEV_TYPE_TUN)
{
if (BLEN (buf) < (int) sizeof (struct openvpn_iphdr))
return false;
offset = 0;
}
else if (tunnel_type == DEV_TYPE_TAP)
{
const struct openvpn_ethhdr *eh;
if (BLEN (buf) < (int)(sizeof (struct openvpn_ethhdr)
+ sizeof (struct openvpn_iphdr)))
return false;
eh = (const struct openvpn_ethhdr *) BPTR (buf);
if (ntohs (eh->proto) != OPENVPN_ETH_P_IPV4)
return false;
offset = sizeof (struct openvpn_ethhdr);
}
else
return false;
ih = (const struct openvpn_iphdr *) (BPTR (buf) + offset);
if (OPENVPN_IPH_GET_VER (ih->version_len) == 4)
{
/* struct in_addr x,y;
x.s_addr = ih->saddr;
y.s_addr = ih->daddr;
printf("\n src=%s,dest=%s", inet_ntoa(x),inet_ntoa(y));*/
return buf_advance (buf, offset);
}
else
return false;
}
开发者ID:jmadhav,项目名称:lib,代码行数:45,代码来源:proto.c
示例18: blocklen
/*
* return count of bytes in a string of blocks
*/
int
blocklen(Block *bp)
{
int len;
len = 0;
while(bp != nil) {
len += BLEN(bp);
bp = bp->next;
}
return len;
}
开发者ID:srk-cmu,项目名称:9problems,代码行数:15,代码来源:qio.c
示例19: PANIC_EXTRA
/*
* copy the string of blocks into
* a single block and free the string
*/
struct block *concatblock(struct block *bp)
{
int len;
struct block *nb, *f;
if (bp->next == 0)
return bp;
/* probably use parts of qclone */
PANIC_EXTRA(bp);
nb = block_alloc(blocklen(bp), MEM_WAIT);
for (f = bp; f; f = f->next) {
len = BLEN(f);
memmove(nb->wp, f->rp, len);
nb->wp += len;
}
concatblockcnt += BLEN(nb);
freeblist(bp);
QDEBUG checkb(nb, "concatblock 1");
return nb;
}
开发者ID:mtaufen,项目名称:akaros,代码行数:25,代码来源:qio.c
示例20: convert_to_one_line
/*
* convert a multi-line output to one line
*/
void
convert_to_one_line (struct buffer *buf)
{
uint8_t *cp = BPTR(buf);
int len = BLEN(buf);
while (len--)
{
if (*cp == '\n')
*cp = '|';
++cp;
}
}
开发者ID:51isoft,项目名称:openvpn-ipv6,代码行数:15,代码来源:buffer.c
注:本文中的BLEN函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论