root / firmware / zpu / lib / net_common.h @ e4d3f63c
History | View | Annotate | Download (1.91 KB)
| 1 |
/*
|
|---|---|
| 2 |
* Copyright 2009-2012 Ettus Research LLC
|
| 3 |
*
|
| 4 |
* This program is free software: you can redistribute it and/or modify
|
| 5 |
* it under the terms of the GNU General Public License as published by
|
| 6 |
* the Free Software Foundation, either version 3 of the License, or
|
| 7 |
* (at your option) any later version.
|
| 8 |
*
|
| 9 |
* This program is distributed in the hope that it will be useful,
|
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 12 |
* GNU General Public License for more details.
|
| 13 |
*
|
| 14 |
* You should have received a copy of the GNU General Public License
|
| 15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 16 |
*/
|
| 17 |
#ifndef INCLUDED_NET_COMMON_H
|
| 18 |
#define INCLUDED_NET_COMMON_H
|
| 19 |
|
| 20 |
#include <stdint.h> |
| 21 |
#include <stddef.h> |
| 22 |
#include <net/socket_address.h> |
| 23 |
#include <net/eth_mac_addr.h> |
| 24 |
|
| 25 |
/*!
|
| 26 |
* Setup an entry in the protocol framer for a UDP socket.
|
| 27 |
*
|
| 28 |
* \param eth_dst ethernet destination mac addr
|
| 29 |
* \param eth_src ethernet source mac addr
|
| 30 |
* \param sock_dst udp/ip socket destination
|
| 31 |
* \param sock_src udp/ip socket source
|
| 32 |
* \param which the index into the table
|
| 33 |
*/
|
| 34 |
void setup_framer(
|
| 35 |
eth_mac_addr_t eth_dst, |
| 36 |
eth_mac_addr_t eth_src, |
| 37 |
struct socket_address sock_dst,
|
| 38 |
struct socket_address sock_src,
|
| 39 |
size_t which |
| 40 |
); |
| 41 |
|
| 42 |
typedef void (*udp_receiver_t)(struct socket_address src, struct socket_address dst, |
| 43 |
unsigned char *payload, int payload_len); |
| 44 |
|
| 45 |
void init_udp_listeners(void); |
| 46 |
|
| 47 |
void register_addrs(const eth_mac_addr_t *mac_addr, const struct ip_addr *ip_addr); |
| 48 |
|
| 49 |
void register_udp_listener(int port, udp_receiver_t rcvr); |
| 50 |
|
| 51 |
void send_udp_pkt(int src_port, struct socket_address dst, |
| 52 |
const void *buf, size_t len); |
| 53 |
|
| 54 |
void handle_eth_packet(uint32_t *p, size_t nlines);
|
| 55 |
|
| 56 |
void send_gratuitous_arp(void); |
| 57 |
|
| 58 |
//! Send an ARP request for the given IP address
|
| 59 |
void net_common_send_arp_request(const struct ip_addr *addr); |
| 60 |
|
| 61 |
#endif /* INCLUDED_NET_COMMON_H */ |