eth.c File Reference

#include "inet.h"
#include "buf.h"
#include "clock.h"
#include "event.h"
#include "osdep_eth.h"
#include "type.h"
#include "assert.h"
#include "eth.h"
#include "eth_int.h"
#include "io.h"
#include "sr.h"

Include dependency graph for eth.c:

Go to the source code of this file.

Data Structures

struct  eth_fd
struct  vlan_hdr_t

Defines

#define ETH_FD_NR   (4*IP_PORT_MAX)
#define EXPIRE_TIME   60*HZ
#define EFF_FLAGS   0xf
#define EFF_EMPTY   0x0
#define EFF_INUSE   0x1
#define EFF_BUSY   0xE
#define EFF_READ_IP   0x2
#define EFF_WRITE_IP   0x4
#define EFF_IOCTL_IP   0x8
#define EFF_OPTSET   0x10

Typedefs

typedef eth_fd eth_fd_t

Functions

FORWARD int eth_checkopt ARGS ((eth_fd_t *eth_fd))
FORWARD void eth_buffree ARGS ((int priority))
FORWARD void packet2user ARGS ((eth_fd_t *fd, acc_t *pack, time_t exp_time))
FORWARD void reply_thr_get ARGS ((eth_fd_t *eth_fd, size_t result, int for_ioctl))
FORWARD void do_rec_conf ARGS ((eth_port_t *eth_port))
FORWARD acc_t *insert_vlan_hdr ARGS ((eth_port_t *eth_port, acc_t *pack))
PUBLIC void eth_prep ()
PUBLIC void eth_init ()
PUBLIC int eth_open (int port, int srfd, get_userdata_t get_userdata, put_userdata_t put_userdata, put_pkt_t put_pkt, select_res_t select_res)
PUBLIC int eth_ioctl (int fd, ioreq_t req)
PUBLIC int eth_write (int fd, size_t count)
PUBLIC int eth_send (int fd, acc_t *data, size_t data_len)
PUBLIC int eth_read (int fd, size_t count)
PUBLIC int eth_cancel (int fd, int which_operation)
PUBLIC int eth_select (int fd, unsigned operations)
PUBLIC void eth_close (int fd)
PUBLIC void eth_loop_ev (event_t *ev, ev_arg_t ev_arg)
PRIVATE int eth_checkopt (eth_fd_t *eth_fd)
PRIVATE void hash_fd (eth_fd_t *eth_fd)
PRIVATE void unhash_fd (eth_fd_t *eth_fd)
PUBLIC void eth_restart_write (eth_port_t *eth_port)
PUBLIC void eth_arrive (eth_port_t *eth_port, acc_t *pack, size_t pack_size)
PUBLIC void eth_reg_vlan (eth_port_t *eth_port, eth_port_t *vlan_port)
PUBLIC void eth_restart_ioctl (eth_port_t *eth_port)
PRIVATE void packet2user (eth_fd_t *eth_fd, acc_t *pack, time_t exp_time)
PRIVATE void eth_buffree (int priority)
PRIVATE void do_rec_conf (eth_port_t *eth_port)
PRIVATE u32_t compute_rec_conf (eth_port_t *eth_port)
PRIVATE void reply_thr_get (eth_fd_t *eth_fd, size_t result, int for_ioctl)
PRIVATE void reply_thr_put (eth_fd_t *eth_fd, size_t result, int for_ioctl)
PRIVATE acc_tinsert_vlan_hdr (eth_port_t *eth_port, acc_t *pack)

Variables

PUBLIC eth_port_teth_port_table
PUBLIC int no_ethWritePort = 0
PRIVATE eth_fd_t eth_fd_table [ETH_FD_NR]
PRIVATE ether_addr_t broadcast = { { 255, 255, 255, 255, 255, 255 } }


Define Documentation

#define EFF_BUSY   0xE
 

Definition at line 47 of file eth.c.

Referenced by eth_close().

#define EFF_EMPTY   0x0
 

Definition at line 45 of file eth.c.

Referenced by eth_close(), and eth_init().

#define EFF_FLAGS   0xf
 

Definition at line 44 of file eth.c.

#define EFF_INUSE   0x1
 

Definition at line 46 of file eth.c.

Referenced by compute_rec_conf(), eth_close(), eth_ioctl(), eth_open(), eth_restart_ioctl(), and packet2user().

#define EFF_IOCTL_IP   0x8
 

Definition at line 50 of file eth.c.

Referenced by eth_cancel(), eth_ioctl(), and eth_restart_ioctl().

#define EFF_OPTSET   0x10
 

Definition at line 51 of file eth.c.

Referenced by compute_rec_conf(), eth_checkopt(), eth_close(), eth_ioctl(), eth_read(), eth_send(), and eth_write().

#define EFF_READ_IP   0x2
 

Definition at line 48 of file eth.c.

Referenced by eth_cancel(), eth_read(), and packet2user().

#define EFF_WRITE_IP   0x4
 

Definition at line 49 of file eth.c.

Referenced by eth_cancel(), eth_restart_write(), and eth_write().

#define ETH_FD_NR   (4*IP_PORT_MAX)
 

Definition at line 23 of file eth.c.

Referenced by compute_rec_conf(), eth_buffree(), eth_init(), eth_open(), and eth_restart_ioctl().

#define EXPIRE_TIME   60*HZ
 

Definition at line 24 of file eth.c.

Referenced by eth_arrive().


Typedef Documentation

typedef struct eth_fd eth_fd_t
 


Function Documentation

FORWARD acc_t* insert_vlan_hdr ARGS (eth_port_t *eth_port, acc_t *pack)   ) 
 

FORWARD void do_rec_conf ARGS (eth_port_t *eth_port  ) 
 

FORWARD void reply_thr_get ARGS (eth_fd_t *eth_fd, size_t result, int for_ioctl)   ) 
 

FORWARD void packet2user ARGS (eth_fd_t *fd, acc_t *pack, time_t exp_time)   ) 
 

FORWARD void eth_buffree ARGS (int priority)   ) 
 

FORWARD int eth_checkopt ARGS (eth_fd_t *eth_fd  ) 
 

PRIVATE u32_t compute_rec_conf eth_port_t eth_port  ) 
 

Definition at line 1144 of file eth.c.

References eth_fd::ef_flags, EFF_INUSE, EFF_OPTSET, ETH_FD_NR, eth_fd_table, flags, and NWEO_NOFLAGS.

Referenced by do_rec_conf().

PRIVATE void do_rec_conf eth_port_t eth_port  ) 
 

Definition at line 1123 of file eth.c.

References compute_rec_conf(), ETH_VLAN_HASH_NR, eth_port::etp_vlan_next, eth_port::etp_vlan_tab, and flags.

Referenced by eth_close(), and eth_ioctl().

PUBLIC void eth_arrive eth_port_t eth_port,
acc_t pack,
size_t  pack_size
 

Definition at line 794 of file eth.c.

References acc::acc_linkC, assert, bf_afree(), bf_append(), bf_bufsize(), bf_cut(), bf_delhead(), bf_memreq(), bf_packIffLess(), broadcast, DIFBLOCK, ether_addr::ea_addr, eth_fd::ef_ethopt, eth_fd::ef_type_next, eth_hdr::eh_dst, eth_hdr::eh_proto, eth_hdr::eh_src, EPF_GOT_ADDR, eth_addrcmp, ETH_HDR_SIZE, ETH_MIN_PACK_SIZE, ETH_TCI_CFI, ETH_TCI_VLAN_MASK, ETH_TYPE_HASH_NR, ETH_VLAN_PROTO, EXPIRE_TIME, get_time(), hash(), HTONS, i, if(), ntohs, NULL, NWEO_EN_BROAD, NWEO_EN_LOC, NWEO_EN_MULTI, NWEO_EN_PROMISC, nwio_ethopt::nweo_flags, nwio_ethopt::nweo_rem, NWEO_REMSPEC, nwio_ethopt::nweo_type, p, printf, ptr2acc_data, time_t, and type.

Referenced by eth_loop_ev(), read_int(), and write_int().

PRIVATE void eth_buffree int  priority  ) 
 

Definition at line 1066 of file eth.c.

References acc::acc_ext_link, bf_afree(), eth_fd::ef_rdbuf_head, ETH_FD_NR, eth_fd_table, ETH_PRI_FDBUFS_EXTRA, and i.

PUBLIC int eth_cancel int  fd,
int  which_operation
 

Definition at line 572 of file eth.c.

References assert, DBLOCK, eth_fd::ef_flags, eth_fd::ef_port, eth_fd::ef_send_next, EFF_IOCTL_IP, EFF_READ_IP, EFF_WRITE_IP, EINTR, eth_fd_table, eth_port::etp_sendq_head, eth_port::etp_sendq_tail, eth_port::etp_vlan_port, FALSE, ip_panic, NULL, NW_OK, printf, reply_thr_get(), reply_thr_put(), SR_CANCEL_IOCTL, SR_CANCEL_READ, SR_CANCEL_WRITE, and TRUE.

Referenced by osdep_eth_init().

PRIVATE int eth_checkopt eth_fd_t eth_fd  ) 
 

Definition at line 680 of file eth.c.

References acc::acc_ext_link, bf_afree(), EFF_OPTSET, flags, NULL, NW_OK, NWEO_ACC_MASK, NWEO_BROAD_MASK, NWEO_LOC_MASK, NWEO_MULTI_MASK, NWEO_PROMISC_MASK, NWEO_REM_MASK, NWEO_RW_MASK, and NWEO_TYPE_MASK.

Referenced by eth_ioctl().

PUBLIC void eth_close int  fd  ) 
 

Definition at line 632 of file eth.c.

References acc::acc_ext_link, assert, bf_afree(), do_rec_conf(), eth_fd::ef_flags, EFF_BUSY, EFF_EMPTY, EFF_INUSE, EFF_OPTSET, eth_fd_table, NULL, and unhash_fd().

Referenced by osdep_eth_init().

PUBLIC void eth_init  ) 
 

Definition at line 89 of file eth.c.

References assert, BUF_S, EFF_EMPTY, eth_conf_nr, ETH_FD_NR, ETH_HDR_SIZE, ETH_TYPE_HASH_NR, ETH_VLAN_HASH_NR, ev_init(), i, j, and NULL.

Referenced by nw_init().

PUBLIC int eth_ioctl int  fd,
ioreq_t  req
 

Definition at line 164 of file eth.c.

References assert, bf_afree(), bf_bufsize(), bf_memreq(), BUF_S, changes, compare, data, DBLOCK, do_rec_conf(), EBADMODE, eth_fd::ef_ethopt, eth_fd::ef_flags, eth_fd::ef_get_userdata, eth_fd::ef_ioctl_req, eth_fd::ef_port, eth_fd::ef_put_userdata, EFF_INUSE, EFF_IOCTL_IP, EFF_OPTSET, EGENERIC, EPF_ENABLED, EPF_GOT_ADDR, eth_checkopt(), eth_fd_table, eth_get_stat(), eth_port::etp_ethaddr, eth_port::etp_flags, eth_port::etp_vlan, hash_fd(), memset(), NW_OK, NW_SUSPEND, NWEO_ACC_MASK, NWEO_BROAD_MASK, nwio_ethopt::nweo_flags, NWEO_LOC_MASK, nwio_ethopt::nweo_multi, NWEO_MULTI_MASK, NWEO_PROMISC_MASK, nwio_ethopt::nweo_rem, NWEO_REM_MASK, NWEO_RW_MASK, nwio_ethopt::nweo_type, NWEO_TYPE_MASK, NWIOGETHOPT, NWIOGETHSTAT, NWIOSETHOPT, printf, ptr2acc_data, reply_thr_get(), reply_thr_put(), result, TRUE, and unhash_fd().

Referenced by arp_main(), eth_restart_ioctl(), ipeth_main(), and osdep_eth_init().

PUBLIC void eth_loop_ev event_t ev,
ev_arg_t  ev_arg
 

Definition at line 658 of file eth.c.

References assert, bf_bufsize(), eth_arrive(), eth_restart_write(), eth_port::etp_sendev, eth_port::etp_wr_pack, ev_arg::ev_ptr, no_ethWritePort, and NULL.

Referenced by eth_send().

PUBLIC int eth_open int  port,
int  srfd,
get_userdata_t  get_userdata,
put_userdata_t  put_userdata,
put_pkt_t  put_pkt,
select_res_t  select_res
 

Definition at line 123 of file eth.c.

References DBLOCK, EAGAIN, eth_fd::ef_flags, EFF_INUSE, EGENERIC, EPF_ENABLED, ETH_FD_NR, eth_fd_table, eth_port_table, eth_port::etp_flags, i, and printf.

Referenced by arp_main(), ipeth_init(), and osdep_eth_init().

PUBLIC void eth_prep  ) 
 

Definition at line 84 of file eth.c.

References alloc(), and eth_conf_nr.

Referenced by nw_conf().

PUBLIC int eth_read int  fd,
size_t  count
 

Definition at line 534 of file eth.c.

References acc::acc_ext_link, assert, bf_afree(), EBADMODE, eth_fd::ef_exp_time, eth_fd::ef_flags, eth_fd::ef_rdbuf_head, EFF_OPTSET, EFF_READ_IP, EPACKSIZE, eth_fd_table, ETH_MAX_PACK_SIZE, FALSE, get_time(), NW_OK, NW_SUSPEND, packet2user(), and reply_thr_put().

Referenced by do_eth_read(), osdep_eth_init(), and setup_read().

PUBLIC void eth_reg_vlan eth_port_t eth_port,
eth_port_t vlan_port
 

Definition at line 980 of file eth.c.

References ETH_HASH_VLAN, eth_port::etp_vlan, eth_port::etp_vlan_next, eth_port::etp_vlan_tab, and t.

PUBLIC void eth_restart_ioctl eth_port_t eth_port  ) 
 

Definition at line 993 of file eth.c.

References eth_fd::ef_flags, eth_fd::ef_ioctl_req, eth_fd::ef_port, EFF_INUSE, EFF_IOCTL_IP, ETH_FD_NR, eth_fd_table, eth_ioctl(), i, if(), and NWIOGETHSTAT.

Referenced by eth_restart().

PUBLIC void eth_restart_write eth_port_t eth_port  ) 
 

Definition at line 774 of file eth.c.

References assert, eth_fd::ef_flags, eth_fd::ef_send_next, eth_fd::ef_write_count, EFF_WRITE_IP, eth_fd_table, eth_write(), NULL, NW_OK, and r.

Referenced by eth_loop_ev(), and write_int().

PUBLIC int eth_select int  fd,
unsigned  operations
 

Definition at line 624 of file eth.c.

References printf.

Referenced by osdep_eth_init().

PUBLIC int eth_send int  fd,
acc_t data,
size_t  data_len
 

Definition at line 449 of file eth.c.

References acc::acc_next, bf_afree(), bf_memreq(), bf_packIffLess(), count, data, DBLOCK, EBADMODE, eth_fd::ef_ethopt, eth_fd::ef_flags, eth_fd::ef_port, EFF_OPTSET, eth_hdr::eh_dst, eth_hdr::eh_proto, eth_hdr::eh_src, EPACKSIZE, EPF_GOT_ADDR, eth_addrcmp, eth_fd_table, ETH_HDR_SIZE, eth_loop_ev(), ETH_MAX_PACK_SIZE, eth_write_port(), eth_port::etp_ethaddr, eth_port::etp_flags, eth_port::etp_sendev, eth_port::etp_vlan_port, eth_port::etp_wr_pack, ev_enqueue(), ev_arg::ev_ptr, insert_vlan_hdr(), NW_OK, NW_WOULDBLOCK, NWEO_EN_PROMISC, nwio_ethopt::nweo_flags, nwio_ethopt::nweo_rem, NWEO_REMSPEC, NWEO_RWDATONLY, nwio_ethopt::nweo_type, NWEO_TYPESPEC, printf, and ptr2acc_data.

Referenced by eth_write(), and ipeth_restart_send().

PUBLIC int eth_write int  fd,
size_t  count
 

Definition at line 386 of file eth.c.

References assert, DBLOCK, EBADMODE, eth_fd::ef_ethopt, eth_fd::ef_flags, eth_fd::ef_get_userdata, eth_fd::ef_port, eth_fd::ef_send_next, eth_fd::ef_srfd, eth_fd::ef_write_count, EFAULT, EFF_OPTSET, EFF_WRITE_IP, EPACKSIZE, eth_fd_table, ETH_HDR_SIZE, ETH_MAX_PACK_SIZE, eth_send(), eth_port::etp_sendq_head, eth_port::etp_sendq_tail, eth_port::etp_vlan_port, eth_port::etp_wr_pack, FALSE, NULL, NW_OK, NW_SUSPEND, nwio_ethopt::nweo_flags, NWEO_RWDATONLY, printf, r, and reply_thr_get().

Referenced by eth_restart_write(), ipeth_restart_send(), and osdep_eth_init().

PRIVATE void hash_fd eth_fd_t eth_fd  ) 
 

Definition at line 718 of file eth.c.

References eth_fd::ef_ethopt, ETH_TYPE_HASH_NR, eth_port::etp_type, eth_port::etp_type_any, hash(), nwio_ethopt::nweo_type, and NWEO_TYPEANY.

Referenced by eth_ioctl().

PRIVATE acc_t* insert_vlan_hdr eth_port_t eth_port,
acc_t pack
 

Definition at line 1189 of file eth.c.

References bf_afree(), bf_append(), bf_cut(), bf_delhead(), bf_memreq(), bf_packIffLess(), ETH_VLAN_PROTO, htons, HTONS, NULL, printf, ptr2acc_data, type, vlan_hdr_t::vh_type, and vlan_hdr_t::vh_vlan.

Referenced by eth_send().

PRIVATE void packet2user eth_fd_t eth_fd,
acc_t pack,
time_t  exp_time
 

Definition at line 1015 of file eth.c.

References acc::acc_ext_link, acc::acc_linkC, assert, bf_afree(), bf_bufsize(), bf_delhead(), bf_dupacc(), EFF_INUSE, EFF_READ_IP, ETH_HDR_SIZE, FALSE, NULL, NWEO_RWDATONLY, reply_thr_put(), result, and size.

Referenced by eth_read().

PRIVATE void reply_thr_get eth_fd_t eth_fd,
size_t  result,
int  for_ioctl
 

Definition at line 1166 of file eth.c.

References assert, and data.

Referenced by eth_cancel(), eth_ioctl(), eth_write(), ip_ioctl(), psip_ioctl(), restart_write_fd(), tcp_cancel(), tcp_ioctl(), tcp_listen(), tcp_reply_ioctl(), tcp_reply_write(), tcp_setconf(), tcp_setopt(), tcp_write(), udp_cancel(), udp_get_data(), udp_ioctl(), udp_setopt(), and udp_write().

PRIVATE void reply_thr_put eth_fd_t eth_fd,
size_t  result,
int  for_ioctl
 

Definition at line 1177 of file eth.c.

References assert, error, and NW_OK.

Referenced by eth_cancel(), eth_ioctl(), eth_read(), packet2user(), psip_ioctl(), tcp_cancel(), tcp_ioctl(), tcp_read(), tcp_reply_read(), udp_cancel(), udp_ioctl(), udp_peek(), and udp_read().

PRIVATE void unhash_fd eth_fd_t eth_fd  ) 
 

Definition at line 741 of file eth.c.

References eth_fd::ef_ethopt, eth_fd::ef_type_next, ETH_TYPE_HASH_NR, eth_port::etp_type, eth_port::etp_type_any, hash(), NULL, nwio_ethopt::nweo_type, and NWEO_TYPEANY.

Referenced by eth_close(), eth_ioctl(), and udp_close().


Variable Documentation

PRIVATE ether_addr_t broadcast = { { 255, 255, 255, 255, 255, 255 } }
 

Definition at line 82 of file eth.c.

Referenced by eth_arrive(), and ip_eth_arrived().

PRIVATE eth_fd_t eth_fd_table[ETH_FD_NR]
 

Definition at line 81 of file eth.c.

Referenced by compute_rec_conf(), eth_buffree(), eth_cancel(), eth_close(), eth_ioctl(), eth_open(), eth_read(), eth_restart_ioctl(), eth_restart_write(), eth_send(), and eth_write().

PUBLIC eth_port_t* eth_port_table
 

Definition at line 78 of file eth.c.

Referenced by eth_check_drivers(), eth_open(), eth_rec(), eth_restart(), find_port(), and osdep_eth_init().

PUBLIC int no_ethWritePort = 0
 

Definition at line 79 of file eth.c.

Referenced by eth_loop_ev(), eth_write_port(), read_int(), and write_int().


Generated on Fri Apr 14 23:21:13 2006 for minix by  doxygen 1.4.6