ifpps: Cleanup screen on panic
[netsniff-ng.git] / proto_ip_esp.c
blob51a5689a65fa5d7d37d691989a2a8e77ce5e5620
1 /*
2 * netsniff-ng - the packet sniffing beast
3 * Copyright 2012 Markus Amend <markus@netsniff-ng.org>, Deutsche Flugsicherung GmbH
4 * Subject to the GPL, version 2.
6 * Encapsulating Security Payload described in RFC4303
7 */
9 #include <stdio.h>
10 #include <stdint.h>
11 #include <netinet/in.h> /* for ntohs() */
13 #include "proto.h"
14 #include "protos.h"
15 #include "built_in.h"
16 #include "pkt_buff.h"
18 struct esp_hdr {
19 uint32_t h_spi;
20 uint32_t h_sn;
21 } __packed;
23 static void esp(struct pkt_buff *pkt)
25 struct esp_hdr *esp_ops;
27 esp_ops = (struct esp_hdr *) pkt_pull(pkt, sizeof(*esp_ops));
28 if (esp_ops == NULL)
29 return;
31 tprintf(" [ ESP ");
32 tprintf("SPI (0x%x), ", ntohl(esp_ops->h_spi));
33 tprintf("SN (0x%x)", ntohl(esp_ops->h_sn));
34 tprintf(" ]\n");
37 static void esp_less(struct pkt_buff *pkt)
39 struct esp_hdr *esp_ops;
41 esp_ops = (struct esp_hdr *) pkt_pull(pkt, sizeof(*esp_ops));
42 if (esp_ops == NULL)
43 return;
45 tprintf(" ESP");
48 struct protocol ip_esp_ops = {
49 .key = 0x32,
50 .print_full = esp,
51 .print_less = esp_less,