home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / netlib / Net_SetAddress.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-04  |  3.2 KB  |  119 lines

  1. /* 
  2.  * Net_SetAddress.c --
  3.  *
  4.  *    Routines to convert Net_Address's to and from network specific
  5.  *    address types.
  6.  *
  7.  * Copyright 1992 Regents of the University of California
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that this copyright
  11.  * notice appears in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  */
  16.  
  17. #ifndef lint
  18. static char rcsid[] = "$Header: /sprite/lib/forms/RCS/proto.c,v 1.6 92/03/02 15:29:56 bmiller Exp $ SPRITE (Berkeley)";
  19. #endif /* not lint */
  20.  
  21. #include <sprite.h>
  22. #include <net.h>
  23.  
  24.  
  25. /*
  26.  *----------------------------------------------------------------------
  27.  *
  28.  * Net_SetAddress --
  29.  *
  30.  *    Converts the network-specific address into a Net_Address.
  31.  *
  32.  * Results:
  33.  *    SUCCESS if the conversion was successful, FAILURE otherwise
  34.  *
  35.  * Side effects:
  36.  *    None.
  37.  *
  38.  *----------------------------------------------------------------------
  39.  */
  40.  
  41. ReturnStatus
  42. Net_SetAddress(type, specificPtr, addrPtr)
  43.     Net_AddressType        type;        /* Type of specific address. */
  44.     Address            specificPtr;    /* The specific address. */
  45.     Net_Address            *addrPtr;    /* Result. */
  46. {
  47.     switch(type) {                
  48.     case NET_ADDRESS_ETHER:                
  49.         addrPtr->type = NET_ADDRESS_ETHER;        
  50.         NET_ETHER_ADDR_COPY((*(Net_EtherAddress *) specificPtr),
  51.         addrPtr->address.ether);            
  52.         break;                        
  53.     case NET_ADDRESS_ULTRA:                    
  54.         addrPtr->type = NET_ADDRESS_ULTRA;            
  55.         Net_UltraAddrCopy((*(Net_UltraAddress *) specificPtr),
  56.         addrPtr->address.ultra);            
  57.         break;                        
  58.     case NET_ADDRESS_FDDI:                    
  59.         addrPtr->type = NET_ADDRESS_FDDI;            
  60.         NET_FDDI_ADDR_COPY((*(Net_FDDIAddress *) specificPtr),
  61.         addrPtr->address.fddi);                
  62.         break;                        
  63.     case NET_ADDRESS_INET:                    
  64.         addrPtr->type = NET_ADDRESS_INET;            
  65.         Net_InetAddrCopy((*(Net_InetAddress *) specificPtr),
  66.         addrPtr->address.inet);            
  67.         break;
  68.     default:
  69.         return FAILURE;
  70.     }            
  71.     return SUCCESS;
  72. }
  73.  
  74. /*
  75.  *----------------------------------------------------------------------
  76.  *
  77.  * Net_GetAddress --
  78.  *
  79.  *    Converts a Net_Address into a network-specific address.
  80.  *
  81.  * Results:
  82.  *    SUCCESS if the conversion was successful, FAILURE otherwise
  83.  *
  84.  * Side effects:
  85.  *    None.
  86.  *
  87.  *----------------------------------------------------------------------
  88.  */
  89.  
  90. ReturnStatus
  91. Net_GetAddress(addrPtr, specificPtr)
  92.     Net_Address        *addrPtr;    /* Address to convert. */
  93.     Address        specificPtr;    /* Result. */
  94. {
  95.     switch(addrPtr->type) {                
  96.     case NET_ADDRESS_ETHER:                
  97.         NET_ETHER_ADDR_COPY(addrPtr->address.ether, 
  98.         (*(Net_EtherAddress *) specificPtr));    
  99.         break;                    
  100.     case NET_ADDRESS_ULTRA:                
  101.         Net_UltraAddrCopy(addrPtr->address.ultra,     
  102.         (*(Net_UltraAddress *) specificPtr));    
  103.         break;                    
  104.     case NET_ADDRESS_FDDI:                
  105.         NET_FDDI_ADDR_COPY(addrPtr->address.fddi,     
  106.         (*(Net_FDDIAddress *) specificPtr));    
  107.         break;                    
  108.     case NET_ADDRESS_INET:                
  109.         Net_InetAddrCopy(addrPtr->address.inet,     
  110.         (*(Net_InetAddress *) specificPtr));    
  111.         break;                    
  112.     default:
  113.         return FAILURE;
  114.     }                            
  115.     return SUCCESS;
  116. }
  117.  
  118.  
  119.