version 1.1.1.1, 2012/02/21 22:14:23
|
version 1.1.1.3, 2023/09/27 11:11:38
|
Line 30
|
Line 30
|
* |
* |
*/ |
*/ |
|
|
#if (HAVE_CONFIG_H) | #include "common.h" |
#include "../include/config.h" | |
#endif | |
#if (!(_WIN32) || (__CYGWIN__)) | |
#include "../include/libnet.h" | |
#else | |
#include "../include/win32/libnet.h" | |
#endif | |
|
|
u_int16_t *all_lists; | uint16_t *all_lists; |
|
|
int |
int |
libnet_plist_chain_new(libnet_t *l, libnet_plist_t **plist, char *token_list) |
libnet_plist_chain_new(libnet_t *l, libnet_plist_t **plist, char *token_list) |
{ |
{ |
int8_t libnet_plist_legal_tokens[] = "0123456789,- "; | char libnet_plist_legal_tokens[] = "0123456789,- "; |
libnet_plist_t *tmp; |
libnet_plist_t *tmp; |
int8_t *tok; | char *tok; |
int i, j, valid_token, cur_node; |
int i, j, valid_token, cur_node; |
u_int16_t *all_lists_tmp; | uint16_t *all_lists_tmp; |
static u_int8_t cur_id; | static uint8_t cur_id; |
|
|
if (l == NULL) |
if (l == NULL) |
{ |
{ |
Line 77 libnet_plist_chain_new(libnet_t *l, libnet_plist_t **p
|
Line 70 libnet_plist_chain_new(libnet_t *l, libnet_plist_t **p
|
if (!valid_token) |
if (!valid_token) |
{ |
{ |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, |
"libnet_build_plist_chain: illegal token # %d (%c)\n", | "libnet_build_plist_chain: illegal token # %d (%c)", |
i + 1, |
i + 1, |
token_list[i]); |
token_list[i]); |
*plist = NULL; |
*plist = NULL; |
Line 91 libnet_plist_chain_new(libnet_t *l, libnet_plist_t **p
|
Line 84 libnet_plist_chain_new(libnet_t *l, libnet_plist_t **p
|
if (!(*plist)) |
if (!(*plist)) |
{ |
{ |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, |
"libnet_build_plist_chain: malloc %s\n", strerror(errno)); | "libnet_build_plist_chain: malloc %s", strerror(errno)); |
*plist = NULL; |
*plist = NULL; |
return (-1); |
return (-1); |
} |
} |
Line 101 libnet_plist_chain_new(libnet_t *l, libnet_plist_t **p
|
Line 94 libnet_plist_chain_new(libnet_t *l, libnet_plist_t **p
|
tmp->next = NULL; |
tmp->next = NULL; |
tmp->id = cur_id; |
tmp->id = cur_id; |
all_lists_tmp = all_lists; |
all_lists_tmp = all_lists; |
all_lists = realloc(all_lists_tmp, (sizeof(u_int16_t) * (cur_id + 1))); | all_lists = realloc(all_lists_tmp, (sizeof(uint16_t) * (cur_id + 1))); |
if (!all_lists) |
if (!all_lists) |
{ |
{ |
all_lists = all_lists_tmp; |
all_lists = all_lists_tmp; |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, |
"libnet_build_plist_chain: realloc %s\n", strerror(errno)); | "libnet_build_plist_chain: realloc %s", strerror(errno)); |
*plist = NULL; |
*plist = NULL; |
return(-1); |
return(-1); |
} |
} |
Line 127 libnet_plist_chain_new(libnet_t *l, libnet_plist_t **p
|
Line 120 libnet_plist_chain_new(libnet_t *l, libnet_plist_t **p
|
if (i) |
if (i) |
{ |
{ |
tmp->next = malloc(sizeof (libnet_plist_t)); |
tmp->next = malloc(sizeof (libnet_plist_t)); |
if (!tmp) | if (!tmp->next) |
{ |
{ |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, |
"libnet_build_plist_chain: malloc %s\n", strerror(errno)); | "libnet_build_plist_chain: malloc %s", strerror(errno)); |
/* |
/* |
* XXX - potential memory leak if other nodes are allocated |
* XXX - potential memory leak if other nodes are allocated |
* but not freed. |
* but not freed. |
Line 188 libnet_plist_chain_new(libnet_t *l, libnet_plist_t **p
|
Line 181 libnet_plist_chain_new(libnet_t *l, libnet_plist_t **p
|
} |
} |
|
|
int |
int |
libnet_plist_chain_next_pair(libnet_plist_t *plist, u_int16_t *bport, | libnet_plist_chain_next_pair(libnet_plist_t *plist, uint16_t *bport, |
u_int16_t *eport) | uint16_t *eport) |
{ |
{ |
u_int16_t *node_cnt; | uint16_t *node_cnt; |
u_int16_t tmp_cnt; | uint16_t tmp_cnt; |
|
|
node_cnt = &(all_lists[plist->id]); |
|
if (plist == NULL) |
if (plist == NULL) |
{ |
{ |
return (-1); |
return (-1); |
} |
} |
|
node_cnt = &(all_lists[plist->id]); |
|
|
/* |
/* |
* We are at the end of the list. |
* We are at the end of the list. |
Line 274 libnet_plist_chain_dump_string(libnet_plist_t *plist)
|
Line 267 libnet_plist_chain_dump_string(libnet_plist_t *plist)
|
int |
int |
libnet_plist_chain_free(libnet_plist_t *plist) |
libnet_plist_chain_free(libnet_plist_t *plist) |
{ |
{ |
u_int16_t i; | uint16_t i; |
libnet_plist_t *tmp; |
libnet_plist_t *tmp; |
|
|
if (plist == NULL) |
if (plist == NULL) |
Line 292 libnet_plist_chain_free(libnet_plist_t *plist)
|
Line 285 libnet_plist_chain_free(libnet_plist_t *plist)
|
return (1); |
return (1); |
} |
} |
|
|
/* EOF */ | /** |
| * Local Variables: |
| * indent-tabs-mode: nil |
| * c-file-style: "stroustrup" |
| * End: |
| */ |