Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  skb_pkt_end.c

  Sprache: C
 

// SPDX-License-Identifier: GPL-2.0
#ifndef BPF_NO_PRESERVE_ACCESS_INDEX
#define BPF_NO_PRESERVE_ACCESS_INDEX
#endif
#include <vmlinux.h>
#include <bpf/bpf_core_read.h>
#include <bpf/bpf_helpers.h>

#define INLINE __always_inline

#define skb_shorter(skb, len) ((void *)(long)(skb)->data + (len) > (void *)(long)skb->data_end)

#define ETH_IPV4_TCP_SIZE (14 + sizeof(struct iphdr) + sizeof(struct tcphdr))

static INLINE struct iphdr *get_iphdr(struct __sk_buff *skb)
{
 struct iphdr *ip = NULL;
 struct ethhdr *eth;

 if (skb_shorter(skb, ETH_IPV4_TCP_SIZE))
  goto out;

 eth = (void *)(long)skb->data;
 ip = (void *)(eth + 1);

out:
 return ip;
}

SEC("tc")
int main_prog(struct __sk_buff *skb)
{
 struct iphdr *ip = NULL;
 struct tcphdr *tcp;
 __u8 proto = 0;
 int urg_ptr;
 u32 offset;

 if (!(ip = get_iphdr(skb)))
  goto out;

 proto = ip->protocol;

 if (proto != IPPROTO_TCP)
  goto out;

 tcp = (void*)(ip + 1);
 if (tcp->dest != 0)
  goto out;
 if (!tcp)
  goto out;

 urg_ptr = tcp->urg_ptr;

 /* Checksum validation part */
 proto++;
 offset = sizeof(struct ethhdr) + offsetof(struct iphdr, protocol);
 bpf_skb_store_bytes(skb, offset, &proto, sizeof(proto), BPF_F_RECOMPUTE_CSUM);

 return urg_ptr;
out:
 return -1;
}
char _license[] SEC("license") = "GPL";

Messung V0.5 in Prozent
C=96 H=90 G=93

¤ Dauer der Verarbeitung: 0.10 Sekunden  (vorverarbeitet am  2026-06-07) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik