Beispiel #1
0
void
dvmrp_print(netdissect_options *ndo,
            const u_char *bp, u_int len)
{
	const u_char *ep;
	u_char type;
	uint8_t major_version, minor_version;

	ndo->ndo_protocol = "dvmrp";
	ep = ndo->ndo_snapend;
	if (bp >= ep)
		return;

	ND_TCHECK_1(bp + 1);
	type = GET_U_1(bp + 1);

	/* Skip IGMP header */
	bp += 8;
	len -= 8;

	switch (type) {

	case DVMRP_PROBE:
		ND_PRINT(" Probe");
		if (ndo->ndo_vflag) {
			if (print_probe(ndo, bp, ep, len) < 0)
				goto trunc;
		}
		break;

	case DVMRP_REPORT:
		ND_PRINT(" Report");
		if (ndo->ndo_vflag > 1) {
			if (print_report(ndo, bp, ep, len) < 0)
				goto trunc;
		}
		break;

	case DVMRP_ASK_NEIGHBORS:
		ND_PRINT(" Ask-neighbors(old)");
		break;

	case DVMRP_NEIGHBORS:
		ND_PRINT(" Neighbors(old)");
		if (print_neighbors(ndo, bp, ep, len) < 0)
			goto trunc;
		break;

	case DVMRP_ASK_NEIGHBORS2:
		ND_PRINT(" Ask-neighbors2");
		break;

	case DVMRP_NEIGHBORS2:
		ND_PRINT(" Neighbors2");
		/*
		 * extract version from IGMP group address field
		 */
		bp -= 4;
		ND_TCHECK_4(bp);
		major_version = GET_U_1(bp + 3);
		minor_version = GET_U_1(bp + 2);
		bp += 4;
		if (print_neighbors2(ndo, bp, ep, len, major_version,
		    minor_version) < 0)
			goto trunc;
		break;

	case DVMRP_PRUNE:
		ND_PRINT(" Prune");
		if (print_prune(ndo, bp) < 0)
			goto trunc;
		break;

	case DVMRP_GRAFT:
		ND_PRINT(" Graft");
		if (print_graft(ndo, bp) < 0)
			goto trunc;
		break;

	case DVMRP_GRAFT_ACK:
		ND_PRINT(" Graft-ACK");
		if (print_graft_ack(ndo, bp) < 0)
			goto trunc;
		break;

	default:
		ND_PRINT(" [type %u]", type);
		break;
	}
	return;

trunc:
	nd_print_trunc(ndo);
	return;
}
Beispiel #2
0
void
dvmrp_print(netdissect_options *ndo,
            register const u_char *bp, register u_int len)
{
	register const u_char *ep;
	register u_char type;

	ep = (const u_char *)ndo->ndo_snapend;
	if (bp >= ep)
		return;

	ND_TCHECK(bp[1]);
	type = bp[1];

	/* Skip IGMP header */
	bp += 8;
	len -= 8;

	switch (type) {

	case DVMRP_PROBE:
		ND_PRINT((ndo, " Probe"));
		if (ndo->ndo_vflag) {
			if (print_probe(ndo, bp, ep, len) < 0)
				goto trunc;
		}
		break;

	case DVMRP_REPORT:
		ND_PRINT((ndo, " Report"));
		if (ndo->ndo_vflag > 1) {
			if (print_report(ndo, bp, ep, len) < 0)
				goto trunc;
		}
		break;

	case DVMRP_ASK_NEIGHBORS:
		ND_PRINT((ndo, " Ask-neighbors(old)"));
		break;

	case DVMRP_NEIGHBORS:
		ND_PRINT((ndo, " Neighbors(old)"));
		if (print_neighbors(ndo, bp, ep, len) < 0)
			goto trunc;
		break;

	case DVMRP_ASK_NEIGHBORS2:
		ND_PRINT((ndo, " Ask-neighbors2"));
		break;

	case DVMRP_NEIGHBORS2:
		ND_PRINT((ndo, " Neighbors2"));
		/*
		 * extract version and capabilities from IGMP group
		 * address field
		 */
		bp -= 4;
		ND_TCHECK2(bp[0], 4);
		target_level = (bp[0] << 24) | (bp[1] << 16) |
		    (bp[2] << 8) | bp[3];
		bp += 4;
		if (print_neighbors2(ndo, bp, ep, len) < 0)
			goto trunc;
		break;

	case DVMRP_PRUNE:
		ND_PRINT((ndo, " Prune"));
		if (print_prune(ndo, bp) < 0)
			goto trunc;
		break;

	case DVMRP_GRAFT:
		ND_PRINT((ndo, " Graft"));
		if (print_graft(ndo, bp) < 0)
			goto trunc;
		break;

	case DVMRP_GRAFT_ACK:
		ND_PRINT((ndo, " Graft-ACK"));
		if (print_graft_ack(ndo, bp) < 0)
			goto trunc;
		break;

	default:
		ND_PRINT((ndo, " [type %d]", type));
		break;
	}
	return;

trunc:
	ND_PRINT((ndo, "[|dvmrp]"));
	return;
}
Beispiel #3
0
int main() {

	int video_file, i;
	tystream_holder_t * tystream = NULL;

	remote_holder_t * remote_holder=NULL;

	vstream_t * vstream = NULL;


	remote_holder = new_remote_holder("tivo");



	logger_init( log_info, stdout, 0, 0 );



	if(!tydemux_init_remote(remote_holder)){
		free_remote_holder(remote_holder);
		printf("Error connecting!!\n");
		return(0);
	}

	if(!remote_holder->fsid_index) {
		tydemux_close_tyserver(remote_holder);
		free_remote_holder(remote_holder);
		printf("No recordings avalible\n");
		return(0);

	} else {
		print_fsid_index_list(remote_holder->fsid_index);
	}

	tystream = tydemux_open_probe_remote(remote_holder, 1186850);

	if(tystream) {
		print_probe(tystream);
	} else {
		tydemux_close_remote_tystream(remote_holder);
		tydemux_close_tyserver(remote_holder);
		free_remote_holder(remote_holder);
		printf("Error Opening remote tystream\n");
		return(0);
	}

	/*
	printf("Indexing\n");

	if(!tydemux_index_remote(remote_holder, NULL)) {
		tydemux_close_remote_tystream(remote_holder);
		tydemux_close_tyserver(remote_holder);
		free_remote_holder(remote_holder);
		printf("Error indexing remote tystream\n");
		return(0);
	}

	printf("Indexing finished\n");
	*/

	video_file = open("test.ty", O_WRONLY|O_CREAT|O_TRUNC|OS_FLAGS, READWRITE_PERMISSIONS);

	/* okay lets test to get one chunk */
	for(i = 5; i < 300; i++) {
		vstream = tydemux_get_remote_chunk(remote_holder, tystream, (int64_t)i);
		if(!vstream) {
			printf("Error fetching remote chunk\n");
			free_vstream(vstream);
			vstream = NULL;
#ifdef WIN32
			assert( tystream->vstream != 0xdddddddd );
#endif
			continue;
		}
		printf("Fetched remote chunk %i \n", i);
		write(video_file, vstream->start_stream, vstream->size);
		free_vstream(vstream);
		vstream = NULL;
#ifdef WIN32
		assert( tystream->vstream != 0xdddddddd );
#endif	
	}
	close(video_file);

	tydemux_close_remote_tystream(remote_holder);
	tydemux_close_tyserver(remote_holder);
	free_remote_holder(remote_holder);
	free_tystream(tystream);
	logger_free();

	exit(0);
}