udp.c File Reference

#include "inet.h"
#include "type.h"
#include "assert.h"
#include "buf.h"
#include "clock.h"
#include "icmp_lib.h"
#include "io.h"
#include "ip.h"
#include "sr.h"
#include "udp.h"
#include "udp_int.h"

Include dependency graph for udp.c:

Go to the source code of this file.

Functions

THIS_FILE FORWARD void read_ip_packets ARGS ((udp_port_t *udp_port))
FORWARD void udp_buffree ARGS ((int priority))
FORWARD int udp_select ARGS ((int fd, unsigned operations))
FORWARD acc_t *udp_get_data ARGS ((int fd, size_t offset, size_t count, int for_ioctl))
FORWARD int udp_put_data ARGS ((int fd, size_t offset, acc_t *data, int for_ioctl))
FORWARD int udp_peek ARGS ((udp_fd_t *))
FORWARD void udp_ip_arrived ARGS ((int port, acc_t *pack, size_t pack_size))
FORWARD void reply_thr_put ARGS ((udp_fd_t *udp_fd, int reply, int for_ioctl))
FORWARD int udp_setopt ARGS ((udp_fd_t *udp_fd))
FORWARD udpport_t find_unused_port ARGS ((int fd))
FORWARD int is_unused_port ARGS ((Udpport_t port))
FORWARD u16_t pack_oneCsum ARGS ((acc_t *pack))
FORWARD void udp_rd_enqueue ARGS ((udp_fd_t *udp_fd, acc_t *pack, clock_t exp_tim))
PUBLIC void udp_prep ()
PUBLIC void udp_init ()
PUBLIC int udp_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 udp_ioctl (int fd, ioreq_t req)
PUBLIC int udp_read (int fd, size_t count)
PRIVATE void udp_main (udp_port_t *udp_port)
PRIVATE int udp_select (int fd, unsigned operations)
PRIVATE acc_tudp_get_data (int port, size_t offset, size_t count, int for_ioctl)
PRIVATE int udp_put_data (int fd, size_t offset, acc_t *data, int for_ioctl)
PRIVATE int udp_setopt (udp_fd_t *udp_fd)
PRIVATE udpport_t find_unused_port (int fd)
PRIVATE void reply_thr_put (udp_fd_t *udp_fd, int reply, int for_ioctl)
PRIVATE void reply_thr_get (udp_fd_t *udp_fd, int reply, int for_ioctl)
PRIVATE int is_unused_port (udpport_t port)
PRIVATE void read_ip_packets (udp_port_t *udp_port)
PRIVATE int udp_peek (udp_fd_t *udp_fd)
PRIVATE int udp_sel_read (udp_fd_t *udp_fd)
PRIVATE int udp_packet2user (udp_fd_t *udp_fd)
PRIVATE void udp_ip_arrived (int port, acc_t *pack, size_t pack_size)
PUBLIC void udp_close (int fd)
PUBLIC int udp_write (int fd, size_t count)
PRIVATE void restart_write_fd (udp_fd_t *udp_fd)
PRIVATE u16_t pack_oneCsum (acc_t *pack)
PRIVATE void udp_restart_write_port (udp_port_t *udp_port)
PUBLIC int udp_cancel (int fd, int which_operation)
PRIVATE void udp_buffree (int priority)
PRIVATE void udp_rd_enqueue (udp_fd_t *udp_fd, acc_t *pack, clock_t exp_tim)
PRIVATE void hash_fd (udp_fd_t *udp_fd)
PRIVATE void unhash_fd (udp_fd_t *udp_fd)

Variables

PUBLIC udp_port_tudp_port_table
PUBLIC udp_fd_t udp_fd_table [UDP_FD_NR]


Function Documentation

FORWARD void udp_rd_enqueue ARGS (udp_fd_t *udp_fd, acc_t *pack, clock_t exp_tim)   ) 
 

FORWARD u16_t pack_oneCsum ARGS (acc_t *pack)   ) 
 

FORWARD int is_unused_port ARGS (Udpport_t port  ) 
 

FORWARD udpport_t find_unused_port ARGS (int fd  ) 
 

FORWARD int udp_setopt ARGS (udp_fd_t *udp_fd  ) 
 

FORWARD void reply_thr_put ARGS (udp_fd_t *udp_fd, int reply, int for_ioctl)   ) 
 

FORWARD void udp_ip_arrived ARGS (int port, acc_t *pack, size_t pack_size)   ) 
 

FORWARD int udp_peek ARGS (udp_fd_t *)   ) 
 

FORWARD int udp_put_data ARGS (int fd, size_t offset, acc_t *data, int for_ioctl)   ) 
 

FORWARD acc_t* udp_get_data ARGS (int fd, size_t offset, size_t count, int for_ioctl)   ) 
 

FORWARD int udp_select ARGS (int fd, unsigned operations)   ) 
 

FORWARD void udp_buffree ARGS (int priority)   ) 
 

THIS_FILE FORWARD void read_ip_packets ARGS (udp_port_t *udp_port  ) 
 

PRIVATE udpport_t find_unused_port int  fd  ) 
 

Definition at line 680 of file udp.c.

References htons, is_unused_port(), and UDP_FD_NR.

PRIVATE void hash_fd udp_fd_t udp_fd  ) 
 

Definition at line 1589 of file udp.c.

References hash(), nwio_udpopt::nwuo_locport, NWUO_LP_ANY, UDP_PORT_HASH_NR, udp_fd::uf_udpopt, udp_port::up_port_any, and udp_port::up_port_hash.

PRIVATE int is_unused_port udpport_t  port  ) 
 

Definition at line 732 of file udp.c.

References FALSE, i, if(), udp_fd, UDP_FD_NR, and udp_fd_table.

PRIVATE u16_t pack_oneCsum acc_t pack  ) 
 

Definition at line 1386 of file udp.c.

References assert, FALSE, length, oneC_sum(), and ptr2acc_data.

Referenced by restart_write_fd(), and udp_ip_arrived().

PRIVATE void read_ip_packets udp_port_t udp_port  ) 
 

Definition at line 749 of file udp.c.

References assert, ip_read(), NW_OK, NW_SUSPEND, result, UDP_MAX_DATAGRAM, UPF_READ_IP, and UPF_READ_SP.

PRIVATE void reply_thr_get udp_fd_t udp_fd,
int  reply,
int  for_ioctl
 

Definition at line 721 of file udp.c.

References assert, and result.

PRIVATE void reply_thr_put udp_fd_t udp_fd,
int  reply,
int  for_ioctl
 

Definition at line 705 of file udp.c.

References assert, NW_OK, and result.

PRIVATE void restart_write_fd udp_fd_t udp_fd  ) 
 

Definition at line 1225 of file udp.c.

References acc::acc_next, assert, bf_afree(), bf_bufsize(), bf_cut(), bf_memreq(), bf_packIffLess(), EFAULT, EINVAL, FALSE, flags, htons, HTONS, ip_hdr::ih_dst, ip_hdr::ih_flags_fragoff, ip_hdr::ih_proto, ip_hdr::ih_tos, ip_hdr::ih_ttl, ip_hdr::ih_vers_ihl, IP_DEF_TTL, IP_MIN_HDR_SIZE, ip_write(), IPPROTO_UDP, ntohs, NW_SUSPEND, NWUO_LP_ANY, NWUO_RA_SET, NWUO_RP_SET, NWUO_RWDATALL, oneC_sum(), pack_oneCsum(), ptr2acc_data, reply_thr_get(), result, UDP_HDR_SIZE, UDP_IO_HDR_SIZE, UDP_IP_FLAGS, UDP_TOS, UFF_WRITE_IP, udp_hdr::uh_chksum, udp_hdr::uh_dst_port, udp_hdr::uh_length, udp_hdr::uh_src_port, udp_io_hdr::uih_dst_addr, udp_io_hdr::uih_dst_port, udp_io_hdr::uih_ip_opt_len, udp_io_hdr::uih_src_port, udp_port::up_flags, udp_port::up_ipfd, udp_port::up_wr_pack, udp_port::up_write_fd, UPF_MORE2WRITE, UPF_WRITE_IP, and UPF_WRITE_SP.

Referenced by udp_restart_write_port(), and udp_write().

PRIVATE void udp_buffree int  priority  ) 
 

Definition at line 1506 of file udp.c.

References acc::acc_ext_link, bf_afree(), i, udp_fd, UDP_FD_NR, udp_fd_table, and UDP_PRI_FDBUFS_EXTRA.

PUBLIC int udp_cancel int  fd,
int  which_operation
 

Definition at line 1470 of file udp.c.

References assert, DBLOCK, EINTR, FALSE, ip_panic, NULL, NW_OK, printf, reply_thr_get(), reply_thr_put(), SR_CANCEL_IOCTL, SR_CANCEL_READ, SR_CANCEL_WRITE, TRUE, udp_fd, udp_fd_table, UFF_IOCTL_IP, UFF_PEEK_IP, UFF_READ_IP, and UFF_WRITE_IP.

PUBLIC void udp_close int  fd  ) 
 

Definition at line 1165 of file udp.c.

References acc::acc_ext_link, assert, bf_afree(), NULL, udp_fd, udp_fd_table, UFF_EMPTY, UFF_INUSE, and unhash_fd().

PRIVATE acc_t* udp_get_data int  port,
size_t  offset,
size_t  count,
int  for_ioctl
 

Definition at line 327 of file udp.c.

References assert, bf_afree(), bf_cut(), bf_memreq(), FALSE, int(), IPPROTO_UDP, NULL, NWIO_COPY, NWIO_EN_BROAD, NWIO_EN_LOC, NWIO_HDR_O_ANY, NWIO_PROTOSPEC, NWIO_REMANY, NWIO_RWDATALL, printf, ptr2acc_data, reply_thr_get(), result, udp_fd, udp_main(), udp_restart_write_port(), UFF_WRITE_IP, udp_port::up_flags, udp_port::up_state, udp_port::up_wr_pack, udp_port::up_write_fd, UPF_MORE2WRITE, UPF_SUSPEND, UPF_WRITE_IP, UPF_WRITE_SP, UPS_ERROR, UPS_GETCONF, UPS_MAIN, and UPS_SETPROTO.

Referenced by udp_main().

PUBLIC void udp_init  ) 
 

Definition at line 60 of file udp.c.

References assert, BUF_S, i, j, NULL, udp_fd, UDP_FD_NR, UDP_HDR_SIZE, UDP_IO_HDR_SIZE, and UFF_EMPTY.

Referenced by nw_init().

PUBLIC int udp_ioctl int  fd,
ioreq_t  req
 

Definition at line 144 of file udp.c.

References acc::acc_length, assert, bf_memreq(), EBADIOCTL, NW_OK, NW_SUSPEND, NWIOGUDPOPT, NWIOSUDPOPT, NWIOUDPPEEK, ptr2acc_data, reply_thr_get(), reply_thr_put(), result, TRUE, udp_fd, udp_peek(), udp_setopt(), UFF_INUSE, UFF_IOCTL_IP, udp_port::up_state, and UPS_MAIN.

Referenced by udp_main().

PRIVATE void udp_ip_arrived int  port,
acc_t pack,
size_t  pack_size
 

Definition at line 896 of file udp.c.

References acc::acc_linkC, acc::acc_next, assert, bf_afree(), bf_cut(), bf_delhead(), bf_memreq(), bf_packIffLess(), DBLOCK, flags, get_time(), hash(), htons, HTONS, i, if(), ip_hdr::ih_dst, IH_IHL_MASK, ip_hdr::ih_proto, ip_hdr::ih_src, ip_hdr::ih_vers_ihl, IP_MIN_HDR_SIZE, ntohs, NULL, NWUO_EN_BROAD, NWUO_EN_LOC, NWUO_RP_SET, oneC_sum(), pack_oneCsum(), printf, ptr2acc_data, udp_fd, UDP_HDR_SIZE, UDP_IO_HDR_SIZE, UDP_PORT_HASH_NR, udp_port_table, UDP_READ_EXP_TIME, UFF_INUSE, udp_hdr::uh_chksum, udp_hdr::uh_dst_port, udp_hdr::uh_length, udp_hdr::uh_src_port, udp_io_hdr::uih_data_len, udp_io_hdr::uih_dst_addr, udp_io_hdr::uih_dst_port, udp_io_hdr::uih_ip_opt_len, udp_io_hdr::uih_src_addr, udp_io_hdr::uih_src_port, udp_port::up_ipaddr, udp_port::up_port_any, udp_port::up_port_hash, and writeIpAddr().

Referenced by udp_main(), and udp_put_data().

PRIVATE void udp_main udp_port_t udp_port  ) 
 

Definition at line 228 of file udp.c.

References DBLOCK, i, if(), ip_ioctl(), ip_open(), ip_panic, NW_SUSPEND, NWIOGIPCONF, NWIOSIPOPT, printf, read_ip_packets(), result, udp_fd, UDP_FD_NR, udp_get_data(), udp_ioctl(), udp_ip_arrived(), udp_put_data(), UFF_INUSE, UFF_IOCTL_IP, UPF_SUSPEND, UPS_EMPTY, UPS_ERROR, UPS_GETCONF, UPS_MAIN, and UPS_SETPROTO.

Referenced by udp_get_data(), and udp_put_data().

PUBLIC int udp_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 107 of file udp.c.

References DBLOCK, EAGAIN, i, printf, UDP_FD_NR, and UFF_INUSE.

PRIVATE int udp_packet2user udp_fd_t udp_fd  ) 
 

Definition at line 836 of file udp.c.

References acc::acc_ext_link, acc::acc_length, assert, bf_afree(), bf_bufsize(), bf_cut(), bf_packIffLess(), EPACKSIZE, FALSE, hdr, NTOHS, NWUO_RWDATONLY, ptr2acc_data, result, size, UDP_IO_HDR_SIZE, UFF_READ_IP, and udp_io_hdr::uih_ip_opt_len.

Referenced by udp_read().

PRIVATE int udp_peek udp_fd_t udp_fd  ) 
 

Definition at line 769 of file udp.c.

References acc::acc_ext_link, assert, bf_afree(), bf_cut(), EBADMODE, get_time(), NULL, NW_OK, NW_SUSPEND, reply_thr_put(), result, TRUE, UFF_IOCTL_IP, and UFF_PEEK_IP.

Referenced by udp_ioctl().

PUBLIC void udp_prep  ) 
 

Definition at line 55 of file udp.c.

References alloc(), and udp_conf_nr.

Referenced by nw_conf().

PRIVATE int udp_put_data int  fd,
size_t  offset,
acc_t data,
int  for_ioctl
 

Definition at line 413 of file udp.c.

References assert, bf_afree(), bf_bufsize(), bf_packIffLess(), compare, data, int(), ip_panic, NW_OK, NWIC_IPADDR_SET, ptr2acc_data, read_ip_packets(), result, udp_ip_arrived(), udp_main(), udp_port::up_flags, udp_port::up_ipaddr, udp_port::up_state, UPF_READ_IP, UPF_READ_SP, UPF_SUSPEND, UPS_ERROR, UPS_GETCONF, and UPS_MAIN.

Referenced by udp_main().

PRIVATE void udp_rd_enqueue udp_fd_t udp_fd,
acc_t pack,
clock_t  exp_tim
 

Definition at line 1541 of file udp.c.

References acc::acc_ext_link, acc::acc_linkC, assert, bf_afree(), bf_cut(), bf_dupacc(), NULL, printf, result, SR_SELECT_READ, TRUE, UFF_IOCTL_IP, UFF_PEEK_IP, and UFF_SEL_READ.

PUBLIC int udp_read int  fd,
size_t  count
 

Definition at line 195 of file udp.c.

References acc::acc_ext_link, bf_afree(), EBADMODE, FALSE, get_time(), NULL, NW_OK, NW_SUSPEND, reply_thr_put(), udp_fd, udp_packet2user(), UFF_OPTSET, and UFF_READ_IP.

PRIVATE void udp_restart_write_port udp_port_t udp_port  ) 
 

Definition at line 1434 of file udp.c.

References assert, i, restart_write_fd(), udp_fd, UDP_FD_NR, udp_fd_table, UFF_INUSE, UFF_WRITE_IP, UPF_MORE2WRITE, UPF_WRITE_IP, and UPF_WRITE_SP.

Referenced by udp_get_data().

PRIVATE int udp_sel_read udp_fd_t udp_fd  ) 
 

Definition at line 810 of file udp.c.

References acc::acc_ext_link, bf_afree(), get_time(), NULL, and result.

Referenced by udp_select().

PRIVATE int udp_select int  fd,
unsigned  operations
 

Definition at line 295 of file udp.c.

References assert, i, printf, SR_SELECT_EXCEPTION, SR_SELECT_POLL, SR_SELECT_READ, SR_SELECT_WRITE, udp_fd, udp_sel_read(), UFF_INUSE, and UFF_SEL_READ.

PRIVATE int udp_setopt udp_fd_t udp_fd  ) 
 

Definition at line 482 of file udp.c.

References assert, bf_afree(), bf_packIffLess(), data, DBLOCK, EADDRINUSE, EBADMODE, EFAULT, find_unused_port(), flags, i, if(), long(), NW_OK, NWUO_ACC_MASK, NWUO_BROAD_MASK, NWUO_EN_IPOPT, nwio_udpopt::nwuo_flags, NWUO_IPOPT_MASK, NWUO_LOCADDR_MASK, nwio_udpopt::nwuo_locport, NWUO_LOCPORT_MASK, NWUO_LP_ANY, NWUO_LP_SEL, NWUO_LP_SET, NWUO_RA_ANY, nwio_udpopt::nwuo_remaddr, NWUO_REMADDR_MASK, nwio_udpopt::nwuo_remport, NWUO_REMPORT_MASK, NWUO_RP_ANY, NWUO_RW_MASK, NWUO_RWDATONLY, printf, ptr2acc_data, reply_thr_get(), TRUE, UDP_FD_NR, udp_fd::uf_flags, udp_fd::uf_port, udp_fd::uf_udpopt, and UFF_INUSE.

Referenced by udp_ioctl().

PUBLIC int udp_write int  fd,
size_t  count
 

Definition at line 1189 of file udp.c.

References assert, DBLOCK, EBADMODE, FALSE, NW_OK, NW_SUSPEND, printf, reply_thr_get(), restart_write_fd(), udp_fd, udp_fd_table, and UFF_WRITE_IP.

PRIVATE void unhash_fd udp_fd_t udp_fd  ) 
 

Definition at line 1613 of file udp.c.

References hash(), NULL, nwio_udpopt::nwuo_locport, NWUO_LP_ANY, UDP_PORT_HASH_NR, udp_fd::uf_port_next, udp_fd::uf_udpopt, udp_port::up_port_any, and udp_port::up_port_hash.


Variable Documentation

PUBLIC udp_fd_t udp_fd_table[UDP_FD_NR]
 

Definition at line 53 of file udp.c.

PUBLIC udp_port_t* udp_port_table
 

Definition at line 52 of file udp.c.


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