덤프파일 수정좀 질문합니다.
별햇님
질문 제목 : 덤프파일 수정좀 부탁드립니다.질문 내용 : #include stdio.h
#include stdlib.h
#include arpa/inet.h
#include sys/types.h
#include sys/socket.h
#include net/ethernet.h /* ether_header */
#include netinet/ip.h /* iphdr */
#include netinet/tcp.h /* tcphdr */
#include practical.h
int main (int argc, char *argv[])
{
int sock = socket (pf_packet, sock_raw, htons (eth_p_ip));
if (sock == -1)
{
perror (socket() error);
exit (1);
}
while (1)
{
unsigned char buf[eth_frame_len]; /*1512*/
ssize_t nbrcvd = recv (sock, buf, eth_frame_len, 0);
if (nbrcvd == -1)
error_handling (recv() error);
printf (total %d bytes received...\n, nbrcvd);
printf (---------ethernet header----------\n);
struct ether_header *peh = (struct ether_header*)buf;
printf (destmac-%02x:%02x:%02x:%02x:%02x:%02x\n,
peh-ether_dhost[0], peh-ether_dhost[1],
peh-ether_dhost[2], peh-ether_dhost[3],
peh-ether_dhost[4], peh-ether_dhost[5]);
printf (srcmac-%02x:%02x:%02x:%02x:%02x:%02x\n,
peh-ether_shost[0], peh-ether_shost[1],
peh-ether_shost[2], peh-ether_shost[3],
peh-ether_shost[4], peh-ether_shost[5]);
printf (ethertype-0x%04x\n,ntohs(peh-ether_type));
printf (---------ip header----------\n);
struct iphdr *pih = (struct iphdr*)(buf + sizeof (struct ether_header));
printf (ip version-%d\n, pih-version);
printf (ip header length-%d\n, pih-ihl * 4);
printf (ttl -%d\n, pih-ttl);
printf (---------recv data ----------\n);
for (int i=0; inbrcvd; i++)
printf (%02x , buf[i]);
printf (\n\n);
}
return 0;
}
위에잇는 구문을 수정해서 출력결과가 아래처럼 나오게 수정하려합니다... 진짜 멘탈 깨지네요 ㅠㅠ 도와주세요
total 60 bytes received...
----------ethernet header-----------
dest mac - 00:0d:87:89:4e:57, src mac - 00:07:70:ae:64:60, ether type = 0x0800
----------ip header---------- vb
ip version - 4, ip header length - 20 bytes
src ip - 192.168.0.23, dest ip - 192.268.0.98
----------tcp header----------
src port - 9190, dst port - 45789
----------recv data----------
00 0d 87 89 4e 57 00 07 70 … 생략
... (계속 반복 출력)
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2695766 | 달팽이 배열 어디서 틀렸는지 모르겠습니다ㅠㅠ | 연분홍 | 2025-05-23 |
2695738 | fopen과fclose질문~~ (5) | 희선 | 2025-05-23 |
2695707 | 3의 배수 나타내기. (2) | 수리 | 2025-05-23 |
2695626 | 피보나치수열 과제 때문에 질문 드립니다. (6) | 옆집언니 | 2025-05-22 |
2695595 | 포인트공부중입니다 int형에서 4=1 인가요? (3) | 족장 | 2025-05-22 |
2695567 | 드라이브 고유번호를 가져오는 함수 (2) | 초코맛사탕 | 2025-05-21 |
2695533 | 음수의 산술변환! 질문이요 ㅠㅠ... (4) | 꽃여름 | 2025-05-21 |
2695506 | 구조체 배열 이용 도서목록 출력 프로그램 (1) | 가을귀 | 2025-05-21 |
2695450 | c언어 함수 질문이요.... | 이슬비 | 2025-05-20 |
2695403 | VirtualAlloc함수 및 메모리 질문 | 크리에이터 | 2025-05-20 |
2695355 | c언어 for함수 | 미쿡 | 2025-05-19 |
2695327 | 안녕하세요 제가 이번에 좀 큰 프로그램을.. | 악당 | 2025-05-19 |
2695295 | mutex동기화의 thread기반 채팅 서버소스 질문입니다 | 그루터기 | 2025-05-19 |
2695270 | 질문이요..swap 관한겁니다..ㅠㅠ (3) | 콩알녀 | 2025-05-19 |
2695244 | 노땅초보궁금한게 하나 있는데요..반복문(while문)초보자질문 (6) | 큰꽃늘 | 2025-05-18 |
2695166 | do while 문 어떤것이잘못된건지 모르겠어요 (2) | 아이폰 | 2025-05-18 |
2695122 | 구조체에 대해 물어보고 싶은게 있습니다 ^^^.. (7) | 수련 | 2025-05-17 |
2695091 | txt 파일 입출력 후 2차 배열에 저장하기입니다. (3) | 헛장사 | 2025-05-17 |
2695063 | 수도요금 프로그램좀 짜주세요. | 시내 | 2025-05-17 |
2695033 | 답변좀요ㅠㅠ (1) | 비사벌 | 2025-05-16 |