Example #1
0
/*
 *build next skb from buffer cache
 */
char *prep_next_skb(file_cache_t *fct,u_int32_t *pktlen)
{	
	if (fct == NULL) {
		printf("<1>no file buffer cache \n");return NULL;
	}
	/* if end */
	if (fct->offset == fct->size) 
		fct->offset = sizeof(pf_hdr_t);

	/*set packet data and hdr pointer,? no copy*/
	p_hdr_t *hdr = (p_hdr_t*)(fct->fcache + fct->offset);
	u_int32_t caplen = hdr->ncl_len; 
	FOFFSET(sizeof(p_hdr_t));
	char *pktdata = fct->fcache + fct->offset;
	FOFFSET(hdr->ncl_len);

	if (fct->offset > fct->size) {
		printf("<1>pcap file is not integrated\n");
		return NULL;
	}

	*pktlen = caplen;

	return pktdata;
}
Example #2
0
int check_pcap(file_cache_t *fct)
{
	u_int32_t magic;
	memcpy(&magic, fct->fcache + fct->offset, sizeof(magic));
	FOFFSET(sizeof(magic));
	if (magic != TCPDUMP_MAGIC) {
		printf("<1> not a tcpdump file\n");
		return 0;
	}
	fct->hdr.magic = magic;

	memcpy(&(fct->hdr)+sizeof(magic), fct->fcache+fct->offset, sizeof(fct->hdr)-sizeof(magic));
	FOFFSET(sizeof(fct->hdr) - sizeof(magic));

	if (fct->offset >= fct->size) {
		printf("<1> not a complete pcap file\n");
		return 0;
	}
	return 1;
}
Example #3
0
    dest->subtitle_header_size = 0;
    dest->extradata_size = 0;
    av_opt_free(dest);
    return AVERROR(ENOMEM);
}
#endif

const AVClass *avcodec_get_class(void)
{
    return &av_codec_context_class;
}

#define FOFFSET(x) offsetof(AVFrame,x)

static const AVOption frame_options[]={
{"best_effort_timestamp", "", FOFFSET(best_effort_timestamp), AV_OPT_TYPE_INT64, {.i64 = AV_NOPTS_VALUE }, INT64_MIN, INT64_MAX, 0},
{"pkt_pos", "", FOFFSET(pkt_pos), AV_OPT_TYPE_INT64, {.i64 = -1 }, INT64_MIN, INT64_MAX, 0},
{"pkt_size", "", FOFFSET(pkt_size), AV_OPT_TYPE_INT64, {.i64 = -1 }, INT64_MIN, INT64_MAX, 0},
{"sample_aspect_ratio", "", FOFFSET(sample_aspect_ratio), AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, 0, INT_MAX, 0},
{"width", "", FOFFSET(width), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0},
{"height", "", FOFFSET(height), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0},
{"format", "", FOFFSET(format), AV_OPT_TYPE_INT, {.i64 = -1 }, 0, INT_MAX, 0},
{"channel_layout", "", FOFFSET(channel_layout), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT64_MAX, 0},
{"sample_rate", "", FOFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0},
{NULL},
};

static const AVClass av_frame_class = {
    .class_name              = "AVFrame",
    .item_name               = NULL,
    .option                  = frame_options,