本文整理汇总了C++中wtap_dump_file_write函数的典型用法代码示例。如果您正苦于以下问题:C++ wtap_dump_file_write函数的具体用法?C++ wtap_dump_file_write怎么用?C++ wtap_dump_file_write使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wtap_dump_file_write函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: k12_dump_record
static gboolean k12_dump_record(wtap_dumper *wdh, guint32 len, guint8* buffer, int *err_p) {
k12_dump_t *k12 = (k12_dump_t *)wdh->priv;
guint32 junky_offset = (0x2000 - ( (k12->file_offset - 0x200) % 0x2000 )) % 0x2000;
if (len > junky_offset) {
if (junky_offset) {
if (! wtap_dump_file_write(wdh, buffer, junky_offset, err_p))
return FALSE;
}
if (! wtap_dump_file_write(wdh, dumpy_junk, 0x10, err_p))
return FALSE;
if (! wtap_dump_file_write(wdh, buffer+junky_offset, len - junky_offset, err_p))
return FALSE;
k12->file_offset += len + 0x10;
} else {
if (! wtap_dump_file_write(wdh, buffer, len, err_p))
return FALSE;
k12->file_offset += len;
}
k12->num_of_records++;
return TRUE;
}
示例2: k12_dump_record
static gboolean k12_dump_record(wtap_dumper *wdh, guint32 len, guint8* buffer, int *err_p) {
k12_dump_t *k12 = (k12_dump_t *)wdh->priv;
guint32 junky_offset = (8192 - ( (k12->file_offset - K12_FILE_HDR_LEN) % 8192 )) % 8192;
if (len > junky_offset) {
if (junky_offset) {
if (! wtap_dump_file_write(wdh, buffer, junky_offset, err_p))
return FALSE;
}
if (! wtap_dump_file_write(wdh, dumpy_junk, K12_FILE_BLOB_LEN, err_p))
return FALSE;
if (! wtap_dump_file_write(wdh, buffer+junky_offset, len - junky_offset, err_p))
return FALSE;
k12->file_offset += len + K12_FILE_BLOB_LEN;
k12->file_len += len + K12_FILE_BLOB_LEN;
} else {
if (! wtap_dump_file_write(wdh, buffer, len, err_p))
return FALSE;
k12->file_offset += len;
k12->file_len += len;
}
k12->num_of_records++;
return TRUE;
}
示例3: k12_dump_close
static gboolean k12_dump_close(wtap_dumper *wdh, int *err) {
k12_dump_t *k12 = (k12_dump_t *)wdh->priv;
union {
guint8 b[sizeof(guint32)];
guint32 u;
} d;
if (! wtap_dump_file_write(wdh, k12_eof, 2, err))
return FALSE;
if (wtap_dump_file_seek(wdh, 8, SEEK_SET, err) == -1)
return FALSE;
d.u = g_htonl(k12->file_len);
if (! wtap_dump_file_write(wdh, d.b, 4, err))
return FALSE;
d.u = g_htonl(k12->num_of_records);
if (! wtap_dump_file_write(wdh, d.b, 4, err))
return FALSE;
return TRUE;
}
示例4: File_write
/* yeah this function is a little weird, but I'm mimicking Lua's actual code for io:write() */
WSLUA_METHOD File_write(lua_State* L) {
/* Writes to the File, similar to Lua's file:write(). See Lua 5.x ref manual for file:write(). */
File f = checkFile(L,1);
int arg = 2; /* beginning index for arguments */
int nargs = lua_gettop(L) - 1;
int status = TRUE;
int err = 0;
if (!f->wdh) {
g_warning("Error in File read: this File object instance is for reading only");
return 0;
}
lua_pushvalue(L, 1); /* push File at the stack top (to be returned) */
for (; nargs--; arg++) {
size_t len;
const char *s = luaL_checklstring(L, arg, &len);
status = wtap_dump_file_write(f->wdh, s, len, &err);
if (!status) break;
f->wdh->bytes_dumped += len;
}
if (!status) {
lua_pop(L,1); /* pop the extraneous File object */
lua_pushnil(L);
lua_pushfstring(L, "File write error: %s", g_strerror(err));
lua_pushinteger(L, err);
return 3;
}
return 1; /* File object already on stack top */
}
示例5: k12_dump_close
static gboolean k12_dump_close(wtap_dumper *wdh, int *err) {
k12_dump_t *k12 = (k12_dump_t *)wdh->priv;
union {
guint8 b[sizeof(guint32)];
guint32 u;
} d;
if (! wtap_dump_file_write(wdh, k12_eof, 2, err))
return FALSE;
k12->file_len += 2;
if (wtap_dump_file_seek(wdh, K12_FILE_HDR_FILE_SIZE, SEEK_SET, err) == -1)
return FALSE;
d.u = g_htonl(k12->file_len);
if (! wtap_dump_file_write(wdh, d.b, 4, err))
return FALSE;
if (wtap_dump_file_seek(wdh, K12_FILE_HDR_PAGE_SIZE, SEEK_SET, err) == -1)
return FALSE;
d.u = g_htonl(8192);
if (! wtap_dump_file_write(wdh, d.b, 4, err))
return FALSE;
if (wtap_dump_file_seek(wdh, K12_FILE_HDR_RECORD_COUNT_1, SEEK_SET, err) == -1)
return FALSE;
d.u = g_htonl(k12->num_of_records);
if (! wtap_dump_file_write(wdh, d.b, 4, err))
return FALSE;
if (wtap_dump_file_seek(wdh, K12_FILE_HDR_RECORD_COUNT_2, SEEK_SET, err) == -1)
return FALSE;
d.u = g_htonl(k12->num_of_records);
if (! wtap_dump_file_write(wdh, d.b, 4, err))
return FALSE;
return TRUE;
}
示例6: snoop_dump_open
/* Returns TRUE on success, FALSE on failure; sets "*err" to an error code on
failure */
gboolean snoop_dump_open(wtap_dumper *wdh, int *err)
{
struct snoop_hdr file_hdr;
/* This is a snoop file */
wdh->subtype_write = snoop_dump;
/* Write the file header. */
if (!wtap_dump_file_write(wdh, &snoop_magic, sizeof snoop_magic, err))
return FALSE;
/* current "snoop" format is 2 */
file_hdr.version = g_htonl(2);
file_hdr.network = g_htonl(wtap_encap[wdh->encap]);
if (!wtap_dump_file_write(wdh, &file_hdr, sizeof file_hdr, err))
return FALSE;
return TRUE;
}
示例7: eyesdn_dump_open
gboolean eyesdn_dump_open(wtap_dumper *wdh, int *err)
{
wdh->subtype_write=eyesdn_dump;
if (!wtap_dump_file_write(wdh, eyesdn_hdr_magic,
EYESDN_HDR_MAGIC_SIZE, err))
return FALSE;
wdh->bytes_dumped += EYESDN_HDR_MAGIC_SIZE;
*err=0;
return TRUE;
}
示例8: s0write
/*---------------------------------------------------
* Returns TRUE on success, FALSE on error
* Write "cnt" bytes of zero with error control
*---------------------------------------------------*/
static gboolean s0write(wtap_dumper *wdh, size_t cnt, int *err)
{
size_t snack;
while (cnt) {
snack = cnt > 64 ? 64 : cnt;
if (!wtap_dump_file_write(wdh, z64, snack, err))
return FALSE;
cnt -= snack;
}
return TRUE; /* ok */
}
示例9: k12_dump_open
gboolean k12_dump_open(wtap_dumper *wdh, int *err) {
k12_dump_t *k12;
if ( ! wtap_dump_file_write(wdh, k12_file_magic, 8, err)) {
return FALSE;
}
if (wtap_dump_file_seek(wdh, 0x200, SEEK_SET, err) == -1)
return FALSE;
wdh->subtype_write = k12_dump;
wdh->subtype_close = k12_dump_close;
k12 = (k12_dump_t *)g_malloc(sizeof(k12_dump_t));
wdh->priv = (void *)k12;
k12->file_len = 0x200;
k12->num_of_records = 0;
k12->file_offset = 0x200;
return TRUE;
}
示例10: nettl_dump_open
/* Returns TRUE on success, FALSE on failure;
sets "*err" to an error code on failure */
gboolean nettl_dump_open(wtap_dumper *wdh, int *err)
{
struct nettl_file_hdr file_hdr;
/* This is a nettl file */
wdh->subtype_write = nettl_dump;
/* Write the file header. */
memset(&file_hdr,0,sizeof(file_hdr));
memcpy(file_hdr.magic,nettl_magic_hpux10,sizeof(file_hdr.magic));
g_strlcpy(file_hdr.file_name,"/tmp/wireshark.TRC000",NETTL_FILENAME_SIZE);
g_strlcpy(file_hdr.tz,"UTC",20);
g_strlcpy(file_hdr.host_name,"",9);
g_strlcpy(file_hdr.os_vers,"B.11.11",9);
file_hdr.os_v=0x55;
g_strlcpy(file_hdr.model,"9000/800",11);
file_hdr.unknown=g_htons(0x406);
if (!wtap_dump_file_write(wdh, &file_hdr, sizeof file_hdr, err))
return FALSE;
wdh->bytes_dumped += sizeof(file_hdr);
return TRUE;
}
示例11: nettl_dump
/* Write a record for a packet to a dump file.
Returns TRUE on success, FALSE on failure. */
static gboolean nettl_dump(wtap_dumper *wdh,
const struct wtap_pkthdr *phdr,
const guint8 *pd, int *err)
{
const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;
struct nettlrec_hdr rec_hdr;
guint8 dummyc[24];
/* We can only write packet records. */
if (phdr->rec_type != REC_TYPE_PACKET) {
*err = WTAP_ERR_REC_TYPE_UNSUPPORTED;
return FALSE;
}
/* Don't write anything we're not willing to read. */
if (phdr->caplen > WTAP_MAX_PACKET_SIZE) {
*err = WTAP_ERR_PACKET_TOO_LARGE;
return FALSE;
}
memset(&rec_hdr,0,sizeof(rec_hdr));
/* HP-UX 11.X header should be 68 bytes */
rec_hdr.hdr_len = g_htons(sizeof(rec_hdr) + 4);
rec_hdr.kind = g_htonl(NETTL_HDR_PDUIN);
rec_hdr.sec = g_htonl(phdr->ts.secs);
rec_hdr.usec = g_htonl(phdr->ts.nsecs/1000);
rec_hdr.caplen = g_htonl(phdr->caplen);
rec_hdr.length = g_htonl(phdr->len);
rec_hdr.devid = -1;
rec_hdr.pid = -1;
rec_hdr.uid = -1;
switch (phdr->pkt_encap) {
case WTAP_ENCAP_NETTL_FDDI:
/* account for pad bytes */
rec_hdr.caplen = g_htonl(phdr->caplen + 3);
rec_hdr.length = g_htonl(phdr->len + 3);
/* fall through and fill the rest of the fields */
case WTAP_ENCAP_NETTL_ETHERNET:
case WTAP_ENCAP_NETTL_TOKEN_RING:
case WTAP_ENCAP_NETTL_RAW_IP:
case WTAP_ENCAP_NETTL_RAW_ICMP:
case WTAP_ENCAP_NETTL_RAW_ICMPV6:
case WTAP_ENCAP_NETTL_RAW_TELNET:
case WTAP_ENCAP_NETTL_UNKNOWN:
rec_hdr.subsys = g_htons(pseudo_header->nettl.subsys);
rec_hdr.devid = g_htonl(pseudo_header->nettl.devid);
rec_hdr.kind = g_htonl(pseudo_header->nettl.kind);
rec_hdr.pid = g_htonl(pseudo_header->nettl.pid);
rec_hdr.uid = g_htons(pseudo_header->nettl.uid);
break;
case WTAP_ENCAP_RAW_IP:
rec_hdr.subsys = g_htons(NETTL_SUBSYS_NS_LS_IP);
break;
case WTAP_ENCAP_ETHERNET:
rec_hdr.subsys = g_htons(NETTL_SUBSYS_BTLAN);
break;
case WTAP_ENCAP_FDDI_BITSWAPPED:
rec_hdr.subsys = g_htons(NETTL_SUBSYS_PCI_FDDI);
/* account for pad bytes */
rec_hdr.caplen = g_htonl(phdr->caplen + 3);
rec_hdr.length = g_htonl(phdr->len + 3);
break;
case WTAP_ENCAP_TOKEN_RING:
rec_hdr.subsys = g_htons(NETTL_SUBSYS_PCI_TR);
break;
#if 0
case WTAP_ENCAP_NETTL_X25:
rec_hdr.caplen = g_htonl(phdr->caplen + 24);
rec_hdr.length = g_htonl(phdr->len + 24);
rec_hdr.subsys = g_htons(pseudo_header->nettl.subsys);
rec_hdr.devid = g_htonl(pseudo_header->nettl.devid);
rec_hdr.kind = g_htonl(pseudo_header->nettl.kind);
rec_hdr.pid = g_htonl(pseudo_header->nettl.pid);
rec_hdr.uid = g_htons(pseudo_header->nettl.uid);
break;
#endif
default:
/* found one we don't support */
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
return FALSE;
}
if (!wtap_dump_file_write(wdh, &rec_hdr, sizeof(rec_hdr), err))
return FALSE;
wdh->bytes_dumped += sizeof(rec_hdr);
/* Write out 4 extra bytes of unknown stuff for HP-UX11
* header format.
*/
memset(dummyc, 0, sizeof dummyc);
if (!wtap_dump_file_write(wdh, dummyc, 4, err))
return FALSE;
//.........这里部分代码省略.........
示例12: s32write
/*---------------------------------------------------
* Returns TRUE on success, FALSE on error
* Write a 32-bit value as little-endian
*---------------------------------------------------*/
static gboolean s32write(wtap_dumper *wdh, const guint32 s32, int *err)
{
guint32 s32_le = GUINT32_TO_LE(s32);
return wtap_dump_file_write(wdh, &s32_le, 4, err);
}
示例13: s16write
/*---------------------------------------------------
* Returns TRUE on success, FALSE on error
* Write a 16-bit value as little-endian
*---------------------------------------------------*/
static gboolean s16write(wtap_dumper *wdh, const guint16 s16, int *err)
{
guint16 s16_le = GUINT16_TO_LE(s16);
return wtap_dump_file_write(wdh, &s16_le, 2, err);
}
示例14: s8write
/*---------------------------------------------------
* Returns TRUE on success, FALSE on error
* Write an 8-bit value
*---------------------------------------------------*/
static gboolean s8write(wtap_dumper *wdh, const guint8 s8, int *err)
{
return wtap_dump_file_write(wdh, &s8, 1, err);
}
示例15: s16write
/*---------------------------------------------------
* Returns TRUE on success, FALSE on error
* Write a 16-bit value with error control
*---------------------------------------------------*/
static gboolean s16write(wtap_dumper *wdh, const guint16 s16, int *err)
{
return wtap_dump_file_write(wdh, &s16, 2, err);
}