ref: 1766db24dfb733bd1f574bf0882527356f177397
dir: /tls.c/
#include <stdio.h> #include <stdint.h> #include <pcap.h> #include "common.h" int parseTlsRecord(const u_char *pkt, Tls tls) { int pos = 0; tls.contenttype = pkt[pos]; pos += TLS_RECORD_CONTENTTYPE; tls.rversion = pkt[pos]; pos += TLS_RECORD_VERSION; tls.len = get2(pkt + TLS_RECORD_LEN); pos += TLS_RECORD_LEN; return 1; } int parseTlsHandshake(const u_char *pkt, TlsHandshake hs) { } int parseTls(const u_char *pkt, Tls tls) { int pos = 0; parseTlsRecord(pkt + pos, tls); parseTlsHandshake(pkt + TLS_RECORD, tls.handshake); } void printTls(Tcp tcp) {/* printf("tcp pkt:\n" "\tsrcport: %d\tdstport: %d\n" "\tseqnum: %d\tacknum: %d\n" "\toffset: %d\tflags: %b (%x)\n" "\twinsize: %d (%x)\tsum: %d\n", tcp.srcport, tcp.dstport, tcp.seqnum, tcp.acknum, tcp.offset, tcp.flags, tcp.flags, tcp.winsize, tcp.winsize, tcp.sum); */} Parser tlsParser = { .name = "tls", .parse = parseTls, .print = printTcp, };