Please wait until the page is fully downloaded and then press the "Expand" button or the blue line numbers.

0041001 /*
0041002 generic/ip_ps.c
0041003 
0041004 pseudo IP specific part of the IP implementation
0041005 
0041006 Created:       Apr 23, 1993 by Philip Homburg
0041007 
0041008 Copyright 1995 Philip Homburg
0041009 */
0041010 
0041011 #include "inet.h"
0041012 #include "assert.h"
0041013 #include "type.h"
0041014 #include "buf.h"
0041015 #include "event.h"
0041016 #include "ip.h"
0041017 #include "ip_int.h"
0041018 #include "psip.h"
0041019 
0041020 THIS_FILE
0041021 
0041022 FORWARD void ipps_main ARGS(( ip_port_t *ip_port ));
0041023 FORWARD void ipps_set_ipaddr ARGS(( ip_port_t *ip_port ));
0041024 FORWARD int ipps_send ARGS(( struct ip_port *ip_port, ipaddr_t dest,
0041025                                           acc_t *pack, int broadcast ));
0041026 
0041027 PUBLIC int ipps_init(ip_port)
0041028 ip_port_t *ip_port;
0041029 {
0041030          int result;
0041031 
0041032          result= psip_enable(ip_port->ip_dl.dl_ps.ps_port, ip_port->ip_port);
0041033          if (result == -1)
0041034                   return -1;
0041035 #if ZERO
0041036          ip_port->ip_dl.dl_ps.ps_send_head= NULL;
0041037          ip_port->ip_dl.dl_ps.ps_send_tail= NULL;
0041038 #endif
0041039          ip_port->ip_dev_main= ipps_main;
0041040          ip_port->ip_dev_set_ipaddr= ipps_set_ipaddr;
0041041          ip_port->ip_dev_send= ipps_send;
0041042          return result;
0041043 }
0041044 
0041045 PUBLIC void ipps_get(ip_port_nr)
0041046 int ip_port_nr;
0041047 {
0041048          int result;
0041049          acc_t *pack;
0041050          ip_port_t *ip_port;
0041051 
0041052          assert(ip_port_nr >= 0 && ip_port_nr < ip_conf_nr);
0041053          ip_port= &ip_port_table[ip_port_nr];
0041054          assert(ip_port->ip_dl_type == IPDL_PSIP);
0041055 
0041056          while (ip_port->ip_dl.dl_ps.ps_send_head != NULL)
0041057          {
0041058                   pack= ip_port->ip_dl.dl_ps.ps_send_head;
0041059                   ip_port->ip_dl.dl_ps.ps_send_head= pack->acc_ext_link;
0041060                   result= psip_send(ip_port->ip_dl.dl_ps.ps_port, pack);
0041061                   if (result != NW_SUSPEND)
0041062                   {
0041063                            assert(result == NW_OK);
0041064                            continue;
0041065                   }
0041066                   pack->acc_ext_link= ip_port->ip_dl.dl_ps.ps_send_head;
0041067                   ip_port->ip_dl.dl_ps.ps_send_head= pack;
0041068                   if (pack->acc_ext_link == NULL)
0041069                            ip_port->ip_dl.dl_ps.ps_send_tail= pack;
0041070                   break;
0041071          }
0041072 }
0041073 
0041074 PUBLIC void ipps_put(ip_port_nr, pack)
0041075 int ip_port_nr;
0041076 acc_t *pack;
0041077 {
0041078          ip_port_t *ip_port;
0041079 
0041080          assert(ip_port_nr >= 0 && ip_port_nr < ip_conf_nr);
0041081          ip_port= &ip_port_table[ip_port_nr];
0041082          assert(ip_port->ip_dl_type == IPDL_PSIP);
0041083          ip_arrived(ip_port, pack);
0041084 }
0041085 
0041086 PRIVATE void ipps_main(ip_port)
0041087 ip_port_t *ip_port;
0041088 {
0041089          /* nothing to do */
0041090 }
0041091 
0041092 PRIVATE void ipps_set_ipaddr(ip_port)
0041093 ip_port_t *ip_port;
0041094 {
0041095          int i;
0041096          ip_fd_t *ip_fd;
0041097 
0041098          /* revive calls waiting for an ip addresses */
0041099          for (i=0, ip_fd= ip_fd_table; i<IP_FD_NR; i++, ip_fd++)
0041100          {
0041101                   if (!(ip_fd->if_flags & IFF_INUSE))
0041102                   {
0041103                            continue;
0041104                   }
0041105                   if (ip_fd->if_port != ip_port)
0041106                   {
0041107                            continue;
0041108                   }
0041109                   if (ip_fd->if_flags & IFF_GIPCONF_IP)
0041110                   {
0041111                            ip_ioctl (i, NWIOGIPCONF);
0041112                   }
0041113          }
0041114 }
0041115 
0041116 PRIVATE int ipps_send(ip_port, dest, pack, broadcast)
0041117 struct ip_port *ip_port;
0041118 ipaddr_t dest;
0041119 acc_t *pack;
0041120 int broadcast;
0041121 {
0041122          int result;
0041123 
0041124          if (broadcast)
0041125                   ip_arrived_broadcast(ip_port, bf_dupacc(pack));
0041126 
0041127          if (ip_port->ip_dl.dl_ps.ps_send_head == NULL)
0041128          {
0041129                   result= psip_send(ip_port->ip_dl.dl_ps.ps_port, pack);
0041130                   if (result != NW_SUSPEND)
0041131                   {
0041132                            assert(result == NW_OK);
0041133                            return result;
0041134                   }
0041135                   assert (ip_port->ip_dl.dl_ps.ps_send_head == NULL);
0041136                   ip_port->ip_dl.dl_ps.ps_send_head= pack;
0041137          }
0041138          else
0041139                   ip_port->ip_dl.dl_ps.ps_send_tail->acc_ext_link= pack;
0041140          ip_port->ip_dl.dl_ps.ps_send_tail= pack;
0041141          pack->acc_ext_link= NULL;
0041142 
0041143          return NW_OK;
0041144 }
0041145 
0041146 /*
0041147  * $PchId: ip_ps.c,v 1.5 1995/11/21 06:45:27 philip Exp $
0041148  */