* @param qid the id of the hardware queue (used for filters)
* @param prot The protocol that is running on top of IP
* @param dst_ip Destination IP
- * @param dst_mac Destination MAC address
* @param interrupt Interrupt handler
* @param poll If the queue is polled or should use interrupts
*
*/
errval_t ip_create(struct ip_q** q, const char* card_name, uint64_t* qid,
- uint8_t prot, uint32_t dst_ip, struct eth_addr dst_mac,
- void(*interrupt)(void*), bool poll);
+ uint8_t prot, uint32_t dst_ip, void(*interrupt)(void*),
+ bool poll);
#endif /* DEVIF_IP_H_ */
* @param src_port UDP source port
* @param dst_port UPD destination port
* @param dst_ip Destination IP
- * @param dst_mac Destination MAC address
* @param interrupt Interrupt handler
* @param poll If the queue is polled or should use interrupts
*
*/
errval_t udp_create(struct udp_q** q, const char* card_name,
uint16_t src_port, uint16_t dst_port,
- uint32_t dst_ip, struct eth_addr dst_mac,
- void(*interrupt)(void*), bool poll);
+ uint32_t dst_ip, void(*interrupt)(void*),
+ bool poll);
/*
* @brief Writes into a buffer so that we still have space to add the headers
*
#include <net/net_queue.h>
#include <net/net_filter.h>
#include <net/dhcp.h>
+#include <net/arp.h>
#include "../../../queue_interface_internal.h"
#include "../headers.h"
*
*/
errval_t ip_create(struct ip_q** q, const char* card_name, uint64_t* qid,
- uint8_t prot, uint32_t dst_ip,
- struct eth_addr dst_mac, inthandler_t interrupt, bool poll)
+ uint8_t prot, uint32_t dst_ip, inthandler_t interrupt, bool poll)
{
errval_t err;
struct ip_q* que;
return err;
}
+ uint64_t mac;
+ err = arp_service_get_mac(htonl(dst_ip), &mac);
+ if (err_is_fail(err)) {
+ return err;
+ }
+
// fill in header that is reused for each packet
// Ethernet
- memcpy(&(que->header.eth.dest.addr), &dst_mac, ETH_HWADDR_LEN);
+ memcpy(&(que->header.eth.dest.addr), &mac, ETH_HWADDR_LEN);
memcpy(&(que->header.eth.src.addr), &src_mac, ETH_HWADDR_LEN);
que->header.eth.type = htons(ETHTYPE_IP);
*/
errval_t udp_create(struct udp_q** q, const char* card_name,
uint16_t src_port, uint16_t dst_port,
- uint32_t dst_ip, struct eth_addr dst_mac,
- void(*interrupt)(void*), bool poll)
+ uint32_t dst_ip, void(*interrupt)(void*), bool poll)
{
errval_t err;
struct udp_q* que;
// init other queue
uint64_t qid;
err = ip_create((struct ip_q**) &que->q, card_name, &qid, UDP_PROT, dst_ip,
- dst_mac, interrupt, poll);
+ interrupt, poll);
if (err_is_fail(err)) {
return err;
}
return;
}
-static void convert_mac(uint64_t int_mac, struct eth_addr* mac)
-{
- // Also convert to network byte order
- mac->addr[5] = int_mac & 0xFF;
- mac->addr[4] = (int_mac & 0xFF00) >> 8;
- mac->addr[3] = (int_mac & 0xFF0000) >> 16;
- mac->addr[2] = (int_mac & 0xFF000000) >> 24;
- mac->addr[1] = (int_mac & 0xFF00000000) >> 32;
- mac->addr[0] = (int_mac & 0xFF0000000000) >> 40;
-}
-
int main(int argc, char *argv[])
{
if (argc > 6) {
phys_rx = id.base;
- struct eth_addr dst_mac;
-
- convert_mac(mac_dst, &dst_mac);
-
err = udp_create((struct udp_q**) &udp_q, cardname, port_src, port_dst,
- ip_dst, dst_mac, event_cb, true);
+ ip_dst, event_cb, true);
if (err_is_fail(err)) {
USER_PANIC("Queue creation failed \n");
}
static bool use_irq = false;
-static void convert_mac(uint64_t int_mac, struct eth_addr* mac)
-{
- // Also convert to network byte order
- mac->addr[5] = int_mac & 0xFF;
- mac->addr[4] = (int_mac & 0xFF00) >> 8;
- mac->addr[3] = (int_mac & 0xFF0000) >> 16;
- mac->addr[2] = (int_mac & 0xFF000000) >> 24;
- mac->addr[1] = (int_mac & 0xFF00000000) >> 32;
- mac->addr[0] = (int_mac & 0xFF0000000000) >> 40;
-}
-
static void event_cb(void* queue)
{
struct devq* q = (struct devq*) udp_q;
phys_rx = id.base;
- struct eth_addr dst_mac;
-
- convert_mac(mac_dst, &dst_mac);
-
err = udp_create((struct udp_q**) &udp_q, cardname, port_src, port_dst,
- ip_dst, dst_mac, event_cb, true);
+ ip_dst, event_cb, true);
if (err_is_fail(err)) {
USER_PANIC("Queue creation failed \n");
}
static uint64_t mac_dst;
static uint16_t port_src;
static uint16_t port_dst;
-static struct eth_addr dst_mac;
static struct capref memory_rx;
static struct capref memory_tx;
}
}
-static void convert_mac(uint64_t int_mac, struct eth_addr* mac)
-{
- // Also convert to network byte order
- mac->addr[5] = int_mac & 0xFF;
- mac->addr[4] = (int_mac & 0xFF00) >> 8;
- mac->addr[3] = (int_mac & 0xFF0000) >> 16;
- mac->addr[2] = (int_mac & 0xFF000000) >> 24;
- mac->addr[1] = (int_mac & 0xFF00000000) >> 32;
- mac->addr[0] = (int_mac & 0xFF0000000000) >> 40;
-}
-
static void test_udp(void)
{
errval_t err;
struct devq* q;
-
- convert_mac(mac_dst, &dst_mac);
-
// create queue with interrupts
udp_create(&udp_q, cardname, port_src, port_dst,
- ip_dst, dst_mac, event_cb, !use_interrupts);
+ ip_dst, event_cb, !use_interrupts);
q = (struct devq*) udp_q;