]> git.llucax.com Git - z.facultad/75.74/practicos.git/commitdiff
Implementado y probado (tibiamente) el protocolo del resolver.
authorLeandro Lucarella <llucax@gmail.com>
Wed, 21 Jun 2006 16:18:13 +0000 (16:18 +0000)
committerLeandro Lucarella <llucax@gmail.com>
Wed, 21 Jun 2006 16:18:13 +0000 (16:18 +0000)
practicas/pipi/src/Makefile
practicas/pipi/src/resolvproto.cpp [new file with mode: 0644]
practicas/pipi/src/resolvproto.h [new file with mode: 0644]
practicas/pipi/src/test_resolvprotoc.cpp [new file with mode: 0644]
practicas/pipi/src/test_resolvprotos.cpp [new file with mode: 0644]

index 6bb581b158153db5f1f6110d2e79d5e6d303f032..b3e071ce1b493bcb8b1f89bb4844fceb39a7774f 100644 (file)
@@ -31,7 +31,8 @@ CC=g++
 
 # Programas
 targets=ip
-tests=test_send test_recv test_ipaddr test_ipin test_ipout test_devtcp test_poll
+tests=test_send test_recv test_ipaddr test_ipin test_ipout test_devtcp \
+      test_poll test_resolvprotos test_resolvprotoc
 
 # Fuentes
 fuentes ?= $(wildcard *.cpp) $(wildcard *.c)
@@ -60,6 +61,10 @@ test_devtcp: test_devtcp.o devtcp.o libtcp.o ipaddr.o
 
 test_poll: test_poll.o libtcp.o
 
+test_resolvprotos: test_resolvprotos.o libtcp.o ipaddr.o resolvproto.o
+
+test_resolvprotoc: test_resolvprotoc.o libtcp.o ipaddr.o resolvproto.o
+
 ip: ip.o ipout.o ipin.o ipaddr.o ipheader.o devque.o devtcp.o routetable.o libtcp.o
 
 depend:
@@ -122,20 +127,20 @@ devtcp.o: /usr/include/bits/netdb.h /usr/include/fcntl.h
 devtcp.o: /usr/include/bits/fcntl.h /usr/include/sys/ipc.h
 devtcp.o: /usr/include/bits/ipctypes.h /usr/include/bits/ipc.h
 devtcp.o: /usr/include/sys/msg.h /usr/include/bits/msq.h
-ip.o: ipout.h ipaddr.h ipheader.h /usr/include/stdint.h
-ip.o: /usr/include/features.h /usr/include/sys/cdefs.h
-ip.o: /usr/include/gnu/stubs.h /usr/include/bits/wchar.h
-ip.o: /usr/include/bits/wordsize.h routetable.h dev.h ipin.h devtcp.h
-ip.o: /usr/include/sys/poll.h /usr/include/bits/poll.h devque.h
-ip.o: /usr/include/unistd.h /usr/include/bits/posix_opt.h
-ip.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h
-ip.o: /usr/include/bits/confname.h /usr/include/getopt.h /usr/include/fcntl.h
-ip.o: /usr/include/bits/fcntl.h /usr/include/sys/types.h /usr/include/time.h
-ip.o: /usr/include/endian.h /usr/include/bits/endian.h
-ip.o: /usr/include/sys/select.h /usr/include/bits/select.h
-ip.o: /usr/include/bits/sigset.h /usr/include/bits/time.h
-ip.o: /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h
-ip.o: /usr/include/bits/sched.h /usr/include/sys/wait.h /usr/include/signal.h
+ip.o: ipout.h ipaddr.h /usr/include/stdint.h /usr/include/features.h
+ip.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h
+ip.o: /usr/include/bits/wchar.h /usr/include/bits/wordsize.h ipheader.h
+ip.o: routetable.h dev.h ipin.h devtcp.h /usr/include/sys/poll.h
+ip.o: /usr/include/bits/poll.h devque.h /usr/include/unistd.h
+ip.o: /usr/include/bits/posix_opt.h /usr/include/bits/types.h
+ip.o: /usr/include/bits/typesizes.h /usr/include/bits/confname.h
+ip.o: /usr/include/getopt.h /usr/include/fcntl.h /usr/include/bits/fcntl.h
+ip.o: /usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h
+ip.o: /usr/include/bits/endian.h /usr/include/sys/select.h
+ip.o: /usr/include/bits/select.h /usr/include/bits/sigset.h
+ip.o: /usr/include/bits/time.h /usr/include/sys/sysmacros.h
+ip.o: /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h
+ip.o: /usr/include/sys/wait.h /usr/include/signal.h
 ip.o: /usr/include/bits/signum.h /usr/include/bits/siginfo.h
 ip.o: /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h
 ip.o: /usr/include/asm/sigcontext.h /usr/include/asm-i486/sigcontext.h
@@ -145,22 +150,23 @@ ip.o: /usr/include/bits/resource.h /usr/include/bits/waitflags.h
 ip.o: /usr/include/bits/waitstatus.h /usr/include/sys/ipc.h
 ip.o: /usr/include/bits/ipctypes.h /usr/include/bits/ipc.h
 ip.o: /usr/include/sys/msg.h /usr/include/bits/msq.h
-ipaddr.o: ipaddr.h
+ipaddr.o: ipaddr.h /usr/include/stdint.h /usr/include/features.h
+ipaddr.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h
+ipaddr.o: /usr/include/bits/wchar.h /usr/include/bits/wordsize.h
 ipheader.o: ipheader.h ipaddr.h /usr/include/stdint.h /usr/include/features.h
 ipheader.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h
 ipheader.o: /usr/include/bits/wchar.h /usr/include/bits/wordsize.h
-ipin.o: ipin.h ipaddr.h ipheader.h /usr/include/stdint.h
-ipin.o: /usr/include/features.h /usr/include/sys/cdefs.h
-ipin.o: /usr/include/gnu/stubs.h /usr/include/bits/wchar.h
-ipin.o: /usr/include/bits/wordsize.h dev.h
-ipout.o: ipout.h ipaddr.h ipheader.h /usr/include/stdint.h
-ipout.o: /usr/include/features.h /usr/include/sys/cdefs.h
-ipout.o: /usr/include/gnu/stubs.h /usr/include/bits/wchar.h
-ipout.o: /usr/include/bits/wordsize.h routetable.h dev.h
-ipout.o: /usr/include/unistd.h /usr/include/bits/posix_opt.h
-ipout.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h
-ipout.o: /usr/include/bits/confname.h /usr/include/getopt.h
-ipout.o: /usr/include/fcntl.h /usr/include/bits/fcntl.h
+ipin.o: ipin.h ipaddr.h /usr/include/stdint.h /usr/include/features.h
+ipin.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h
+ipin.o: /usr/include/bits/wchar.h /usr/include/bits/wordsize.h ipheader.h
+ipin.o: dev.h
+ipout.o: ipout.h ipaddr.h /usr/include/stdint.h /usr/include/features.h
+ipout.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h
+ipout.o: /usr/include/bits/wchar.h /usr/include/bits/wordsize.h ipheader.h
+ipout.o: routetable.h dev.h /usr/include/unistd.h
+ipout.o: /usr/include/bits/posix_opt.h /usr/include/bits/types.h
+ipout.o: /usr/include/bits/typesizes.h /usr/include/bits/confname.h
+ipout.o: /usr/include/getopt.h /usr/include/fcntl.h /usr/include/bits/fcntl.h
 ipout.o: /usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h
 ipout.o: /usr/include/bits/endian.h /usr/include/sys/select.h
 ipout.o: /usr/include/bits/select.h /usr/include/bits/sigset.h
@@ -169,11 +175,50 @@ ipout.o: /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h
 ipout.o: /usr/include/sys/ipc.h /usr/include/bits/ipctypes.h
 ipout.o: /usr/include/bits/ipc.h /usr/include/sys/msg.h
 ipout.o: /usr/include/bits/msq.h
-routetable.o: routetable.h dev.h ipaddr.h
-test_devtcp.o: ipaddr.h devtcp.h dev.h /usr/include/stdint.h
-test_devtcp.o: /usr/include/features.h /usr/include/sys/cdefs.h
-test_devtcp.o: /usr/include/gnu/stubs.h /usr/include/bits/wchar.h
-test_devtcp.o: /usr/include/bits/wordsize.h /usr/include/sys/poll.h
+resolvproto.o: resolvproto.h ipaddr.h /usr/include/stdint.h
+resolvproto.o: /usr/include/features.h /usr/include/sys/cdefs.h
+resolvproto.o: /usr/include/gnu/stubs.h /usr/include/bits/wchar.h
+resolvproto.o: /usr/include/bits/wordsize.h libtcp.h /usr/include/stdio.h
+resolvproto.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h
+resolvproto.o: /usr/include/libio.h /usr/include/_G_config.h
+resolvproto.o: /usr/include/wchar.h /usr/include/gconv.h
+resolvproto.o: /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h
+resolvproto.o: /usr/include/stdlib.h /usr/include/sys/types.h
+resolvproto.o: /usr/include/time.h /usr/include/endian.h
+resolvproto.o: /usr/include/bits/endian.h /usr/include/sys/select.h
+resolvproto.o: /usr/include/bits/select.h /usr/include/bits/sigset.h
+resolvproto.o: /usr/include/bits/time.h /usr/include/sys/sysmacros.h
+resolvproto.o: /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h
+resolvproto.o: /usr/include/alloca.h /usr/include/unistd.h
+resolvproto.o: /usr/include/bits/posix_opt.h /usr/include/bits/confname.h
+resolvproto.o: /usr/include/getopt.h /usr/include/signal.h
+resolvproto.o: /usr/include/bits/signum.h /usr/include/bits/siginfo.h
+resolvproto.o: /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h
+resolvproto.o: /usr/include/asm/sigcontext.h
+resolvproto.o: /usr/include/asm-i486/sigcontext.h
+resolvproto.o: /usr/include/linux/compiler.h /usr/include/bits/sigstack.h
+resolvproto.o: /usr/include/bits/sigthread.h /usr/include/sys/wait.h
+resolvproto.o: /usr/include/sys/resource.h /usr/include/bits/resource.h
+resolvproto.o: /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h
+resolvproto.o: /usr/include/string.h /usr/include/sys/socket.h
+resolvproto.o: /usr/include/sys/uio.h /usr/include/bits/uio.h
+resolvproto.o: /usr/include/bits/socket.h /usr/include/limits.h
+resolvproto.o: /usr/include/bits/posix1_lim.h /usr/include/bits/local_lim.h
+resolvproto.o: /usr/include/linux/limits.h /usr/include/bits/posix2_lim.h
+resolvproto.o: /usr/include/bits/sockaddr.h /usr/include/asm/socket.h
+resolvproto.o: /usr/include/asm-i486/socket.h /usr/include/asm/sockios.h
+resolvproto.o: /usr/include/asm-i486/sockios.h /usr/include/netinet/in.h
+resolvproto.o: /usr/include/bits/in.h /usr/include/bits/byteswap.h
+resolvproto.o: /usr/include/arpa/inet.h /usr/include/netdb.h
+resolvproto.o: /usr/include/rpc/netdb.h /usr/include/bits/netdb.h
+routetable.o: routetable.h dev.h ipaddr.h /usr/include/stdint.h
+routetable.o: /usr/include/features.h /usr/include/sys/cdefs.h
+routetable.o: /usr/include/gnu/stubs.h /usr/include/bits/wchar.h
+routetable.o: /usr/include/bits/wordsize.h
+test_devtcp.o: ipaddr.h /usr/include/stdint.h /usr/include/features.h
+test_devtcp.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h
+test_devtcp.o: /usr/include/bits/wchar.h /usr/include/bits/wordsize.h
+test_devtcp.o: devtcp.h dev.h /usr/include/sys/poll.h
 test_devtcp.o: /usr/include/bits/poll.h /usr/include/unistd.h
 test_devtcp.o: /usr/include/bits/posix_opt.h /usr/include/bits/types.h
 test_devtcp.o: /usr/include/bits/typesizes.h /usr/include/bits/confname.h
@@ -195,42 +240,42 @@ test_devtcp.o: /usr/include/bits/resource.h /usr/include/bits/waitflags.h
 test_devtcp.o: /usr/include/bits/waitstatus.h /usr/include/sys/ipc.h
 test_devtcp.o: /usr/include/bits/ipctypes.h /usr/include/bits/ipc.h
 test_devtcp.o: /usr/include/sys/msg.h /usr/include/bits/msq.h
-test_ipaddr.o: ipaddr.h ipheader.h /usr/include/stdint.h
-test_ipaddr.o: /usr/include/features.h /usr/include/sys/cdefs.h
-test_ipaddr.o: /usr/include/gnu/stubs.h /usr/include/bits/wchar.h
-test_ipaddr.o: /usr/include/bits/wordsize.h
-test_ipin.o: ipin.h ipaddr.h ipheader.h /usr/include/stdint.h
-test_ipin.o: /usr/include/features.h /usr/include/sys/cdefs.h
-test_ipin.o: /usr/include/gnu/stubs.h /usr/include/bits/wchar.h
-test_ipin.o: /usr/include/bits/wordsize.h dev.h devque.h
-test_ipin.o: /usr/include/unistd.h /usr/include/bits/posix_opt.h
-test_ipin.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h
-test_ipin.o: /usr/include/bits/confname.h /usr/include/getopt.h
-test_ipin.o: /usr/include/fcntl.h /usr/include/bits/fcntl.h
-test_ipin.o: /usr/include/sys/types.h /usr/include/time.h
-test_ipin.o: /usr/include/endian.h /usr/include/bits/endian.h
-test_ipin.o: /usr/include/sys/select.h /usr/include/bits/select.h
-test_ipin.o: /usr/include/bits/sigset.h /usr/include/bits/time.h
-test_ipin.o: /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h
-test_ipin.o: /usr/include/bits/sched.h /usr/include/sys/ipc.h
-test_ipin.o: /usr/include/bits/ipctypes.h /usr/include/bits/ipc.h
-test_ipin.o: /usr/include/sys/msg.h /usr/include/bits/msq.h
-test_ipout.o: ipout.h ipaddr.h ipheader.h /usr/include/stdint.h
-test_ipout.o: /usr/include/features.h /usr/include/sys/cdefs.h
-test_ipout.o: /usr/include/gnu/stubs.h /usr/include/bits/wchar.h
-test_ipout.o: /usr/include/bits/wordsize.h routetable.h dev.h devque.h
-test_ipout.o: /usr/include/unistd.h /usr/include/bits/posix_opt.h
-test_ipout.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h
-test_ipout.o: /usr/include/bits/confname.h /usr/include/getopt.h
-test_ipout.o: /usr/include/fcntl.h /usr/include/bits/fcntl.h
-test_ipout.o: /usr/include/sys/types.h /usr/include/time.h
-test_ipout.o: /usr/include/endian.h /usr/include/bits/endian.h
-test_ipout.o: /usr/include/sys/select.h /usr/include/bits/select.h
-test_ipout.o: /usr/include/bits/sigset.h /usr/include/bits/time.h
-test_ipout.o: /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h
-test_ipout.o: /usr/include/bits/sched.h /usr/include/sys/ipc.h
-test_ipout.o: /usr/include/bits/ipctypes.h /usr/include/bits/ipc.h
-test_ipout.o: /usr/include/sys/msg.h /usr/include/bits/msq.h
+test_ipaddr.o: ipaddr.h /usr/include/stdint.h /usr/include/features.h
+test_ipaddr.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h
+test_ipaddr.o: /usr/include/bits/wchar.h /usr/include/bits/wordsize.h
+test_ipaddr.o: ipheader.h
+test_ipin.o: ipin.h ipaddr.h /usr/include/stdint.h /usr/include/features.h
+test_ipin.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h
+test_ipin.o: /usr/include/bits/wchar.h /usr/include/bits/wordsize.h
+test_ipin.o: ipheader.h dev.h devque.h /usr/include/unistd.h
+test_ipin.o: /usr/include/bits/posix_opt.h /usr/include/bits/types.h
+test_ipin.o: /usr/include/bits/typesizes.h /usr/include/bits/confname.h
+test_ipin.o: /usr/include/getopt.h /usr/include/fcntl.h
+test_ipin.o: /usr/include/bits/fcntl.h /usr/include/sys/types.h
+test_ipin.o: /usr/include/time.h /usr/include/endian.h
+test_ipin.o: /usr/include/bits/endian.h /usr/include/sys/select.h
+test_ipin.o: /usr/include/bits/select.h /usr/include/bits/sigset.h
+test_ipin.o: /usr/include/bits/time.h /usr/include/sys/sysmacros.h
+test_ipin.o: /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h
+test_ipin.o: /usr/include/sys/ipc.h /usr/include/bits/ipctypes.h
+test_ipin.o: /usr/include/bits/ipc.h /usr/include/sys/msg.h
+test_ipin.o: /usr/include/bits/msq.h
+test_ipout.o: ipout.h ipaddr.h /usr/include/stdint.h /usr/include/features.h
+test_ipout.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h
+test_ipout.o: /usr/include/bits/wchar.h /usr/include/bits/wordsize.h
+test_ipout.o: ipheader.h routetable.h dev.h devque.h /usr/include/unistd.h
+test_ipout.o: /usr/include/bits/posix_opt.h /usr/include/bits/types.h
+test_ipout.o: /usr/include/bits/typesizes.h /usr/include/bits/confname.h
+test_ipout.o: /usr/include/getopt.h /usr/include/fcntl.h
+test_ipout.o: /usr/include/bits/fcntl.h /usr/include/sys/types.h
+test_ipout.o: /usr/include/time.h /usr/include/endian.h
+test_ipout.o: /usr/include/bits/endian.h /usr/include/sys/select.h
+test_ipout.o: /usr/include/bits/select.h /usr/include/bits/sigset.h
+test_ipout.o: /usr/include/bits/time.h /usr/include/sys/sysmacros.h
+test_ipout.o: /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h
+test_ipout.o: /usr/include/sys/ipc.h /usr/include/bits/ipctypes.h
+test_ipout.o: /usr/include/bits/ipc.h /usr/include/sys/msg.h
+test_ipout.o: /usr/include/bits/msq.h
 test_recv.o: devque.h dev.h /usr/include/unistd.h /usr/include/features.h
 test_recv.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h
 test_recv.o: /usr/include/bits/posix_opt.h /usr/include/bits/types.h
@@ -245,6 +290,94 @@ test_recv.o: /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h
 test_recv.o: /usr/include/bits/sched.h /usr/include/sys/ipc.h
 test_recv.o: /usr/include/bits/ipctypes.h /usr/include/bits/ipc.h
 test_recv.o: /usr/include/sys/msg.h /usr/include/bits/msq.h
+test_resolvprotoc.o: resolvproto.h ipaddr.h /usr/include/stdint.h
+test_resolvprotoc.o: /usr/include/features.h /usr/include/sys/cdefs.h
+test_resolvprotoc.o: /usr/include/gnu/stubs.h /usr/include/bits/wchar.h
+test_resolvprotoc.o: /usr/include/bits/wordsize.h libtcp.h
+test_resolvprotoc.o: /usr/include/stdio.h /usr/include/bits/types.h
+test_resolvprotoc.o: /usr/include/bits/typesizes.h /usr/include/libio.h
+test_resolvprotoc.o: /usr/include/_G_config.h /usr/include/wchar.h
+test_resolvprotoc.o: /usr/include/gconv.h /usr/include/bits/stdio_lim.h
+test_resolvprotoc.o: /usr/include/bits/sys_errlist.h /usr/include/stdlib.h
+test_resolvprotoc.o: /usr/include/sys/types.h /usr/include/time.h
+test_resolvprotoc.o: /usr/include/endian.h /usr/include/bits/endian.h
+test_resolvprotoc.o: /usr/include/sys/select.h /usr/include/bits/select.h
+test_resolvprotoc.o: /usr/include/bits/sigset.h /usr/include/bits/time.h
+test_resolvprotoc.o: /usr/include/sys/sysmacros.h
+test_resolvprotoc.o: /usr/include/bits/pthreadtypes.h
+test_resolvprotoc.o: /usr/include/bits/sched.h /usr/include/alloca.h
+test_resolvprotoc.o: /usr/include/unistd.h /usr/include/bits/posix_opt.h
+test_resolvprotoc.o: /usr/include/bits/confname.h /usr/include/getopt.h
+test_resolvprotoc.o: /usr/include/signal.h /usr/include/bits/signum.h
+test_resolvprotoc.o: /usr/include/bits/siginfo.h
+test_resolvprotoc.o: /usr/include/bits/sigaction.h
+test_resolvprotoc.o: /usr/include/bits/sigcontext.h
+test_resolvprotoc.o: /usr/include/asm/sigcontext.h
+test_resolvprotoc.o: /usr/include/asm-i486/sigcontext.h
+test_resolvprotoc.o: /usr/include/linux/compiler.h
+test_resolvprotoc.o: /usr/include/bits/sigstack.h
+test_resolvprotoc.o: /usr/include/bits/sigthread.h /usr/include/sys/wait.h
+test_resolvprotoc.o: /usr/include/sys/resource.h /usr/include/bits/resource.h
+test_resolvprotoc.o: /usr/include/bits/waitflags.h
+test_resolvprotoc.o: /usr/include/bits/waitstatus.h /usr/include/string.h
+test_resolvprotoc.o: /usr/include/sys/socket.h /usr/include/sys/uio.h
+test_resolvprotoc.o: /usr/include/bits/uio.h /usr/include/bits/socket.h
+test_resolvprotoc.o: /usr/include/limits.h /usr/include/bits/posix1_lim.h
+test_resolvprotoc.o: /usr/include/bits/local_lim.h
+test_resolvprotoc.o: /usr/include/linux/limits.h
+test_resolvprotoc.o: /usr/include/bits/posix2_lim.h
+test_resolvprotoc.o: /usr/include/bits/sockaddr.h /usr/include/asm/socket.h
+test_resolvprotoc.o: /usr/include/asm-i486/socket.h
+test_resolvprotoc.o: /usr/include/asm/sockios.h
+test_resolvprotoc.o: /usr/include/asm-i486/sockios.h
+test_resolvprotoc.o: /usr/include/netinet/in.h /usr/include/bits/in.h
+test_resolvprotoc.o: /usr/include/bits/byteswap.h /usr/include/arpa/inet.h
+test_resolvprotoc.o: /usr/include/netdb.h /usr/include/rpc/netdb.h
+test_resolvprotoc.o: /usr/include/bits/netdb.h
+test_resolvprotos.o: resolvproto.h ipaddr.h /usr/include/stdint.h
+test_resolvprotos.o: /usr/include/features.h /usr/include/sys/cdefs.h
+test_resolvprotos.o: /usr/include/gnu/stubs.h /usr/include/bits/wchar.h
+test_resolvprotos.o: /usr/include/bits/wordsize.h libtcp.h
+test_resolvprotos.o: /usr/include/stdio.h /usr/include/bits/types.h
+test_resolvprotos.o: /usr/include/bits/typesizes.h /usr/include/libio.h
+test_resolvprotos.o: /usr/include/_G_config.h /usr/include/wchar.h
+test_resolvprotos.o: /usr/include/gconv.h /usr/include/bits/stdio_lim.h
+test_resolvprotos.o: /usr/include/bits/sys_errlist.h /usr/include/stdlib.h
+test_resolvprotos.o: /usr/include/sys/types.h /usr/include/time.h
+test_resolvprotos.o: /usr/include/endian.h /usr/include/bits/endian.h
+test_resolvprotos.o: /usr/include/sys/select.h /usr/include/bits/select.h
+test_resolvprotos.o: /usr/include/bits/sigset.h /usr/include/bits/time.h
+test_resolvprotos.o: /usr/include/sys/sysmacros.h
+test_resolvprotos.o: /usr/include/bits/pthreadtypes.h
+test_resolvprotos.o: /usr/include/bits/sched.h /usr/include/alloca.h
+test_resolvprotos.o: /usr/include/unistd.h /usr/include/bits/posix_opt.h
+test_resolvprotos.o: /usr/include/bits/confname.h /usr/include/getopt.h
+test_resolvprotos.o: /usr/include/signal.h /usr/include/bits/signum.h
+test_resolvprotos.o: /usr/include/bits/siginfo.h
+test_resolvprotos.o: /usr/include/bits/sigaction.h
+test_resolvprotos.o: /usr/include/bits/sigcontext.h
+test_resolvprotos.o: /usr/include/asm/sigcontext.h
+test_resolvprotos.o: /usr/include/asm-i486/sigcontext.h
+test_resolvprotos.o: /usr/include/linux/compiler.h
+test_resolvprotos.o: /usr/include/bits/sigstack.h
+test_resolvprotos.o: /usr/include/bits/sigthread.h /usr/include/sys/wait.h
+test_resolvprotos.o: /usr/include/sys/resource.h /usr/include/bits/resource.h
+test_resolvprotos.o: /usr/include/bits/waitflags.h
+test_resolvprotos.o: /usr/include/bits/waitstatus.h /usr/include/string.h
+test_resolvprotos.o: /usr/include/sys/socket.h /usr/include/sys/uio.h
+test_resolvprotos.o: /usr/include/bits/uio.h /usr/include/bits/socket.h
+test_resolvprotos.o: /usr/include/limits.h /usr/include/bits/posix1_lim.h
+test_resolvprotos.o: /usr/include/bits/local_lim.h
+test_resolvprotos.o: /usr/include/linux/limits.h
+test_resolvprotos.o: /usr/include/bits/posix2_lim.h
+test_resolvprotos.o: /usr/include/bits/sockaddr.h /usr/include/asm/socket.h
+test_resolvprotos.o: /usr/include/asm-i486/socket.h
+test_resolvprotos.o: /usr/include/asm/sockios.h
+test_resolvprotos.o: /usr/include/asm-i486/sockios.h
+test_resolvprotos.o: /usr/include/netinet/in.h /usr/include/bits/in.h
+test_resolvprotos.o: /usr/include/bits/byteswap.h /usr/include/arpa/inet.h
+test_resolvprotos.o: /usr/include/netdb.h /usr/include/rpc/netdb.h
+test_resolvprotos.o: /usr/include/bits/netdb.h
 test_send.o: devque.h dev.h /usr/include/unistd.h /usr/include/features.h
 test_send.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h
 test_send.o: /usr/include/bits/posix_opt.h /usr/include/bits/types.h
diff --git a/practicas/pipi/src/resolvproto.cpp b/practicas/pipi/src/resolvproto.cpp
new file mode 100644 (file)
index 0000000..92a5512
--- /dev/null
@@ -0,0 +1,114 @@
+#include "resolvproto.h"
+#include "libtcp.h"
+#include <cstdlib>
+#include <algorithm>
+#include <iterator>
+
+/// Constructor
+ResolvProtoRequest::ResolvProtoRequest(int fd)
+{
+    recv(fd);
+}
+
+/// Constructor
+ResolvProtoRequest::ResolvProtoRequest(std::string name, uint8_t type):
+    type(type), name(name)
+{}
+
+/// Envía por socket
+void ResolvProtoRequest::send(int sockfd) const
+    throw (std::runtime_error)
+{
+    if (libtcp_send(sockfd, &type, sizeof(uint8_t)) != sizeof(uint8_t))
+        throw std::runtime_error("Error al enviar type por socket");
+    uint16_t size = name.size();
+    if (libtcp_send(sockfd, &size, sizeof(uint16_t)) != sizeof(uint16_t))
+        throw std::runtime_error("Error al enviar size por socket");
+    if (libtcp_send(sockfd, name.c_str(), size) != size)
+        throw std::runtime_error("Error al enviar name por socket");
+}
+
+/// Recibe por socket
+void ResolvProtoRequest::recv(int sockfd)
+    throw (std::runtime_error)
+{
+    if (libtcp_receive_bin(sockfd, &type, sizeof(uint8_t)) != sizeof(uint8_t))
+        throw std::runtime_error("Error al recibir type por socket");
+    uint16_t size;
+    if (libtcp_receive_bin(sockfd, &size, sizeof(uint16_t)) != sizeof(uint16_t))
+        throw std::runtime_error("Error al recibir size por socket");
+    char* buf = (char*) malloc(size);
+    if (libtcp_receive_bin(sockfd, buf, size) != size)
+    {
+        free(buf);
+        throw std::runtime_error("Error al recibir name por socket");
+    }
+    name.assign(buf, size);
+    free(buf);
+}
+
+/// Impresión de request
+std::ostream& operator<< (std::ostream& os, const ResolvProtoRequest& rpr)
+{
+    return os << "ResolvProtoRequest(type=" << unsigned(rpr.type) << ", name="
+        << rpr.name << ")";
+}
+
+/// Constructor
+ResolvProtoResponse::ResolvProtoResponse(int fd)
+{
+    recv(fd);
+}
+
+/// Constructor
+ResolvProtoResponse::ResolvProtoResponse(ret_t ret):
+    ret(ret)
+{}
+
+/// Envía por socket
+void ResolvProtoResponse::send(int sockfd) const
+    throw (std::runtime_error)
+{
+    if (libtcp_send(sockfd, &ret, sizeof(uint8_t)) != sizeof(uint8_t))
+        throw std::runtime_error("Error al enviar ret por socket");
+    uint8_t count = ips.size();
+    if (libtcp_send(sockfd, &count, sizeof(uint8_t)) != sizeof(uint8_t))
+        throw std::runtime_error("Error al enviar count por socket");
+    for (ipvec_t::const_iterator i = ips.begin(); i != ips.end(); ++i)
+    {
+        uint32_t ip = *i;
+        if (libtcp_send(sockfd, &ip, sizeof(uint32_t)) != sizeof(uint32_t))
+            throw std::runtime_error("Error al enviar IPAddr por socket");
+    }
+}
+
+/// Recibe por socket
+void ResolvProtoResponse::recv(int sockfd)
+    throw (std::runtime_error)
+{
+    if (libtcp_receive_bin(sockfd, &ret, sizeof(uint8_t)) != sizeof(uint8_t))
+        throw std::runtime_error("Error al recibir ret por socket");
+    uint8_t count;
+    if (libtcp_send(sockfd, &count, sizeof(uint8_t)) != sizeof(uint8_t))
+        throw std::runtime_error("Error al recibir count por socket");
+    ips.clear();
+    ips.reserve(count);
+    for (uint8_t i = 0; i < count; ++i)
+    {
+        uint32_t ip;
+        if (libtcp_send(sockfd, &ip, sizeof(uint32_t)) != sizeof(uint32_t))
+            throw std::runtime_error("Error al recibir IPAddr por socket");
+        ips.push_back(ip);
+    }
+}
+
+/// Impresión de response
+std::ostream& operator<< (std::ostream& os, const ResolvProtoResponse& rpr)
+{
+    os << "ResolvProtoResponse(ret=" << unsigned(rpr.ret) << ", ";
+    std::copy(rpr.ips.begin(), rpr.ips.end(),
+            std::ostream_iterator< IPAddr >(os, ", "));
+    return os << ")";
+}
+
+// vim: set et sw=4 sts=4 :
diff --git a/practicas/pipi/src/resolvproto.h b/practicas/pipi/src/resolvproto.h
new file mode 100644 (file)
index 0000000..826fa38
--- /dev/null
@@ -0,0 +1,74 @@
+#ifndef _RESOLVPROTO_H_
+#define _RESOLVPROTO_H_
+
+#include "ipaddr.h"
+#include <string>
+#include <vector>
+#include <stdexcept>
+#include <stdint.h>
+
+/// Petición del resolver a un nameserver
+struct ResolvProtoRequest
+{
+
+    /// Tipo de petición, por ahora sólo QUERY
+    enum { TYPE_QUERY };
+
+    /// Tipo de petición, por ahora sólo QUERY
+    uint8_t type;
+
+    /// Nombre a buscar
+    std::string name;
+
+    /// Constructor
+    ResolvProtoRequest(int fd);
+
+    /// Constructor
+    ResolvProtoRequest(std::string name, uint8_t type = TYPE_QUERY);
+
+    /// Envía por socket
+    void send(int sockfd) const throw (std::runtime_error);
+
+    /// Recibe por socket
+    void recv(int sockfd) throw (std::runtime_error);
+
+};
+
+/// Impresión de request
+std::ostream& operator<< (std::ostream& os, const ResolvProtoRequest& rpr);
+
+
+/// Respuesta del resolver a un nameserver
+struct ResolvProtoResponse
+{
+
+    /// Resultado de la respuesta
+    enum ret_t { RET_OK, RET_NOTFOUND, RET_TIMEOUT };
+
+    /// Resultado de la respuesta
+    uint8_t ret;
+
+    /// IPs devueltas
+    typedef std::vector< IPAddr > ipvec_t;
+    ipvec_t ips;
+
+    /// Constructor
+    ResolvProtoResponse(int fd);
+
+    /// Constructor
+    ResolvProtoResponse(ret_t ret);
+
+    /// Envía por socket
+    void send(int sockfd) const throw (std::runtime_error);
+
+    /// Recibe por socket
+    void recv(int sockfd) throw (std::runtime_error);
+
+};
+
+/// Impresión de response
+std::ostream& operator<< (std::ostream& os, const ResolvProtoResponse& rpr);
+
+#endif // _RESOLVPROTO_H_
+
+// vim: set et sw=4 sts=4 :
diff --git a/practicas/pipi/src/test_resolvprotoc.cpp b/practicas/pipi/src/test_resolvprotoc.cpp
new file mode 100644 (file)
index 0000000..4f04686
--- /dev/null
@@ -0,0 +1,19 @@
+
+#include "resolvproto.h"
+#include "libtcp.h"
+#include <iostream>
+#include <cassert>
+
+int main()
+{
+    int fd = libtcp_open_activo("localhost", 5050); assert(fd != -1);
+    ResolvProtoRequest rpr("hola.mundo.cruel");
+    std::cout << "Vamos a enviar: " << rpr << "\n";
+    rpr.send(fd);
+    ResolvProtoResponse rps(fd);
+    std::cout << "Recibimos: " << rps << "\n";
+    close(fd);
+    return 0;
+}
+
+// vim: set et sw=4 sts=4 :
diff --git a/practicas/pipi/src/test_resolvprotos.cpp b/practicas/pipi/src/test_resolvprotos.cpp
new file mode 100644 (file)
index 0000000..7286ab3
--- /dev/null
@@ -0,0 +1,24 @@
+
+#include "resolvproto.h"
+#include "libtcp.h"
+#include <iostream>
+#include <cassert>
+
+int main()
+{
+    int sfd = libtcp_open_pasivo(5050); assert(sfd != -1);
+    int cfd = accept(sfd, NULL, NULL); assert(cfd != -1);
+    close(sfd);
+    ResolvProtoRequest rpr(cfd);
+    std::cout << "Recibimos: " << rpr << "\n";
+    ResolvProtoResponse rps(ResolvProtoResponse::RET_OK);
+    rps.ips.push_back(IPAddr("10.10.10.2"));
+    rps.ips.push_back(IPAddr("100.20.45.21"));
+    rps.ips.push_back(IPAddr("230.23.62.189"));
+    std::cout << "Contestamos: " << rps << "\n";
+    rps.send(cfd);
+    close(cfd);
+    return 0;
+}
+
+// vim: set et sw=4 sts=4 :