62 #define SR_ARPCACHE_SZ 100 63 #define SR_ARPCACHE_TO 15.0 137 unsigned int packet_len,
uint32_t ip
IP addr in network byte order of the MAC/IP mapping.
Definition: sr_arpcache.h:81
pthread_mutexattr_t attr
Attributes for the mutex lock, you shouldn't need to use this, the starter code handles it for you...
Definition: sr_arpcache.h:115
uint32_t ip
The IP trying to be resolved by the request.
Definition: sr_arpcache.h:93
struct sr_packet * packets
List of sr_packet waiting on this request to finish.
Definition: sr_arpcache.h:99
time_t added
Time that the entry was added.
Definition: sr_arpcache.h:82
unsigned int len
Length of the raw ethernet frame.
Definition: sr_arpcache.h:70
void sr_arpreq_destroy(struct sr_arpcache *cache, struct sr_arpreq *entry)
Frees all memory associated with this arp request entry.
Definition: sr_arpcache.c:153
An ARP cache which tracks IP/MAC mappings, as well as outstanding ARP requests.
Definition: sr_arpcache.h:108
struct sr_arpreq * sr_arpcache_insert(struct sr_arpcache *cache, unsigned char *mac, uint32_t ip)
Inserts an ARP cache entry.
Definition: sr_arpcache.c:110
char * iface
The outgoing interface.
Definition: sr_arpcache.h:71
uint8_t * buf
The raw Ethernet frame of the packet, presumably with the dest MAC empty.
Definition: sr_arpcache.h:69
An entry in the ARP cache.
Definition: sr_arpcache.h:79
An outstanding ARP request with queued packets waiting on the response.
Definition: sr_arpcache.h:92
struct sr_arpreq * requests
The linked list of outstanding ARP requests.
Definition: sr_arpcache.h:110
Data structures and methods for handeling interfaces.
int valid
Boolean indicating whether or not the entry is valid.
Definition: sr_arpcache.h:85
struct sr_packet * next
A pointer to the next packet waiting on the same request.
Definition: sr_arpcache.h:72
A packet queued, waiting for the resolution of an sr_arpreq.
Definition: sr_arpcache.h:68
struct sr_arpentry * sr_arpcache_lookup(struct sr_arpcache *cache, uint32_t ip)
Checks if an IP->MAC mapping is in the cache.
Definition: sr_arpcache.c:34
void sr_arpcache_dump(struct sr_arpcache *cache)
Prints out the ARP table.
Definition: sr_arpcache.c:192
int sr_arpcache_destroy(struct sr_arpcache *cache)
sr_arpcache destructor, you shouldn't need to call this, the starter code calls it for you...
Definition: sr_arpcache.c:224
void * sr_arpcache_timeout(void *cache_ptr)
A cleanup command which clears out ARP cache entries every 15 seconds, you shouldn't need to call thi...
Definition: sr_arpcache.c:230
struct sr_arpreq * sr_arpcache_queuereq(struct sr_arpcache *cache, uint32_t ip, uint8_t *packet, unsigned int packet_len, char *iface)
Adds an ARP request to the ARP request queue.
Definition: sr_arpcache.c:65
pthread_mutex_t lock
A lock to ensure that the cache isn't concurrently modified by multiple threads, you shouldn't need t...
Definition: sr_arpcache.h:111
int sr_arpcache_init(struct sr_arpcache *cache)
sr_arpcache constructor, you shouldn't need to call this, the starter code calls it for you...
Definition: sr_arpcache.c:207
time_t sent
Last time this ARP request was sent.
Definition: sr_arpcache.h:94
struct sr_arpreq * next
Pointer to the next outstanding ARP request.
Definition: sr_arpcache.h:101
uint32_t times_sent
Number of times this request was sent.
Definition: sr_arpcache.h:97