예제 #1
0
struct atsc_tvct_section *atsc_tvct_section_codec(struct atsc_section_psip *psip)
{
	uint8_t * buf = (uint8_t *) psip;
	size_t pos = sizeof(struct atsc_section_psip);
	size_t len = section_ext_length(&(psip->ext_head));
	int idx;
	struct atsc_tvct_section *tvct = (struct atsc_tvct_section *) psip;

	if (len < sizeof(struct atsc_tvct_section))
		return NULL;

	pos++;

	for(idx =0; idx < tvct->num_channels_in_section; idx++) {

		if ((pos + sizeof(struct atsc_tvct_channel)) > len)
			return NULL;
		struct atsc_tvct_channel *channel = (struct atsc_tvct_channel *) (buf+pos);

		pos += 7*2;

		bswap32(buf+pos);
		bswap32(buf+pos+4);
		bswap16(buf+pos+8);
		bswap16(buf+pos+10);
		bswap16(buf+pos+12);
		bswap16(buf+pos+14);
		bswap16(buf+pos+16);
		pos+=18;

		if ((pos + channel->descriptors_length) > len)
			return NULL;
		if (verify_descriptors(buf + pos, channel->descriptors_length))
			return NULL;

		pos += channel->descriptors_length;
	}

	if ((pos + sizeof(struct atsc_tvct_section_part2)) > len)
		return NULL;
	struct atsc_tvct_section_part2 *part2 = (struct atsc_tvct_section_part2 *) (buf+pos);

	bswap16(buf+pos);
	pos+=2;

	if ((pos + part2->descriptors_length) > len)
		return NULL;

	if (verify_descriptors(buf + pos, part2->descriptors_length))
		return NULL;

	pos += part2->descriptors_length;

	if (pos != len)
		return NULL;

	return (struct atsc_tvct_section *) psip;
}
예제 #2
0
struct mpeg_odsmt_section *mpeg_odsmt_section_codec(struct section_ext * ext)
{
	struct mpeg_odsmt_section * odsmt = (struct mpeg_odsmt_section *)ext;
	uint8_t * buf = (uint8_t *)ext;
	size_t pos = sizeof(struct section_ext);
	size_t len = section_ext_length(ext);
	int i;

	if (len < sizeof(struct mpeg_odsmt_section))
		return NULL;

	pos++;

	if (odsmt->stream_count == 0) {
		struct mpeg_odsmt_stream * stream =
			(struct mpeg_odsmt_stream *) (buf + pos);

		if ((pos + sizeof(struct mpeg_odsmt_stream_single)) > len)
			return NULL;

		bswap16(buf+pos);
		pos+=3;

		if ((pos + stream->u.single.es_info_length) >= len)
			return NULL;

		if (verify_descriptors(buf + pos, stream->u.single.es_info_length))
			return NULL;

		pos += stream->u.single.es_info_length;
	} else {
		for (i=0; i< odsmt->stream_count; i++) {
			struct mpeg_odsmt_stream * stream =
				(struct mpeg_odsmt_stream *)(buf + pos);

			if ((pos + sizeof(struct mpeg_odsmt_stream_multi)) > len)
				return NULL;

			bswap16(buf+pos);
			pos += sizeof(struct mpeg_odsmt_stream_multi);

			if ((pos + stream->u.multi.es_info_length) > len)
				return NULL;

			if (verify_descriptors(buf + pos,
			    stream->u.multi.es_info_length))
				return NULL;

			pos += stream->u.multi.es_info_length;
		}
	}

	if (pos != len)
		return NULL;

	return (struct mpeg_odsmt_section *) ext;
}
예제 #3
0
struct atsc_ett_section *atsc_ett_section_codec(struct atsc_section_psip *psip)
{
	uint8_t * buf = (uint8_t *) psip;
	size_t pos = sizeof(struct atsc_section_psip);
	size_t len = section_ext_length(&(psip->ext_head));

	if (len < sizeof(struct atsc_ett_section))
		return NULL;

	bswap32(buf + pos);
	pos += 4;

	if (atsc_text_validate(buf + pos,
	    		       section_ext_length(&psip->ext_head) - sizeof(struct atsc_ett_section)))
		return NULL;

	return (struct atsc_ett_section *) psip;
}
struct dvb_tva_container_section *dvb_tva_container_section_codec(struct section_ext *ext)
{
	size_t len = section_ext_length(ext);
	struct dvb_tva_container_section* ret = (struct dvb_tva_container_section*) ext;

	if (len < sizeof(struct dvb_tva_container_section))
		return NULL;

	return ret;
}
예제 #5
0
struct dvb_int_section * dvb_int_section_codec(struct section_ext *ext)
{
	uint8_t *buf = (uint8_t *) ext;
	struct dvb_int_section *in = (struct dvb_int_section *) ext;
	size_t pos = sizeof(struct section_ext);
	size_t len = section_ext_length(ext);

	if (len < sizeof(struct dvb_int_section))
		return NULL;

	bswap32(buf+8);
	bswap16(buf+12);
	pos += 6;

	if (len - pos < in->platform_descriptors_length)
		return NULL;

	if (verify_descriptors(buf + pos, in->platform_descriptors_length))
		return NULL;

	pos += in->platform_descriptors_length;

	while (pos < len) {
		struct dvb_int_target *s2 = (struct dvb_int_target *) (buf + pos);
		struct dvb_int_operational_loop *s3;

		bswap16(buf + pos); /* target_descriptor_loop_length swap */

		if (len - pos < s2->target_descriptors_length)
			return NULL;

		pos += sizeof(struct dvb_int_target);

		if (verify_descriptors(buf + pos, s2->target_descriptors_length))
			return NULL;

		pos += s2->target_descriptors_length;

		s3 = (struct dvb_int_operational_loop *) (buf + pos);

		bswap16(buf + pos); /* operational_descriptor_loop_length swap */

		if (len - pos < s3->operational_descriptors_length)
			return NULL;

		pos += sizeof(struct dvb_int_operational_loop);

		if (verify_descriptors(buf + pos, s3->operational_descriptors_length))
			return NULL;

		pos += s3->operational_descriptors_length;
	}

	return (struct dvb_int_section *) ext;
}
예제 #6
0
struct dvb_nit_section *dvb_nit_section_codec(struct section_ext * ext)
{
	uint8_t * buf = (uint8_t *) ext;
	struct dvb_nit_section * ret = (struct dvb_nit_section *) ext;
	size_t pos = sizeof(struct section_ext);
	size_t len = section_ext_length(ext);

	if (len < sizeof(struct dvb_nit_section))
		return NULL;

	bswap16(buf + pos);
	pos += 2;

	if ((pos + ret->network_descriptors_length) > len)
		return NULL;

	if (verify_descriptors(buf + pos, ret->network_descriptors_length))
		return NULL;

	pos += ret->network_descriptors_length;

	if ((pos + sizeof(struct dvb_nit_section_part2)) > len)
		return NULL;

	bswap16(buf + pos);
	pos += 2;

	while (pos < len) {
		struct dvb_nit_transport *transport =
			(struct dvb_nit_transport *)(buf + pos);

		if ((pos + sizeof(struct dvb_nit_transport)) > len)
			return NULL;

		bswap16(buf + pos);
		bswap16(buf + pos + 2);
		bswap16(buf + pos + 4);

		pos += sizeof(struct dvb_nit_transport);

		if ((pos + transport->transport_descriptors_length) > len)
			return NULL;

		if (verify_descriptors(buf + pos,
					transport->transport_descriptors_length))
			return NULL;

		pos += transport->transport_descriptors_length;
	}

	if (pos != len)
		return NULL;

	return ret;
}
예제 #7
0
struct mpeg_tsdt_section * mpeg_tsdt_section_codec(struct section_ext * ext)
{
	uint8_t * buf = (uint8_t *)ext;
	size_t pos = sizeof(struct section_ext);

	if (verify_descriptors(buf + pos,
	    section_ext_length(ext) - sizeof(struct mpeg_tsdt_section)))
		return NULL;

	return (struct mpeg_tsdt_section *)ext;
}
예제 #8
0
struct atsc_eit_section *atsc_eit_section_codec(struct atsc_section_psip *psip)
{
	uint8_t * buf = (uint8_t *) psip;
	size_t pos = 0;
	size_t len = section_ext_length(&(psip->ext_head));
	int idx;

	if (len < sizeof(struct atsc_eit_section))
		return NULL;
	struct atsc_eit_section *eit = (struct atsc_eit_section *) psip;

	pos += sizeof(struct atsc_eit_section);
	for(idx =0; idx < eit->num_events_in_section; idx++) {
		if (len < (pos + sizeof(struct atsc_eit_event)))
			return NULL;
		struct atsc_eit_event *event = (struct atsc_eit_event *) (buf+pos);

		bswap16(buf+pos);
		bswap32(buf+pos+2);
		bswap32(buf+pos+6);

		pos += sizeof(struct atsc_eit_event);
		if (len < (pos + event->title_length))
			return NULL;
		if (atsc_text_validate(buf+pos, event->title_length))
			return NULL;

		pos += event->title_length;
		if (len < (pos + sizeof(struct atsc_eit_event_part2)))
			return NULL;
		struct atsc_eit_event_part2 *part2 = (struct atsc_eit_event_part2 *) (buf+pos);

		bswap16(buf+pos);

		pos += sizeof(struct atsc_eit_event_part2);
		if (len < (pos + part2->descriptors_length))
			return NULL;

		if (verify_descriptors(buf + pos, part2->descriptors_length))
			return NULL;
		pos += part2->descriptors_length;
	}

	if (pos != len)
		return NULL;

	return (struct atsc_eit_section *) psip;
}
예제 #9
0
struct atsc_stt_section *atsc_stt_section_codec(struct atsc_section_psip *psip)
{
	uint8_t *buf = (uint8_t *) psip;
	size_t pos = sizeof(struct atsc_section_psip);
	size_t len = section_ext_length(&(psip->ext_head));

	if (len < sizeof(struct atsc_stt_section))
		return NULL;

	bswap32(buf + pos);
	pos += 5;
	bswap16(buf + pos);
	pos += 2;

	if (verify_descriptors(buf + pos, len - sizeof(struct atsc_stt_section)))
		return NULL;

	return (struct atsc_stt_section *) psip;
}
예제 #10
0
struct dvb_sdt_section * dvb_sdt_section_codec(struct section_ext * ext)
{
	uint8_t * buf = (uint8_t *) ext;
	size_t pos = sizeof(struct section_ext);
	size_t len = section_ext_length(ext);

	if (len < sizeof(struct dvb_sdt_section))
		return NULL;

	bswap16(buf + pos);
	pos += 3;

	while (pos < len) {
		struct dvb_sdt_service * service =
			(struct dvb_sdt_service *)(buf + pos);

		if ((pos + sizeof(struct dvb_sdt_service)) > len)
			return NULL;

		bswap16(buf + pos);
		bswap16(buf + pos + 3);
		pos += sizeof(struct dvb_sdt_service);

		if ((pos + service->descriptors_loop_length) > len)
			return NULL;

		if (verify_descriptors(buf + pos, service->descriptors_loop_length))
			return NULL;

		pos += service->descriptors_loop_length;
	}

	if (pos != len)
		return NULL;

	return (struct dvb_sdt_section *) ext;
}
예제 #11
0
struct atsc_dccsct_section *atsc_dccsct_section_codec(struct atsc_section_psip *psip)
{
	uint8_t * buf = (uint8_t *) psip;
	size_t pos = 0;
	size_t len = section_ext_length(&(psip->ext_head));
	int idx;

	if (len < sizeof(struct atsc_dccsct_section))
		return NULL;
	struct atsc_dccsct_section *dccsct = (struct atsc_dccsct_section *) psip;

	pos += sizeof(struct atsc_dccsct_section);
	for(idx =0; idx < dccsct->updates_defined; idx++) {
		if (len < (pos + sizeof(struct atsc_dccsct_update)))
			return NULL;
		struct atsc_dccsct_update *update = (struct atsc_dccsct_update *) (buf+pos);

		pos += sizeof(struct atsc_dccsct_update);
		if (len < (pos + update->update_data_length))
			return NULL;

		switch(update->update_type) {
		case ATSC_DCCST_UPDATE_NEW_GENRE: {
			int sublen = sizeof(struct atsc_dccsct_update_new_genre);
			if (update->update_data_length < sublen)
				return NULL;

			if (atsc_text_validate(buf+pos+sublen, update->update_data_length - sublen))
				return NULL;
			break;
		}
		case ATSC_DCCST_UPDATE_NEW_STATE: {
			int sublen = sizeof(struct atsc_dccsct_update_new_state);
			if (update->update_data_length < sublen)
				return NULL;

			if (atsc_text_validate(buf+pos+sublen, update->update_data_length - sublen))
				return NULL;
			break;
		}
		case ATSC_DCCST_UPDATE_NEW_COUNTY: {
			int sublen = sizeof(struct atsc_dccsct_update_new_county);
			if (update->update_data_length < sublen)
				return NULL;
			bswap16(buf+pos+1);

			if (atsc_text_validate(buf+pos+sublen, update->update_data_length - sublen))
				return NULL;
			break;
		}
		}

		pos += update->update_data_length;
		if (len < (pos + sizeof(struct atsc_dccsct_update_part2)))
			return NULL;
		struct atsc_dccsct_update_part2 *part2 = (struct atsc_dccsct_update_part2 *) buf + pos;

		bswap16(buf+pos);

		pos += sizeof(struct atsc_dccsct_update_part2);
		if (len < (pos + part2->descriptors_length))
			return NULL;
		if (verify_descriptors(buf + pos, part2->descriptors_length))
			return NULL;

		pos += part2->descriptors_length;
	}

	if (len < (pos + sizeof(struct atsc_dccsct_section_part2)))
		return NULL;
	struct atsc_dccsct_section_part2 *part2 = (struct atsc_dccsct_section_part2 *) (buf+pos);

	bswap16(buf+pos);

	pos += sizeof(struct atsc_dccsct_section_part2);
	if (len < (pos + part2->descriptors_length))
		return NULL;
	if (verify_descriptors(buf + pos, part2->descriptors_length))
		return NULL;

	pos += part2->descriptors_length;
	if (pos != len)
		return NULL;

	return (struct atsc_dccsct_section *) psip;
}