Results 1 to 1 of 1
Hi All,
I am learning network programming.Just i am trying for capturing tftp packets.I stopeed tftp server service and i wrote small program using UDP socket.When i started this program, ...
- 11-09-2008 #1Just Joined!
- Join Date
- Nov 2008
- Posts
- 1
tftp packet capturing
Hi All,
I am learning network programming.Just i am trying for capturing tftp packets.I stopeed tftp server service and i wrote small program using UDP socket.When i started this program, tftp packets are not reaching this as it is waiting for port 69 packets.But tftp packets are hitting the NIC (captured packets in wireshark).Are there any hooks to register to get the tftp packets?
It will be a great help if you may clarify this.
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#define SERVER_UDP_PACKET 69
#define MAX_MSG 512
main()
{
int sockFd;
struct sockaddr_in srvAddr,cliAddr;
int cliLen,n;
char mesg[MAX_MSG];
struct tftpControlPacket *packet;
sockFd = socket(AF_INET,SOCK_DGRAM,0);
if(sockFd < 0)
{
printf("Error in creating socket\n");
}
memset(&srvAddr,0,sizeof(srvAddr));
srvAddr.sin_family = AF_INET;
srvAddr.sin_addr.s_addr = htonl(INADDR_ANY);
srvAddr.sin_port = htons(SERVER_UDP_PORT);
if(bind(sockFd,(struct sockaddr *)&srvAddr,sizeof(srvAddr)) < 0 )
printf("Error in binding socket \n");
while(1)
{
cliLen = sizeof(cliAddr);
n = recvfrom(sockFd,mesg,MAX_MSG,0,&cliAddr,&cliLen);
if(n < 0)
printf("Error in receiving the data from client \n");
else
printf("Received tftp packet\n");
}
}


Reply With Quote