Open
Conversation
lucaderi
reviewed
Mar 25, 2026
2026/BIANUCCI/pbridge.c
Outdated
| // - packet --> puntatore ai dati del pacchetto da inviare (es: ARP, ICMP, ...) | ||
| // - len --> lunghezza del pacchetto in byte | ||
| fprintf(stderr, "Failed to send packet: %s\n", pcap_geterr(handle)); | ||
| exit(1); |
Owner
There was a problem hiding this comment.
Gli exit in un programma non sono mai belli: andrebbero gestiti diversamente
lucaderi
reviewed
Mar 25, 2026
Owner
lucaderi
left a comment
There was a problem hiding this comment.
Buon lavoro, ci sono piccoli problemi che puoi risolvere
2026/BIANUCCI/pbridge.c
Outdated
|
|
||
| if(stat(device, &s) == 0) { // stat() verifica se device esiste come file nel filesystem --> 0 == esiste; se non esiste lo trattiamo come nome di interfaccia (es: eth0) | ||
| /* Device is a file (probabilmente .pcap) on filesystem */ | ||
| if((pd1 = pcap_open_offline(device, errbuf)) == NULL) { // non stiamo catturando traffico live --> leggiamo pacchetti gia salvati (file .pcap) |
Owner
There was a problem hiding this comment.
Questo lo puoi togliere con il bridge
2026/BIANUCCI/pbridge.c
Outdated
|
|
||
| if(stat(device2, &s) == 0) { // stat() verifica se device esiste come file nel filesystem --> 0 == esiste; se non esiste lo trattiamo come nome di interfaccia (es: eth0) | ||
| /* Device is a file (probabilmente .pcap) on filesystem */ | ||
| if((pd2 = pcap_open_offline(device2, errbuf)) == NULL) { // non stiamo catturando traffico live --> leggiamo pacchetti gia salvati (file .pcap) |
2026/BIANUCCI/pbridge.c
Outdated
| } | ||
|
|
||
| if(fds[0].revents & POLLIN) { | ||
| pcap_dispatch(pd1, 1, dummyProcessPacket, (u_char*)pd2); |
Owner
There was a problem hiding this comment.
Questo va bene ma se vuoi puoi invitare direttamente il pacchetto
- Apportate correzioni evidenziate nella commit precedente - Rimosse funzionalità non necessarie al semplice bridge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Buonasera,
Ho trasformato l'originario pcount.c in pbridge.c, implementando una struttura bidirezionale tra due interfacce di rete. Ho introdotto solo i cambiamenti necessari per garantire il funzionamento del bridge, preparando al contempo il terreno per l'integrazione futura dei filtri di pacchetto.
Ho stravolto l'idea iniziale dei thread con poll() e pcap_dispatch(). Per quanto rigurda l'invio dei pacchetti ho deciso di rimanere aderente a packet_send.c visto a lezione, quindi l'uso di pcap_inject.
Resto a completa disposizione per feedback, suggerimenti o eventuali correzioni sull'architettura,
AB