version 1.1, 2012/02/21 22:14:23
|
version 1.1.1.3, 2021/03/16 23:47:28
|
Line 50 static libnet_cq_t *l_cq = NULL;
|
Line 50 static libnet_cq_t *l_cq = NULL;
|
static libnet_cqd_t l_cqd = {0, CQ_LOCK_UNLOCKED, NULL}; |
static libnet_cqd_t l_cqd = {0, CQ_LOCK_UNLOCKED, NULL}; |
|
|
|
|
static inline int set_cq_lock(u_int x) | static int |
| set_cq_lock(uint x) |
{ |
{ |
if (check_cq_lock(x)) |
if (check_cq_lock(x)) |
{ |
{ |
Line 61 static inline int set_cq_lock(u_int x)
|
Line 62 static inline int set_cq_lock(u_int x)
|
return (1); |
return (1); |
} |
} |
|
|
static inline int clear_cq_lock(u_int x) | static int |
| clear_cq_lock(uint x) |
{ |
{ |
if (!check_cq_lock(x)) |
if (!check_cq_lock(x)) |
{ |
{ |
Line 114 libnet_cq_add(libnet_t *l, char *label)
|
Line 116 libnet_cq_add(libnet_t *l, char *label)
|
|
|
/* label the context with the user specified string */ |
/* label the context with the user specified string */ |
strncpy(l->label, label, LIBNET_LABEL_SIZE); |
strncpy(l->label, label, LIBNET_LABEL_SIZE); |
l->label[LIBNET_LABEL_SIZE] = '\0'; | l->label[LIBNET_LABEL_SIZE - 1] = '\0'; |
|
|
l_cq->next = NULL; |
l_cq->next = NULL; |
l_cq->prev = NULL; |
l_cq->prev = NULL; |
Line 145 libnet_cq_add(libnet_t *l, char *label)
|
Line 147 libnet_cq_add(libnet_t *l, char *label)
|
|
|
/* label the context with the user specified string */ |
/* label the context with the user specified string */ |
strncpy(l->label, label, LIBNET_LABEL_SIZE); |
strncpy(l->label, label, LIBNET_LABEL_SIZE); |
l->label[LIBNET_LABEL_SIZE] = '\0'; | l->label[LIBNET_LABEL_SIZE -1] = '\0'; |
|
|
new->next = l_cq; |
new->next = l_cq; |
new->prev = NULL; |
new->prev = NULL; |
Line 174 libnet_cq_remove(libnet_t *l)
|
Line 176 libnet_cq_remove(libnet_t *l)
|
|
|
if (l == NULL) |
if (l == NULL) |
{ |
{ |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, |
|
"%s(): can't remove empty libnet context\n", __func__); |
|
return(NULL); |
return(NULL); |
} |
} |
|
|
Line 325 libnet_cq_find_by_label(char *label)
|
Line 325 libnet_cq_find_by_label(char *label)
|
return (p ? p->context : NULL); |
return (p ? p->context : NULL); |
} |
} |
|
|
int8_t * | const char * |
libnet_cq_getlabel(libnet_t *l) |
libnet_cq_getlabel(libnet_t *l) |
{ |
{ |
return (l->label); |
return (l->label); |
Line 344 libnet_cq_destroy()
|
Line 344 libnet_cq_destroy()
|
libnet_destroy(tmp->context); |
libnet_destroy(tmp->context); |
free(tmp); |
free(tmp); |
} |
} |
|
l_cq = NULL; |
|
memset(&l_cqd, 0, sizeof(l_cqd)); |
} |
} |
|
|
libnet_t * |
libnet_t * |
Line 388 libnet_cq_next()
|
Line 390 libnet_cq_next()
|
return (l_cqd.current ? l_cqd.current->context : NULL); |
return (l_cqd.current ? l_cqd.current->context : NULL); |
} |
} |
|
|
u_int32_t | uint32_t |
libnet_cq_size() |
libnet_cq_size() |
{ |
{ |
return (l_cqd.node); |
return (l_cqd.node); |
} |
} |
|
|
|
uint32_t |
|
libnet_cq_end_loop() |
|
{ |
|
if (! clear_cq_lock(CQ_LOCK_WRITE)) |
|
{ |
|
return (0); |
|
} |
|
l_cqd.current = l_cq; |
|
return (1); |
|
} |
|
|