2 //=============================================================================
6 * The Vb class is an encapsulation of the snmp variable binding.
7 * This module contains the class definition for the variable binding (VB)
8 * class. The VB class is an encapsulation of a SNMP VB. A VB object is
9 * composed of one SNMP++ Oid and one SMI value. The Vb class utilizes Oid
10 * objects and thus requires the Oid class. To use this class,
11 * set oid, value then call valid() to be sure object was constructed correctly.
13 * @author Peter E MellquistMichael R MacFaden mrm@cisco.com - rework & ACE port
15 //=============================================================================
17 /*===================================================================
19 Hewlett-Packard Company
21 ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
22 Permission to use, copy, modify, distribute and/or sell this software
23 and/or its documentation is hereby granted without fee. User agrees
24 to display the above copyright notice and this license notice in all
25 copies of the software and any documentation of the software. User
26 agrees to assume all liability for the use of the software; Hewlett-Packard
27 makes no representations about the suitability of this software for any
28 purpose. It is provided "AS-IS without warranty of any kind,either express
29 or implied. User hereby grants a royalty-free license to any and all
30 derivatives based upon this software code base.
31 =====================================================================*/
33 #include "asnmp/address.h"
34 #include "ace/OS_NS_string.h"
35 #include "ace/OS_NS_arpa_inet.h"
36 #include "ace/OS_NS_netdb.h"
37 #include "ace/OS_NS_stdlib.h"
38 #include "ace/OS_NS_stdio.h"
39 #include "ace/OS_NS_ctype.h"
40 #include "ace/OS_Memory.h"
42 //=================================================================
43 //======== Abstract Address Class Implementation ==================
44 //=================================================================
46 // allow destruction of derived classes
52 //-----------------------------------------------------------------
53 // is the address object valid?
54 int Address::valid() const
59 //------------[ Address::trim_white_space( char * ptr) ]------------
60 // destructive trim white space
61 void Address::trim_white_space( char * ptr
)
66 // skip leading white space
67 while (*tmp
==' ')tmp
++;
68 ACE_OS::strcpy(ptr
,tmp
);
71 while ((*tmp
!=' ') && (*tmp
!=0)) tmp
++;
75 //TM: this is not used nor needed, remove?
76 //-----[ element access ]----------------------------------------------
77 unsigned char& Address::operator[]( const int position
)
79 if ( position
< MAX_ADDR_SZ
)
80 return address_buffer
[ position
];
82 return address_buffer
[0];
86 //-----------------------------------------------------------------------
87 // overloaded equivlence operator, are two addresses equal?
88 bool operator==( const Address
&lhs
, const Address
&rhs
)
90 if ( ACE_OS::strcmp( (const char*) lhs
, (const char*)rhs
)==0)
96 //-----------------------------------------------------------------------
97 // overloaded equivlence operator, are two addresses equal?
98 bool operator!=( const Address
&lhs
, const Address
&rhs
)
100 return (!( lhs
== rhs
));
104 //------------------------------------------------------------------
105 // overloaded > operator, is a1 > a2
106 bool operator>( const Address
&lhs
, const Address
&rhs
)
108 if (ACE_OS::strcmp( (const char*) lhs
, (const char*)rhs
)>0)
114 // overloaded >= operator, is a1 > a2
115 bool operator>=( const Address
&lhs
,const Address
&rhs
)
117 if (( lhs
> rhs
) || ( lhs
== rhs
))
123 // overloaded < operator, is a1 <= a2
124 bool operator<=( const Address
&lhs
,const Address
&rhs
)
126 if (( lhs
< rhs
) || ( lhs
== rhs
))
133 //-----------------------------------------------------------------
134 // overloaded < operator, is a1 < a2
135 bool operator<( const Address
&lhs
, const Address
&rhs
)
137 if (ACE_OS::strcmp( (const char*) lhs
, (const char*)rhs
)<0)
143 //------------------------------------------------------------------
144 // equivlence operator overloaded, are an address and a string equal?
145 bool operator==( const Address
&lhs
,const char *rhs
)
147 if (!rhs
&& !lhs
.valid())
149 if (ACE_OS::strcmp( (const char *) lhs
, rhs
)== 0)
155 //------------------------------------------------------------------
156 // not equal operator overloaded, are an address and a string not equal?
157 bool operator!=( const Address
&lhs
,const char *rhs
)
159 return (!( lhs
== rhs
));
162 //------------------------------------------------------------------
163 // overloaded > , is a > inaddr
164 bool operator>( const Address
&lhs
,const char *rhs
)
167 return lhs
.valid(); // if lhs valid then > 0, else invalid !> 0
168 if (ACE_OS::strcmp( (const char *) lhs
, rhs
)> 0)
174 //------------------------------------------------------------------
175 // overloaded >= , is a >= inaddr
176 bool operator>=( const Address
&lhs
,const char *rhs
)
179 return true; // always >= 0
180 if (ACE_OS::strcmp( (const char *) lhs
, rhs
)>= 0)
186 //-----------------------------------------------------------------
187 // overloaded < , are an address and a string equal?
188 bool operator<( const Address
&lhs
,const char *rhs
)
191 return false; // always >= 0
192 if (ACE_OS::strcmp( (const char *) lhs
, rhs
)< 0)
198 //-----------------------------------------------------------------
199 // overloaded <= , is a <= inaddr
200 bool operator<=( const Address
&lhs
,const char *rhs
)
203 return !lhs
.valid(); // invalid == 0, else valid > 0
204 if (ACE_OS::strcmp( (const char *) lhs
, rhs
) <= 0)
211 //=====================================================================
212 //============ IPAddress Implementation ===============================
213 //=====================================================================
215 //-----------[ syntax type ]----------------------------------------------
216 SmiUINT32
IpAddress::get_syntax()
218 return sNMP_SYNTAX_IPADDR
;
221 //-----[ IP Address copy constructor ]---------------------------------
222 IpAddress::IpAddress(const IpAddress
&ipaddr
)
225 // always initialize what type this object is
226 smival
.syntax
= sNMP_SYNTAX_IPADDR
;
227 smival
.value
.string
.len
=IPV4LEN
;
228 smival
.value
.string
.ptr
= address_buffer
;
230 iv_friendly_name_
[0] = 0;
231 iv_friendly_name_status_
= 0;
232 valid_flag
= ipaddr
.valid_flag
;
234 ACE_OS::memcpy(address_buffer
, ipaddr
.address_buffer
,IPV4LEN
);
235 ACE_OS::strcpy( iv_friendly_name_
, ipaddr
.iv_friendly_name_
);
238 IpAddress::format_output();
242 //-------[ default construct, an IP address with a string ]---------------------
243 IpAddress::IpAddress( const char *inaddr
): Address()
245 // always initialize what type this object is
246 smival
.syntax
= sNMP_SYNTAX_IPADDR
;
247 smival
.value
.string
.len
= IPV4LEN
;
248 smival
.value
.string
.ptr
= address_buffer
;
250 if (ACE_OS::strlen(inaddr
) == 0) {
252 iv_friendly_name_
[0] = 0;
253 iv_friendly_name_status_
= 0;
254 IpAddress::format_output();
258 // parse_address initializes valid, address_buffer & iv_friendly_name_
259 valid_flag
= parse_address(inaddr
);
260 IpAddress::format_output();
264 //-----[ construct an IP address with a GenAddress ]---------------------
265 IpAddress::IpAddress( const GenAddress
&genaddr
)
267 // always initialize what type this object is
268 smival
.syntax
= sNMP_SYNTAX_IPADDR
;
269 smival
.value
.string
.len
= IPV4LEN
;
270 smival
.value
.string
.ptr
= address_buffer
;
273 iv_friendly_name_
[0] = 0;
274 iv_friendly_name_status_
= 0;
275 // allow use of an ip or udp genaddress
276 if (genaddr
.get_type() == type_ip
) {
277 valid_flag
= genaddr
.valid();
279 // copy in the IP address data
280 IpAddress
temp_ip( (const char *) genaddr
);
285 if (genaddr
.get_type() == type_udp
) {
286 valid_flag
= genaddr
.valid();
288 // copy in the IP address data
289 UdpAddress
temp_udp( (const char *) genaddr
);
293 IpAddress::format_output();
296 //-----[ destructor ]--------------------------------------------------
297 IpAddress::~IpAddress()
301 // assumes member data is word aligned to avoid sigbus
302 int IpAddress::is_loopback() const
305 u_long
*pl
= (u_long
*)&address_buffer
;
306 return (*pl
== INADDR_LOOPBACK
);
311 int IpAddress::is_multicast() const
314 u_long
*pl
= (u_long
*)&address_buffer
;
315 return (IN_MULTICAST(*pl
));
320 // Private addressess not are not assignable in the Internet, they are
321 // defined in RFC 1597 as: 10, 172.16, and 192.168.0
322 // Some companies use them internally and apply NAT to allow translation
323 // instead of paying for ip networks.
324 // Cisco IOS devices can provide NAT aka Network Address Translation
325 // but don't expect SNMP based networks to handle cross-NAT address spaces.
326 // assumes storage in network byte order mrm@cisco.com 7/28/97
328 int IpAddress::is_private() const
331 if (address_buffer
[0] == 10)
333 if (address_buffer
[0] == 172 && address_buffer
[1] == 16)
335 if (address_buffer
[0] == 192 && address_buffer
[1] == 168 &&
336 address_buffer
[2] == 0)
343 // convert address into octet string format in network byte order
344 void IpAddress::to_octet(OctetStr
& octet
) const
346 octet
.set_data( smival
.value
.string
.ptr
, smival
.value
.string
.len
);
350 int IpAddress::is_broadcast() const
353 u_long
*pl
= (u_long
*)&address_buffer
;
354 return ( (*pl
) & INADDR_BROADCAST
);
359 //-----[ IP Address general = operator ]-------------------------------
360 SnmpSyntax
& IpAddress::operator=( SnmpSyntax
&val
)
362 // protect against assignment from itself
366 valid_flag
= 0; // will get set 1 if really valid
367 iv_friendly_name_
[0]=0;
370 switch (val
.get_syntax()) {
371 case sNMP_SYNTAX_IPADDR
:
372 case sNMP_SYNTAX_OCTETS
:
373 if (((IpAddress
&)val
).smival
.value
.string
.len
==IPV4LEN
) {
374 ACE_OS::memcpy(address_buffer
,
375 ((IpAddress
&)val
).smival
.value
.string
.ptr
,IPV4LEN
);
380 // NOTE: as a value add, other types could have "logical"
381 // mappings, i.e. integer32 and unsigned32
384 IpAddress::format_output();
388 //------[ assignment to another ipaddress object overloaded ]-----------------
389 IpAddress
& IpAddress::operator=( const IpAddress
&ipaddress
)
391 // protect against assignment from itself
392 if ( this == &ipaddress
)
395 valid_flag
= ipaddress
.valid_flag
;
396 iv_friendly_name_
[0]=0;
399 ACE_OS::memcpy(address_buffer
, ipaddress
.address_buffer
, IPV4LEN
);
400 ACE_OS::strcpy(iv_friendly_name_
, ipaddress
.iv_friendly_name_
);
402 IpAddress::format_output();
407 //--------[ create a new instance of this Value ]-----------------------
408 SnmpSyntax
*IpAddress::clone() const
410 return (SnmpSyntax
*) new IpAddress(*this);
413 //-------[ return the Fully Qualified Domain Name ]----------------------
414 const char *IpAddress::resolve_hostname(int &status
)
416 if ((iv_friendly_name_
[0] == 0) && valid_flag
)
418 status
= iv_friendly_name_status_
;
419 return iv_friendly_name_
;
422 // parse a dotted string
423 int IpAddress::parse_dotted_ipstring( const char *inaddr
)
428 int error_status
= 0;
429 char temp
[MAXHOSTNAMELEN
+1]; // temp buffer for destruction
432 // check len, an ip can never be bigger than 15
435 if ( !inaddr
|| (ACE_OS::strlen( inaddr
) > 30))
437 ACE_OS::strcpy( temp
, inaddr
);
438 trim_white_space( temp
);
439 if ( ACE_OS::strlen( temp
) > 15)
442 // must only have three dots
443 // strtok will not catch this !
447 if ( *ptr
== '.') dot_count
++;
453 // look for dot token separator
454 ip_token
= ACE_OS::strtok( (char *) temp
,".");
456 // while more tokens..
457 while ( ip_token
!= 0) {
458 // verify that the token is all numerics
459 w
= ACE_OS::strlen( ip_token
);
463 if (( ip_token
[z
] < '0') || ( ip_token
[z
] > '9'))
466 value
= ( unsigned int) ACE_OS::strtod(ip_token
,0);
467 if (( value
> 0)&& ( value
<=255))
468 address_buffer
[token_count
] = (unsigned char) value
;
470 if (ACE_OS::strcmp(ip_token
,"0")==0)
471 address_buffer
[token_count
]= (unsigned char) 0;
475 ip_token
= ACE_OS::strtok( 0, ".");
478 // gota be four in len
479 if ( token_count
!= 4)
482 // any parsing errors?
489 //-----[ IP Address parse Address ]---------------------------------
490 int IpAddress::parse_address( const char *inaddr
)
492 // parse the input char array
493 // fill up internal buffer with four ip bytes
494 // set and return validity flag
497 char ds
[MAXHOSTNAMELEN
+1];
499 // intialize the friendly_name member variable
500 iv_friendly_name_
[0] = 0;
501 iv_friendly_name_status_
= 0;
503 // is this a dotted IP notation string or
505 if ( parse_dotted_ipstring( inaddr
)) {
506 // since this is a valid dotted string
507 // don't do any DNS (Performance!)
512 if ((rc
= resolve_to_address(inaddr
, ipAddr
)) == 0) {
513 // now lets check out the dotted string
514 ACE_OS::strncpy( ds
, ACE_OS::inet_ntoa(ipAddr
), MAXHOSTNAMELEN
);
516 if ( !parse_dotted_ipstring( ds
))
519 // save the friendly name
520 ACE_OS::strcpy( iv_friendly_name_
, inaddr
);
521 } // end if lookup result
523 iv_friendly_name_status_
= rc
;
526 } // end else not a dotted string
530 // using the currently defined address, do a DNS
531 // and try to fill up the name
532 int IpAddress::addr_to_friendly()
535 long result
= ACE_OS::inet_addr(to_string());
537 return -1; // expected a dotted quad!
539 ipAddr
.s_addr
= result
;
541 // set iv_friendly_name_ from ipAddr
542 if (resolve_to_hostname(ipAddr
, iv_friendly_name_
) == 0) {
546 #if defined (VXWORKS)
547 // VxWorks doesn't have h_errno
548 iv_friendly_name_status_
= errno
;
550 iv_friendly_name_status_
= h_errno
;
552 return iv_friendly_name_status_
;
556 // static aka class member function (1.2.3.4 -> foo.com)
557 int IpAddress::resolve_to_hostname(const in_addr
& quad_addr
, char *hostname
)
559 struct hostent lookupResult
;
561 ACE_HOSTENT_DATA buffer
;
562 ACE_OS::memset(&lookupResult
, 0, sizeof(struct hostent
));
563 ACE_OS::memset(&buffer
, 0, sizeof(ACE_HOSTENT_DATA
));
565 // reverse lookup (requires in-addr.arpa to be setup in DNS
566 if (ACE_OS::gethostbyaddr_r((const char *)&quad_addr
.s_addr
, IPV4LEN
,
567 AF_INET
, &lookupResult
, buffer
, &loc_errno
)) {
568 // verify right type of record
569 if (lookupResult
.h_addrtype
== AF_INET
&&
570 lookupResult
.h_length
== IPV4LEN
) {
571 ACE_OS::strcpy( hostname
, lookupResult
.h_name
);
572 // setup multiple entries
576 ACE_ASSERT(0); // todo add trace and debug and dump
577 return -1; // wrong resource record type
584 // static aka class member function (foo.com -> 1.2.3.4)
585 int IpAddress::resolve_to_address(const char *hostname
, in_addr
& quad_addr
)
587 struct hostent lookupResult
;
588 ACE_HOSTENT_DATA buffer
;
589 ACE_OS::memset(&buffer
, 0, sizeof(ACE_HOSTENT_DATA
));
590 ACE_OS::memset(&lookupResult
, 0, sizeof(struct hostent
));
592 if (ACE_OS::gethostbyname_r( hostname
, &lookupResult
, buffer
, &loc_errno
)) {
593 if (lookupResult
.h_length
== (int) sizeof(in_addr
) &&
594 lookupResult
.h_addrtype
== AF_INET
) {
595 ACE_OS::memcpy((void *) &quad_addr
,
596 (void *) lookupResult
.h_addr_list
[0], sizeof(in_addr
));
600 return -1; // wrong address size
605 //----[ IP address char * cast ]--------------------------------------
606 IpAddress::operator const char *() const
608 return (char *)output_buffer
;
611 //----[ IP address get char representation ]--------------------------
612 const char * IpAddress::to_string()
614 return (char *)output_buffer
;
617 //----[ IP address format output ]------------------------------------
618 void IpAddress::format_output()
620 // if valid format else null it
622 ACE_OS::sprintf( (char *) output_buffer
,"%d.%d.%d.%d",address_buffer
[0],
623 address_buffer
[1], address_buffer
[2], address_buffer
[3]);
625 output_buffer
[0] = 0;
628 //------[ return the type ]----------------------------------
629 addr_type
IpAddress::get_type() const
634 //-----------------------------------------------------------------
635 // logically and two IPaddresses and
636 // return the new one
637 void IpAddress::mask( const IpAddress
& ipaddr
)
639 if ( this->valid() && ipaddr
.valid()) {
640 this->address_buffer
[0] = this->address_buffer
[0] & ipaddr
.address_buffer
[0];
641 this->address_buffer
[1] = this->address_buffer
[1] & ipaddr
.address_buffer
[1];
642 this->address_buffer
[2] = this->address_buffer
[2] & ipaddr
.address_buffer
[2];
643 this->address_buffer
[3] = this->address_buffer
[3] & ipaddr
.address_buffer
[3];
649 //=======================================================================
650 //========== DNS Iterator Implementation ================================
651 //=======================================================================
654 Address_Iter::Address_Iter (const char *hostname
)
659 ACE_OS::memset (&buffer_
, 0, sizeof (ACE_HOSTENT_DATA
));
660 ACE_OS::memset (&lookupResult_
, 0, sizeof (struct hostent
));
662 if (ACE_OS::inet_addr (hostname
) == (unsigned long) -1)
664 valid_
= query_dns (hostname
);
668 ACE_ASSERT (0); // don't support dot-quad lookup yet
671 // count number of hostnames
675 for (n
= 0, pc
= lookupResult_
.h_addr_list
; *pc
!= 0; ++n
, ++pc
)
680 count_
= n
; // plus first one
681 entry_
= lookupResult_
.h_addr_list
;
684 int Address_Iter::valid() const
686 return (valid_
== 1);
689 int Address_Iter::how_many_addresses()
694 // return next entry, rc = 0, if entry is null return 0
695 int Address_Iter::next(IpAddress
& addr
)
697 if (!entry_
|| *entry_
== 0)
700 IpAddress
tmp(*entry_
++); // return data
708 int Address_Iter::query_dns(const char *hostname
)
711 if (ACE_OS::gethostbyname_r( hostname
, &lookupResult_
, buffer_
,
713 if (lookupResult_
.h_length
== (int) sizeof(IPV4LEN
) &&
714 lookupResult_
.h_addrtype
== AF_INET
) {
718 return -1; // wrong address size
723 //=======================================================================
724 //========== Udp Address Implementation =================================
725 //=======================================================================
727 //-----------[ syntax type ]----------------------------------------------
728 SmiUINT32
UdpAddress::get_syntax()
730 return sNMP_SYNTAX_OCTETS
;
733 //-----------------[ construct an Udp address with another Udp address ]---
734 UdpAddress::UdpAddress( const UdpAddress
&udpaddr
):IpAddress(udpaddr
)
736 // always initialize SMI info
737 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
738 smival
.value
.string
.len
= UDPIPV4LEN
;
739 smival
.value
.string
.ptr
= address_buffer
;
741 // Copy the port value
742 set_port(udpaddr
.get_port());
746 // default constructor with a dotted string
747 UdpAddress::UdpAddress( const char *inaddr
):IpAddress()
749 if (ACE_OS::strlen(inaddr
) == 0) {
750 // Inherits IP Address attributes
751 // Always initialize (override) what type this object is
752 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
753 smival
.value
.string
.len
= UDPIPV4LEN
;
754 smival
.value
.string
.ptr
= address_buffer
;
760 // always initialize SMI info
761 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
762 smival
.value
.string
.len
= UDPIPV4LEN
;
763 smival
.value
.string
.ptr
= address_buffer
;
765 valid_flag
= parse_address( (char *)inaddr
);
769 //-----------------[ construct a UdpAddress from a GenAddress ]--------------
770 UdpAddress::UdpAddress( const GenAddress
&genaddr
):IpAddress()
772 // always initialize SMI info
773 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
774 smival
.value
.string
.len
= UDPIPV4LEN
;
775 smival
.value
.string
.ptr
= address_buffer
;
777 unsigned int port
= 0;
780 // allow use of an ip or udp genaddress
781 if (genaddr
.get_type() == type_udp
)
783 valid_flag
= genaddr
.valid();
786 // copy in the IP address data
787 UdpAddress
temp_udp( (const char *) genaddr
);
790 // port info since are making an UpAddress
791 port
= temp_udp
.get_port();
795 if (genaddr
.get_type() == type_ip
)
797 valid_flag
= genaddr
.valid();
800 // copy in the IP address data
801 IpAddress
temp_ip( (const char *) genaddr
);
810 //--------[ construct a udp from an IpAddress ]--------------------------
811 UdpAddress::UdpAddress( const IpAddress
&ipaddr
):IpAddress(ipaddr
)
813 // always initialize SMI info
814 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
815 smival
.value
.string
.len
= UDPIPV4LEN
;
816 smival
.value
.string
.ptr
= address_buffer
;
823 //-----[ destructor ]--------------------------------------------------
824 UdpAddress::~UdpAddress()
829 // copy an instance of this Value
830 SnmpSyntax
& UdpAddress::operator=( SnmpSyntax
&val
)
832 // protect against assignment from itself
836 valid_flag
=0; // will get set 1 if really valid
838 switch (val
.get_syntax()){
839 case sNMP_SYNTAX_IPADDR
:
841 UdpAddress
temp_udp(val
.to_string());
842 *this = temp_udp
; // valid_flag is set by the udp assignment
846 case sNMP_SYNTAX_OCTETS
:
847 if (((UdpAddress
&)val
).smival
.value
.string
.len
== UDPIPV4LEN
){
848 ACE_OS::memcpy(address_buffer
,
849 ((UdpAddress
&)val
).smival
.value
.string
.ptr
, UDPIPV4LEN
);
850 iv_friendly_name_
[0] = 0;
855 // NOTE: as a value add, other types could have "logical"
856 // mappings, i.e. integer32 and unsigned32
863 // assignment to another UdpAddress object overloaded
864 UdpAddress
& UdpAddress::operator=( const UdpAddress
&udpaddr
)
866 // protect against assignment from itself
867 if ( this == &udpaddr
)
870 (IpAddress
&)*this = udpaddr
; // use ancestor assignment for ipaddr value
871 set_port(udpaddr
.get_port()); // copy to port value
877 //-----[ IP Address parse Address ]---------------------------------
878 int UdpAddress::parse_address( const char *inaddr
)
880 char buffer
[MAXHOSTNAMELEN
+1];
882 unsigned short port
= 0;
883 if (inaddr
&& (ACE_OS::strlen( inaddr
)< MAXHOSTNAMELEN
+1))
884 ACE_OS::strcpy( buffer
, inaddr
);
889 // look for port info @ the end of the string
890 // port can be delineated by a ':' or a '/'
891 // if neither are present then just treat it
892 // like a normal IpAddress
894 tmp
= ACE_OS::strstr( buffer
,":");
896 tmp
= ACE_OS::strstr(buffer
,"/");
899 *tmp
=0; // null terminator
901 port
= ACE_OS::atoi( tmp
);
905 return IpAddress::parse_address( buffer
);
909 //----------[ create a new instance of this Value ]------------------------
910 SnmpSyntax
*UdpAddress::clone() const
912 return (SnmpSyntax
*) new UdpAddress(*this);
915 //--------[ set the port number ]---------------------------------------
916 void UdpAddress::set_port( const unsigned short p
)
918 unsigned short port_nbo
= htons(p
);
919 ACE_OS::memcpy(&address_buffer
[IPV4LEN
], &port_nbo
, 2);
923 //---------[ get the port number ]--------------------------------------
924 unsigned short UdpAddress::get_port() const
927 unsigned short port_nbo
;
928 ACE_OS::memcpy(&port_nbo
, &address_buffer
[IPV4LEN
], 2);
929 return ntohs(port_nbo
);
932 return 0; // don't use uninitialized memory
935 //------[ return the type ]--------------------------------------------
936 addr_type
UdpAddress::get_type() const
941 //----[ UDP address char * cast ]--------------------------------------
942 UdpAddress::operator const char *() const
944 return (char *)output_buffer
;
947 //----[ UDP address get char representation ]--------------------------
948 const char * UdpAddress::to_string()
950 return (char *)output_buffer
;
953 // make format same as ACE_INET_Addr class (addr:port)
954 void UdpAddress::format_output()
956 IpAddress::format_output(); // allow ancestors to format their buffers
958 // if valid format else null it
960 ACE_OS::sprintf( (char *) output_buffer
,"%s:%d",
961 IpAddress::to_string(),
964 output_buffer
[0] = 0;
968 //=======================================================================
969 //=========== Netbios Address Implementation ============================
970 //=======================================================================
972 void NetbiosAddress::format_output()
975 ACE_OS::memcpy(output_buffer
, address_buffer
, NETBIOSLEN
);
977 output_buffer
[0] = 0;
980 void NetbiosAddress::InitNBAddr(const char *inaddr
)
982 if (ACE_OS::strlen(inaddr
) == 0) {
983 // always initialize SMI info
984 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
985 smival
.value
.string
.len
= NETBIOSLEN
;
986 smival
.value
.string
.ptr
= address_buffer
;
989 NetbiosAddress::format_output();
993 // always initialize SMI info
994 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
995 smival
.value
.string
.len
= IPXLEN
;
996 smival
.value
.string
.ptr
= address_buffer
;
998 valid_flag
= parse_address( (char *) inaddr
);
999 NetbiosAddress::format_output();
1002 // TODO: how to handle addresses < 15 chars (zero out or pad with ' ')
1003 NetbiosAddress::NetbiosAddress( const char *inaddr
)
1008 NetbiosAddress::NetbiosAddress( const char *inaddr
, nb_service svc
)
1011 address_buffer
[15] = svc
;
1014 // TODO: go back over ms/ibm specs and verify this
1015 // 16 chars, 15 can be any character, 16th is service number between 0 and 20
1016 // names beginning with IBM are reserved, and hence invalid
1017 // and doubt IBM would use this class anyway
1018 int NetbiosAddress::parse_address(const char *address
)
1020 if (ACE_OS::strlen(address
) > NETBIOSLEN
)
1021 return 0; // invalid
1023 if (ACE_OS::strncmp(address
, "IBM", 3) == 0)
1024 return 0; // invalid
1026 // addresses are free form but this check may need to be expose to user
1028 //if (address[15] < nb_workstation || address[15] > nb_server)
1029 // return 0; //invalid service type
1031 ACE_OS::memset(address_buffer
, 0, NETBIOSLEN
);
1032 ACE_OS::memcpy(address_buffer
, address
, NETBIOSLEN
);
1037 NetbiosAddress::NetbiosAddress( const NetbiosAddress
& nbaddr
)
1040 // always initialize SMI info
1041 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
1042 smival
.value
.string
.len
= NETBIOSLEN
;
1043 smival
.value
.string
.ptr
= address_buffer
;
1045 valid_flag
= nbaddr
.valid_flag
;
1047 ACE_OS::memcpy(address_buffer
, nbaddr
.address_buffer
, NETBIOSLEN
);
1048 NetbiosAddress::format_output();
1051 NetbiosAddress::NetbiosAddress( const GenAddress
& genaddr
)
1053 // always initialize SMI info
1054 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
1055 smival
.value
.string
.len
= NETBIOSLEN
;
1056 smival
.value
.string
.ptr
= address_buffer
;
1059 // allow use of an ipx or ipxsock address
1060 if ( (genaddr
.get_type() == type_nb
) ) {
1061 valid_flag
= genaddr
.valid();
1063 // copy in the Ipx address data
1064 NetbiosAddress
temp_nb( (const char *) genaddr
);
1068 NetbiosAddress::format_output();
1071 NetbiosAddress::~NetbiosAddress()
1075 const char *NetbiosAddress::to_string()
1077 return (char *)output_buffer
;
1080 void NetbiosAddress::to_octet(OctetStr
& octet
) const
1082 octet
.set_data( smival
.value
.string
.ptr
, smival
.value
.string
.len
);
1085 NetbiosAddress
& NetbiosAddress::operator=( const NetbiosAddress
&val
)
1087 // protect against assignment from itself
1091 valid_flag
= 0; // will set to 1 if really valid
1093 switch (((NetbiosAddress
*) &val
)->get_syntax()) {
1094 case sNMP_SYNTAX_OCTETS
:
1095 ACE_OS::memcpy(address_buffer
,
1096 ((NetbiosAddress
&)val
).smival
.value
.string
.ptr
, NETBIOSLEN
);
1101 NetbiosAddress::format_output();
1105 nb_service
NetbiosAddress::get_service_type() const
1107 return (nb_service
) address_buffer
[15];
1110 void NetbiosAddress::set_service_type(nb_service nbservice
)
1112 address_buffer
[15] = nbservice
;
1113 NetbiosAddress::format_output();
1116 NetbiosAddress::operator const char *() const
1118 return (char *)output_buffer
;
1121 SnmpSyntax
& NetbiosAddress::operator=( SnmpSyntax
&val
)
1123 // protect against assignment from itself
1127 valid_flag
= 0; // will set to 1 if really valid
1129 switch (val
.get_syntax()) {
1130 case sNMP_SYNTAX_OCTETS
:
1131 if (((NetbiosAddress
&)val
).smival
.value
.string
.len
== NETBIOSLEN
) {
1132 ACE_OS::memcpy(address_buffer
,
1133 ((NetbiosAddress
&)val
).smival
.value
.string
.ptr
, NETBIOSLEN
);
1139 NetbiosAddress::format_output();
1143 SnmpSyntax
*NetbiosAddress::clone() const
1145 return (SnmpSyntax
*) new NetbiosAddress(*this);
1148 SmiUINT32
NetbiosAddress::get_syntax()
1150 return sNMP_SYNTAX_OCTETS
;
1153 addr_type
NetbiosAddress::get_type() const
1158 //=======================================================================
1159 //=========== IPX Address Implementation ================================
1160 //=======================================================================
1162 //-----------[ syntax type ]----------------------------------------------
1163 SmiUINT32
IpxAddress::get_syntax()
1165 return sNMP_SYNTAX_OCTETS
;
1169 //----------[ default constructor with a string arg ]---------------------------
1170 IpxAddress::IpxAddress( const char *inaddr
):Address( )
1172 if (ACE_OS::strlen(inaddr
) == 0) {
1173 // always initialize SMI info
1174 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
1175 smival
.value
.string
.len
= IPXLEN
;
1176 smival
.value
.string
.ptr
= address_buffer
;
1180 IpxAddress::format_output();
1183 // always initialize SMI info
1184 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
1185 smival
.value
.string
.len
= IPXLEN
;
1186 smival
.value
.string
.ptr
= address_buffer
;
1189 valid_flag
= parse_address( (char *) inaddr
);
1190 IpxAddress::format_output();
1194 //-----[ IPX Address copy constructor ]----------------------------------
1195 IpxAddress::IpxAddress(const IpxAddress
&ipxaddr
)
1198 // always initialize SMI info
1199 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
1200 smival
.value
.string
.len
= IPXLEN
;
1201 smival
.value
.string
.ptr
= address_buffer
;
1204 valid_flag
= ipxaddr
.valid_flag
;
1206 ACE_OS::memcpy(address_buffer
, ipxaddr
.address_buffer
, IPXLEN
);
1207 IpxAddress::format_output();
1211 //----[ construct an IpxAddress from a GenAddress ]---------------------------
1212 IpxAddress::IpxAddress( const GenAddress
&genaddr
)
1214 // always initialize SMI info
1215 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
1216 smival
.value
.string
.len
= IPXLEN
;
1217 smival
.value
.string
.ptr
= address_buffer
;
1220 // allow use of an ipx or ipxsock address
1221 if ( (genaddr
.get_type() == type_ipx
) ) {
1222 valid_flag
= genaddr
.valid();
1224 // copy in the Ipx address data
1225 IpxAddress
temp_ipx( (const char *) genaddr
);
1230 if ( (genaddr
.get_type() == type_ipxsock
) ) {
1231 valid_flag
= genaddr
.valid();
1233 // copy in the Ipx address data
1234 IpxSockAddress
temp_ipxsock( (const char *) genaddr
);
1235 *this = temp_ipxsock
;
1238 IpxAddress::format_output();
1242 //-----[ destructor ]--------------------------------------------------
1243 IpxAddress::~IpxAddress()
1248 //-----[ IPX Address general = operator ]-------------------------------
1249 SnmpSyntax
& IpxAddress::operator=( SnmpSyntax
&val
)
1251 // protect against assignment from itself
1255 valid_flag
=0; // will set to 1 if really valid
1257 switch (val
.get_syntax()){
1258 case sNMP_SYNTAX_OCTETS
:
1259 if (((IpxAddress
&)val
).smival
.value
.string
.len
== IPXLEN
){
1260 ACE_OS::memcpy(address_buffer
, ((IpxAddress
&)val
).smival
.value
.string
.ptr
, IPXLEN
);
1266 IpxAddress::format_output();
1270 //--------[ assignment to another IpAddress object overloaded ]----------
1271 IpxAddress
& IpxAddress::operator=( const IpxAddress
&ipxaddress
)
1273 // protect against assignment from itself
1274 if ( this == &ipxaddress
)
1277 valid_flag
= ipxaddress
.valid_flag
;
1279 ACE_OS::memcpy(address_buffer
, ipxaddress
.address_buffer
, IPXLEN
);
1280 IpxAddress::format_output();
1285 // create a new instance of this Value
1286 SnmpSyntax
*IpxAddress::clone() const
1288 return (SnmpSyntax
*) new IpxAddress(*this);
1291 //-----[ IPX Address parse Address ]-----------------------------------
1292 // Convert a string to a ten byte ipx address
1293 // On success sets validity 1 or 0
1295 // IPX address format
1297 // NETWORK ID| MAC ADDRESS
1298 // 01 02 03 04|05 06 07 08 09 10
1299 // XX XX XX XX|XX XX XX XX XX XX
1301 // Valid input format
1303 // XXXXXXXX.XXXXXXXXXXXX
1304 // Total length must be 21
1305 // Must have a separator in it
1306 // First string length must be 8
1307 // Second string length must be 12
1308 // Each char must take on value 0-F
1310 // Input formats recognized
1312 // XXXXXXXX.XXXXXXXXXXXX
1313 // XXXXXXXX:XXXXXXXXXXXX
1314 // XXXXXXXX-XXXXXXXXXXXX
1315 // XXXXXXXX.XXXXXX-XXXXXX
1316 // XXXXXXXX:XXXXXX-XXXXXX
1317 // XXXXXXXX-XXXXXX-XXXXXX
1318 int IpxAddress::parse_address( const char *inaddr
)
1320 char unsigned *str1
,*str2
;
1321 char temp
[30]; // don't destroy original
1326 // save the orginal source
1327 if (!inaddr
|| (ACE_OS::strlen( inaddr
) >(sizeof(temp
)-1))) return 0;
1328 ACE_OS::strcpy( temp
, inaddr
);
1329 trim_white_space( temp
);
1330 tmplen
= ACE_OS::strlen(temp
);
1332 // bad total length check
1333 // 123456789012345678901
1334 // XXXXXXXX-XXXXXXXXXXXX 21 len
1336 // XXXXXXXX-XXXXXX-XXXXXX 22 len
1337 // need at least 21 chars and no more than 22
1338 if ( (tmplen
<21) || (tmplen
>22))
1341 // convert the string to all lower case
1342 // this allows hex values to be in upper or lower
1343 for (z
=0;z
< tmplen
;z
++)
1344 temp
[z
] = ACE_OS::ace_tolower(temp
[z
]);
1346 // check for separated nodeid
1347 // if found remove it
1348 if (temp
[15] == '-')
1350 for(z
=16;z
<tmplen
;z
++)
1351 temp
[z
-1] = temp
[z
];
1355 // no dot or colon separator check
1356 separator
= temp
[8];
1357 if (( separator
!= ':') &&
1358 ( separator
!= '.') &&
1359 ( separator
!= '-') &&
1360 ( separator
!= ' '))
1363 // separate the strings
1364 str1
= ( unsigned char *) temp
;
1365 while( *str1
!= separator
) str1
++;
1368 str1
= ( unsigned char *) temp
;
1370 // check len of the network portion
1371 if ( ACE_OS::strlen((char *) str1
) != 8)
1374 // check len of mac portion
1375 if ( ACE_OS::strlen( (char *) str2
) != 12)
1378 // ok we like then lens, make sure that all chars are 0-f
1379 // check out the net id
1382 if (((*tmp
>= '0') && (*tmp
<= '9'))|| // good 0-9
1383 ((*tmp
>= 'a') && (*tmp
<= 'f'))) // or a-f
1388 // check out the MAC address
1391 if (((*tmp
>= '0') && (*tmp
<= '9'))|| // good 0-9
1392 ((*tmp
>= 'a') && (*tmp
<= 'f'))) // or a-f
1397 // convert to target string
1401 if (( *tmp
>= '0') && ( *tmp
<= '9'))
1402 *tmp
= *tmp
- (char unsigned )'0';
1404 *tmp
= *tmp
- (char unsigned) 'a' + (char unsigned) 10;
1408 // network id portion
1409 address_buffer
[0] = (str1
[0]*16) + str1
[1];
1410 address_buffer
[1] = (str1
[2]*16) + str1
[3];
1411 address_buffer
[2] = (str1
[4]*16) + str1
[5];
1412 address_buffer
[3] = (str1
[6]*16) + str1
[7];
1417 if (( *tmp
>= '0') && ( *tmp
<= '9'))
1418 *tmp
= *tmp
- (char unsigned) '0';
1420 *tmp
= *tmp
- (char unsigned) 'a'+ (char unsigned) 10;
1424 address_buffer
[4] = (str2
[0]*16) + str2
[1];
1425 address_buffer
[5] = (str2
[2]*16) + str2
[3];
1426 address_buffer
[6] = (str2
[4]*16) + str2
[5];
1427 address_buffer
[7] = (str2
[6]*16) + str2
[7];
1428 address_buffer
[8] = (str2
[8]*16) + str2
[9];
1429 address_buffer
[9] = (str2
[10]*16) + str2
[11];
1434 //----[ IPX address char * cast ]--------------------------------------
1435 IpxAddress::operator const char *() const
1437 return (char *)output_buffer
;
1440 //----[ IPX address get char representation ]--------------------------
1441 const char * IpxAddress::to_string()
1443 return (char *)output_buffer
;
1447 //----[ IPX address format output ]-------------------------------------
1448 void IpxAddress::format_output()
1451 ACE_OS::sprintf((char *) output_buffer
,
1452 "%02x%02x%02x%02x%c%02x%02x%02x%02x%02x%02x",
1453 address_buffer
[0],address_buffer
[1],
1454 address_buffer
[2],address_buffer
[3],'-',
1455 address_buffer
[4],address_buffer
[5],
1456 address_buffer
[6],address_buffer
[7],
1457 address_buffer
[8],address_buffer
[9]);
1459 output_buffer
[0] = 0;
1463 // get the host id portion of an ipx address
1464 int IpxAddress::get_hostid( MacAddress
& mac
)
1469 ACE_OS::sprintf( buffer
,"%02x:%02x:%02x:%02x:%02x:%02x",
1471 address_buffer
[5], address_buffer
[6], address_buffer
[7],
1472 address_buffer
[8], address_buffer
[9]);
1473 MacAddress
temp( buffer
);
1474 // mac = (SnmpSyntax&) temp;
1486 //------[ return the type ]----------------------------------
1487 addr_type
IpxAddress::get_type() const
1492 void IpxAddress::to_octet(OctetStr
& octet
) const
1494 octet
.set_data( smival
.value
.string
.ptr
, smival
.value
.string
.len
);
1498 //========================================================================
1499 //======== IpxSockAddress Implementation =================================
1500 //========================================================================
1502 //-----------[ syntax type ]----------------------------------------------
1503 SmiUINT32
IpxSockAddress::get_syntax()
1505 return sNMP_SYNTAX_OCTETS
;
1508 //-----------[ construct an IpxSockAddress with another IpxSockAddress]----
1509 IpxSockAddress::IpxSockAddress( const IpxSockAddress
&ipxaddr
):IpxAddress(ipxaddr
)
1511 // always initialize SMI info
1512 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
1513 smival
.value
.string
.len
= IPXSOCKLEN
;
1514 smival
.value
.string
.ptr
= address_buffer
;
1516 // copy the socket value
1517 set_socket(ipxaddr
.get_socket());
1522 //---------------[ default construct a IpxSockAddress ]--------------
1523 IpxSockAddress::IpxSockAddress( const char *inaddr
):IpxAddress()
1525 if (ACE_OS::strlen(inaddr
) == 0) {
1526 // always initialize SMI info
1527 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
1528 smival
.value
.string
.len
= IPXSOCKLEN
;
1529 smival
.value
.string
.ptr
= address_buffer
;
1536 // always initialize SMI info
1537 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
1538 smival
.value
.string
.len
= IPXSOCKLEN
;
1539 smival
.value
.string
.ptr
= address_buffer
;
1541 valid_flag
= parse_address( (char *) inaddr
);
1546 //---------------[ construct a IpxSockAddress from a GenAddress ]----------
1547 IpxSockAddress::IpxSockAddress( const GenAddress
&genaddr
):IpxAddress()
1549 // always initialize SMI info
1550 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
1551 smival
.value
.string
.len
= IPXSOCKLEN
;
1552 smival
.value
.string
.ptr
= address_buffer
;
1555 unsigned short socketid
= 0;
1556 // allow use of an ipx or ipxsock address
1557 if ( (genaddr
.get_type() == type_ipx
) )
1559 valid_flag
= genaddr
.valid();
1562 // copy in the Ipx address data
1563 IpxAddress
temp_ipx( (const char *) genaddr
);
1568 if ( (genaddr
.get_type() == type_ipxsock
) )
1570 valid_flag
= genaddr
.valid();
1573 // copy in the Ipx address data
1574 IpxSockAddress
temp_ipxsock( (const char *) genaddr
);
1575 *this = temp_ipxsock
;
1576 // socketid info since are making an IpxSockAddress
1577 socketid
= temp_ipxsock
.get_socket();
1580 set_socket(socketid
);
1585 //------------[ construct an IpxSockAddress from a IpxAddress ]--------------
1586 IpxSockAddress::IpxSockAddress( const IpxAddress
&ipxaddr
):IpxAddress(ipxaddr
)
1588 // always initialize SMI info
1589 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
1590 smival
.value
.string
.len
= IPXSOCKLEN
;
1591 smival
.value
.string
.ptr
= address_buffer
;
1597 //-----[ destructor ]--------------------------------------------------
1598 IpxSockAddress::~IpxSockAddress()
1602 // copy an instance of this Value
1603 SnmpSyntax
& IpxSockAddress::operator=( SnmpSyntax
&val
)
1605 // protect against assignment from itself
1609 valid_flag
=0; // will set to 1 if really valid
1611 switch (val
.get_syntax()){
1612 case sNMP_SYNTAX_OCTETS
:
1614 // See if it is of the Ipx address family
1615 // This handles IpxSockAddress == IpxAddress
1616 IpxSockAddress
temp_ipx(val
.to_string());
1617 if (temp_ipx
.valid()){
1618 *this = temp_ipx
; // ipxsock = ipxsock
1620 // See if it is an OctetStr of appropriate length
1621 else if (((IpxSockAddress
&)val
).smival
.value
.string
.len
== IPXSOCKLEN
){
1622 ACE_OS::memcpy(address_buffer
,
1623 ((IpxSockAddress
&)val
).smival
.value
.string
.ptr
,
1635 // assignment to another IpAddress object overloaded
1636 IpxSockAddress
& IpxSockAddress::operator=( const IpxSockAddress
&ipxaddr
)
1638 // protect against assignment from itself
1639 if ( this == &ipxaddr
)
1642 (IpxAddress
&)*this = ipxaddr
; // use ancestor assignment for ipx addr
1643 set_socket(ipxaddr
.get_socket()); // copy socket value
1649 //----------[ create a new instance of this Value ]------------------------
1650 SnmpSyntax
*IpxSockAddress::clone() const
1652 return (SnmpSyntax
*) new IpxSockAddress(*this);
1655 //----[ IPXSock address char * cast ]--------------------------------------
1656 IpxSockAddress::operator const char *() const
1658 return (char *)output_buffer
;
1661 //----[ IPXSock address get char representation ]--------------------------
1662 const char * IpxSockAddress::to_string()
1664 return (char *)output_buffer
;
1667 //----[ IPX address format output ]-------------------------------------
1668 void IpxSockAddress::format_output()
1670 IpxAddress::format_output(); // allow ancestors to format their buffers
1673 ACE_OS::sprintf((char *) output_buffer
,"%s/%d",
1674 IpxAddress::to_string(), get_socket());
1676 output_buffer
[0] = 0;
1679 //-----[ IP Address parse Address ]---------------------------------
1680 int IpxSockAddress::parse_address( const char *inaddr
)
1682 char buffer
[MAXHOSTNAMELEN
+1];
1683 unsigned short socketid
=0;
1685 if (inaddr
&& (ACE_OS::strlen( inaddr
)< MAXHOSTNAMELEN
))
1686 ACE_OS::strcpy( buffer
, inaddr
);
1692 // look for port info @ the end of the string
1693 // port can be delineated by a ':' or a '/'
1694 // if neither are present then just treat it
1695 // like a normal IpAddress
1697 tmp
= ACE_OS::strstr( buffer
,"/");
1701 *tmp
=0; // null terminator
1703 socketid
= ACE_OS::atoi( tmp
);
1705 set_socket(socketid
);
1706 return IpxAddress::parse_address( buffer
);
1710 //-------------[ set the socket number ]----------------------------------
1711 void IpxSockAddress::set_socket( const unsigned short s
)
1713 unsigned short sock_nbo
= htons(s
);
1714 ACE_OS::memcpy(&address_buffer
[IPXLEN
], &sock_nbo
, 2);
1717 //--------------[ get the socket number ]---------------------------------
1718 unsigned short IpxSockAddress::get_socket() const
1722 unsigned short sock_nbo
;
1723 ACE_OS::memcpy(&sock_nbo
, &address_buffer
[IPXLEN
], 2);
1724 return ntohs(sock_nbo
);
1727 return 0; // don't use uninitialized memory
1730 //------[ return the type ]----------------------------------------------
1731 addr_type
IpxSockAddress::get_type() const
1733 return type_ipxsock
;
1737 //========================================================================
1738 //======== MACAddress Implementation =====================================
1739 //========================================================================
1741 //-----------[ syntax type ]----------------------------------------------
1742 SmiUINT32
MacAddress::get_syntax()
1744 return sNMP_SYNTAX_OCTETS
;
1747 //-----[ MAC Address copy constructor ]---------------------------------
1748 MacAddress::MacAddress(const MacAddress
&macaddr
)
1751 // always initialize SMI info
1752 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
1753 smival
.value
.string
.len
= MACLEN
;
1754 smival
.value
.string
.ptr
= address_buffer
;
1756 valid_flag
= macaddr
.valid_flag
;
1758 ACE_OS::memcpy(address_buffer
, macaddr
.address_buffer
, MACLEN
);
1762 //---------[ constructor with a string argument ]-------------------------
1763 MacAddress::MacAddress( const char *inaddr
):Address( )
1765 if (ACE_OS::strlen(inaddr
) == 0) {
1766 // always initialize SMI info
1767 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
1768 smival
.value
.string
.len
= MACLEN
;
1769 smival
.value
.string
.ptr
= address_buffer
;
1776 // always initialize SMI info
1777 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
1778 smival
.value
.string
.len
= MACLEN
;
1779 smival
.value
.string
.ptr
= address_buffer
;
1781 valid_flag
= parse_address( (char *) inaddr
);
1785 //-----[ construct a MacAddress from a GenAddress ]------------------------
1786 MacAddress::MacAddress( const GenAddress
&genaddr
)
1788 // always initialize SMI info
1789 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
1790 smival
.value
.string
.len
= MACLEN
;
1791 smival
.value
.string
.ptr
= address_buffer
;
1794 // allow use of mac address
1795 if (genaddr
.get_type() == type_mac
)
1797 valid_flag
= genaddr
.valid();
1800 // copy in the Mac address data
1801 MacAddress
temp_mac( (const char *) genaddr
);
1808 //-----[ destructor ]--------------------------------------------------
1809 MacAddress::~MacAddress()
1813 //---------[ MacAddress clone ]-------------------------------------------
1814 SnmpSyntax
*MacAddress::clone() const
1816 return (SnmpSyntax
*) new MacAddress(*this);
1819 //------[ assignment to another ipaddress object overloaded ]--------------
1820 MacAddress
& MacAddress::operator=( const MacAddress
&macaddress
)
1822 // protect against assignment from itself
1823 if ( this == &macaddress
)
1826 valid_flag
= macaddress
.valid_flag
;
1828 ACE_OS::memcpy(address_buffer
, macaddress
.address_buffer
, MACLEN
);
1834 //-----[ MAC Address general = operator ]---------------------------------
1835 SnmpSyntax
& MacAddress::operator=( SnmpSyntax
&val
)
1837 // protect against assignment from itself
1841 valid_flag
=0; // will set to 1 if really valid
1843 switch (val
.get_syntax()){
1844 case sNMP_SYNTAX_OCTETS
:
1845 if (((MacAddress
&)val
).smival
.value
.string
.len
== MACLEN
){
1846 ACE_OS::memcpy(address_buffer
,
1847 ((MacAddress
&)val
).smival
.value
.string
.ptr
, MACLEN
);
1857 //-----[ MAC Address parse Address ]--------------------------------------
1858 // Convert a string to a six byte MAC address
1859 // On success sets validity 1 or 0
1861 // MAC address format
1864 // 01 02 03 04 05 06
1865 // XX:XX:XX:XX:XX:XX
1866 // Valid input format
1869 // Total length must be 17
1870 // Each char must take on value 0-F
1872 int MacAddress::parse_address( const char *inaddr
)
1874 char temp
[MAXHOSTNAMELEN
+1]; // don't destroy original
1879 // save the orginal source
1880 if ( !inaddr
|| (ACE_OS::strlen( inaddr
) > 30)) return 0;
1881 ACE_OS::strcpy( temp
, inaddr
);
1882 trim_white_space( temp
);
1884 // bad total length check
1885 if ( ACE_OS::strlen(temp
) != 17)
1889 if ((temp
[2] != ':')||(temp
[5] != ':')||(temp
[8]!=':')||(temp
[11]!=':')
1893 // strip off the colons
1894 tmp
= ( unsigned char *) temp
;
1908 for(z
=0;z
<ACE_OS::strlen(temp
);z
++)
1909 temp
[z
] = ACE_OS::ace_tolower( temp
[z
]);
1912 // check out the MAC address
1913 tmp
= ( unsigned char *) temp
;
1915 if (((*tmp
>= '0') && (*tmp
<= '9'))|| // good 0-9
1916 ((*tmp
>= 'a') && (*tmp
<= 'f'))) // or a-f
1921 // convert to target string
1922 tmp
= (unsigned char *) temp
;
1925 if (( *tmp
>= '0') && ( *tmp
<= '9'))
1926 *tmp
= *tmp
- (char unsigned )'0';
1928 *tmp
= *tmp
- (char unsigned) 'a' + (char unsigned) 10;
1932 address_buffer
[0] = (temp
[0]*16) + temp
[1];
1933 address_buffer
[1] = (temp
[2]*16) + temp
[3];
1934 address_buffer
[2] = (temp
[4]*16) + temp
[5];
1935 address_buffer
[3] = (temp
[6]*16) + temp
[7];
1936 address_buffer
[4] = (temp
[8]*16) + temp
[9];
1937 address_buffer
[5] = (temp
[10]*16) + temp
[11];
1942 //----[ MAC address char * cast ]--------------------------------------
1943 MacAddress::operator const char *() const
1945 return (char *)output_buffer
;
1947 //----[ MAC address get char representation ]--------------------------
1948 const char * MacAddress::to_string()
1950 return (char *)output_buffer
;
1953 //----[ MAC address format output ]---------------------------------
1954 void MacAddress::format_output()
1957 ACE_OS::sprintf(output_buffer
,"%02x:%02x:%02x:%02x:%02x:%02x",address_buffer
[0],
1958 address_buffer
[1],address_buffer
[2],address_buffer
[3],
1959 address_buffer
[4],address_buffer
[5]);
1961 output_buffer
[0] = 0;
1964 //------[ return the type ]----------------------------------
1965 addr_type
MacAddress::get_type() const
1971 unsigned int MacAddress::hashFunction() const
1973 return ((((address_buffer
[0] << 8) + address_buffer
[1]) * HASH0LEN
)
1974 + (((address_buffer
[2] << 8) + address_buffer
[3]) * HASH1LEN
)
1975 + (((address_buffer
[4] << 8) + address_buffer
[5]) * HASH2LEN
));
1978 void MacAddress::to_octet(OctetStr
& octet
) const
1980 octet
.set_data( smival
.value
.string
.ptr
, smival
.value
.string
.len
);
1983 //========================================================================
1984 //========== Generic Address Implementation ==============================
1985 //========================================================================
1987 //-----------[ get the syntax]----------------------------------------------
1988 SmiUINT32
GenAddress::get_syntax()
1991 return address
->get_syntax();
1993 return sNMP_SYNTAX_NULL
;
1996 void GenAddress::init_smi()
1998 smival
.syntax
= sNMP_SYNTAX_NULL
; // to be overridden
1999 smival
.value
.string
.len
= 0; // to be overridden
2000 smival
.value
.string
.ptr
= address_buffer
; // constant
2003 //-----------[ constructor with a string argument ]----------------------
2004 GenAddress::GenAddress( const char *addr
): address(0)
2007 // initialize SMI info
2008 // BOK: smival is generally not used for GenAddress, but
2009 // we need this to be a replica of the real address'
2010 // smival info so that <class>::operator=SnmpSyntax
2014 if (addr
&& ACE_OS::strlen(addr
) == 0) {
2019 parse_address(addr
);
2021 // Copy real address smival info into GenAddr smival
2022 // BOK: smival is generally not used for GenAddress, but
2023 // we need this to be a replica of the real address'
2024 // smival info so that <class>::operator=SnmpSyntax
2027 smival
.syntax
= ((GenAddress
*)address
)->smival
.syntax
;
2028 smival
.value
.string
.len
=
2029 ((GenAddress
*)address
)->smival
.value
.string
.len
;
2030 ACE_OS::memcpy(smival
.value
.string
.ptr
,
2031 ((GenAddress
*)address
)->smival
.value
.string
.ptr
,
2032 (size_t)smival
.value
.string
.len
);
2036 //-----------[ constructor with an Address argument ]--------------------
2037 GenAddress::GenAddress( const Address
&addr
): address(0)
2041 // initialize SMI info
2042 // BOK: this is generally not used for GenAddress,
2043 // but we need this to be a replica of the real address'
2044 // smival info so that operator=SnmpSyntax will work.
2046 // make sure that the object is valid
2047 if (!addr
.valid()) {
2052 address
= (Address
*)addr
.clone();
2054 valid_flag
= address
->valid();
2056 // Copy real address smival info into GenAddr smival
2057 // BOK: smival is generally not used for GenAddress, but
2058 // we need this to be a replica of the real address'
2059 // smival info so that <class>::operator=SnmpSyntax
2062 smival
.syntax
= address
->get_syntax();
2063 smival
.value
.string
.len
=
2064 ((GenAddress
*)address
)->smival
.value
.string
.len
;
2065 ACE_OS::memcpy(smival
.value
.string
.ptr
,
2066 ((GenAddress
*)address
)->smival
.value
.string
.ptr
,
2067 (size_t)smival
.value
.string
.len
);
2073 //-----------------[ constructor with another GenAddress object ]-------------
2074 GenAddress::GenAddress( const GenAddress
&addr
)
2080 // initialize SMI info
2081 // BOK: this is generally not used for GenAddress,
2082 // but we need this to be a replica of the real address'
2083 // smival info so that operator=SnmpSyntax will work.
2086 // make sure that the object is valid
2087 if (!addr
.valid_flag
) {
2092 address
= (Address
*)addr
.address
->clone();
2094 valid_flag
= address
->valid();
2096 // Copy real address smival info into GenAddr smival
2097 // BOK: smival is generally not used for GenAddress, but
2098 // we need this to be a replica of the real address'
2099 // smival info so that <class>::operator=SnmpSyntax
2102 smival
.syntax
= ((GenAddress
*)address
)->smival
.syntax
;
2103 smival
.value
.string
.len
=
2104 ((GenAddress
*)address
)->smival
.value
.string
.len
;
2105 ACE_OS::memcpy(smival
.value
.string
.ptr
,
2106 ((GenAddress
*)address
)->smival
.value
.string
.ptr
,
2107 (size_t)smival
.value
.string
.len
);
2113 //----------[ destructor ] ------------------------------------------------
2114 GenAddress::~GenAddress()
2120 //----------[ create a new instance of this Value ]------------------------
2121 SnmpSyntax
*GenAddress::clone() const
2123 return (SnmpSyntax
*) new GenAddress(*this);
2126 //------[ assignment GenAddress = GenAddress ]-----------------------------
2127 GenAddress
& GenAddress::operator=( const GenAddress
&addr
)
2129 // protect against assignment from itself
2130 if ( this == &addr
)
2140 address
= (Address
*)(addr
.address
)->clone();
2143 valid_flag
= address
->valid();
2145 // Copy real address smival info into GenAddr smival
2146 // BOK: smival is generally not used for GenAddress, but
2147 // we need this to be a replica of the real address'
2148 // smival info so that <class>::operator=SnmpSyntax
2151 smival
.syntax
= ((GenAddress
*)address
)->smival
.syntax
;
2152 smival
.value
.string
.len
=
2153 ((GenAddress
*)address
)->smival
.value
.string
.len
;
2154 ACE_OS::memcpy(smival
.value
.string
.ptr
,
2155 ((GenAddress
*)address
)->smival
.value
.string
.ptr
,
2156 (size_t)smival
.value
.string
.len
);
2164 //------[ assignment GenAddress = any SnmpSyntax ]-----------------------
2165 SnmpSyntax
& GenAddress::operator=( SnmpSyntax
&val
)
2167 // protect against assignment from itself
2171 valid_flag
= 0; // will get set to 1 if really valid
2172 if ( address
!= 0) {
2178 switch ( val
.get_syntax() ) {
2179 //-----[ ip address case ]-------------
2180 // BOK: this case shouldn't be needed since there is an explicit
2181 // GenAddr=Address assignment that will override this assignment.
2182 // Left here for posterity.
2183 case sNMP_SYNTAX_IPADDR
:
2185 address
= (Address
*)val
.clone();
2187 valid_flag
= address
->valid();
2191 //-----[ udp address case ]------------
2192 //-----[ ipx address case ]------------
2193 //-----[ mac address case ]------------
2194 // BOK: This is here only to support GenAddr = primitive OctetStr.
2195 // The explicit GenAddr=Address assignment will handle the cases
2196 // GenAddr = [UdpAdd|IpxAddr|IpxSock|MacAddr|DecNetAddr|NetbiosAddr|AppleTlk].
2197 // Note, using the heuristic of octet str len to determine type of
2198 // address to create is not accurate when address lengths are equal
2199 // (e.g., UDPIPV4LEN == MACLEN). It gets worse if we add AppleTalk or
2200 // OSI which use variable length addresses! assume AppleTalk as used in IOS Mibs
2201 // is defined in CISCO-TC.my as fixed length of 3 octets
2203 case sNMP_SYNTAX_OCTETS
:
2205 unsigned long val_len
;
2206 val_len
= ((GenAddress
&)val
).smival
.value
.string
.len
;
2208 if (val_len
== UDPIPV4LEN
) {
2209 ACE_NEW_RETURN(address
, UdpAddress
, *this);
2211 else if (val_len
==IPV4LEN
) {
2212 ACE_NEW_RETURN(address
, IpAddress
, *this);
2214 else if (val_len
== IPXLEN
) {
2215 ACE_NEW_RETURN(address
, IpxAddress
, *this);
2217 else if (val_len
== IPXSOCKLEN
) {
2218 ACE_NEW_RETURN(address
, IpxSockAddress
, *this);
2220 else if (val_len
== MACLEN
) {
2221 ACE_NEW_RETURN(address
, MacAddress
, *this);
2223 else if (val_len
== APPLETKLEN
) {
2224 ACE_NEW_RETURN(address
, AppleTalkAddress
, *this);
2226 else if (val_len
== DECNETLEN
) {
2227 ACE_NEW_RETURN(address
, DecNetAddress
, *this);
2229 else if (val_len
== NETBIOSLEN
) {
2230 ACE_NEW_RETURN(address
, DecNetAddress
, *this);
2235 valid_flag
= address
->valid();
2242 // Copy real address smival info into GenAddr smival
2243 // BOK: smival is generally not used for GenAddress, but
2244 // we need this to be a replica of the real address'
2245 // smival info so that <class>::operator=SnmpSyntax
2248 smival
.syntax
= ((GenAddress
*)address
)->smival
.syntax
;
2249 smival
.value
.string
.len
=
2250 ((GenAddress
*)address
)->smival
.value
.string
.len
;
2251 ACE_OS::memcpy(smival
.value
.string
.ptr
,
2252 ((GenAddress
*)address
)->smival
.value
.string
.ptr
,
2253 (size_t)smival
.value
.string
.len
);
2261 // redefined parse address for macs
2262 // TODO: Add netbios, appletalk, and decnet addresses here
2263 int GenAddress::parse_address( const char *addr
)
2268 // try to create each of the addresses until the correct one
2271 //BOK: Need to try IPX Sock and IPX before UDP since on Win32,
2272 // gethostbyname() seems to think the ipx network number
2273 // portion is a valid ipaddress string... stupid WinSOCK!
2276 ACE_NEW_RETURN(address
, IpxSockAddress( addr
), -1);
2277 valid_flag
= address
->valid();
2278 if ( valid_flag
&& ((IpxSockAddress
*)address
)->get_socket()) {
2280 return 1; // ok its an ipxsock address
2282 // otherwise delete it and try another
2286 ACE_NEW_RETURN(address
, IpxAddress( addr
), -1);
2287 valid_flag
= address
->valid();
2290 return 1; // ok its an ipx address
2292 // otherwise delete it and try another
2295 //TM: Must try the derived classes first...one pitfall of the
2296 //following solution is if someone creates with a port/socket of 0 the
2297 //class will get demoted to ip/ipx. The only proper way to do this is
2298 //to parse the strings ourselves.
2301 ACE_NEW_RETURN(address
, UdpAddress( addr
), -1);
2302 valid_flag
= address
->valid();
2303 if ( valid_flag
&& ((UdpAddress
*)address
)->get_port()) {
2305 return 1; // ok its a udp address
2308 // otherwise delete it and try another
2312 ACE_NEW_RETURN(address
, IpAddress( addr
), -1);
2313 valid_flag
= address
->valid();
2317 return 1; // ok its an ip address
2319 // otherwise delete it and try another
2323 ACE_NEW_RETURN(address
, MacAddress( addr
), -1);
2324 valid_flag
= address
->valid();
2327 return 1; // ok, its a mac
2330 // guess by length of argument the type of address
2331 switch (ACE_OS::strlen(addr
)) {
2333 ACE_NEW_RETURN(address
, NetbiosAddress( addr
), -1);
2334 valid_flag
= address
->valid();
2337 return 1; // ok, its a mac
2342 ACE_NEW_RETURN(address
, AppleTalkAddress( addr
), -1);
2343 valid_flag
= address
->valid();
2346 return 1; // ok, its a mac
2351 ACE_NEW_RETURN(address
, DecNetAddress( addr
), -1);
2352 valid_flag
= address
->valid();
2355 return 1; // ok, its a mac
2359 // otherwise its invalid
2366 GenAddress::operator const char *() const
2369 return (const char *)*address
; // pass thru
2371 return (char *)output_buffer
;
2374 // to_string form of the contained address
2375 const char * GenAddress::to_string()
2378 return address
->to_string(); // pass thru
2380 return (char *)output_buffer
;
2384 void GenAddress::format_output()
2386 output_buffer
[0] = '\0';
2389 //------[ return the type ]----------------------------------
2390 addr_type
GenAddress::get_type() const
2393 return type_invalid
;
2395 return address
->get_type();
2398 // call the particular type class here
2399 void GenAddress::to_octet(OctetStr
& octet
) const
2404 address
->to_octet(octet
);
2407 //------------------------------------------------------------------------
2408 //---------[ DecNet Address Class ]---------------------------------------
2409 //------------------------------------------------------------------------
2411 DecNetAddress::DecNetAddress( const char *inaddr
): Address()
2413 if (ACE_OS::strlen(inaddr
) == 0) {
2414 // always initialize SMI info
2415 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
2416 smival
.value
.string
.len
= DECNETLEN
;
2417 smival
.value
.string
.ptr
= address_buffer
;
2420 DecNetAddress::format_output();
2424 // always initialize SMI info
2425 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
2426 smival
.value
.string
.len
= DECNETLEN
;
2427 smival
.value
.string
.ptr
= address_buffer
;
2429 valid_flag
= parse_address( (char *) inaddr
);
2430 DecNetAddress::format_output();
2433 DecNetAddress::DecNetAddress( const DecNetAddress
& addr
)
2438 DecNetAddress::DecNetAddress( const GenAddress
& genaddr
)
2440 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
2441 smival
.value
.string
.len
= DECNETLEN
;
2442 smival
.value
.string
.ptr
= address_buffer
;
2445 // allow use of an ipx or ipxsock address
2446 if ( (genaddr
.get_type() == type_decnet
) ) {
2447 valid_flag
= genaddr
.valid();
2449 // copy in the Ipx address data
2450 DecNetAddress
temp_ipx( (const char *) genaddr
);
2454 DecNetAddress::format_output();
2457 DecNetAddress::~DecNetAddress()
2461 const char *DecNetAddress::to_string()
2463 return (char *)output_buffer
;
2466 DecNetAddress
& DecNetAddress::operator=( const DecNetAddress
&decaddr
)
2468 // protect against assignment from itself
2469 if ( this == &decaddr
)
2471 valid_flag
= decaddr
.valid_flag
;
2473 ACE_OS::memcpy(address_buffer
, decaddr
.address_buffer
, DECNETLEN
);
2478 void DecNetAddress::to_octet(OctetStr
& octet
) const
2480 octet
.set_data( smival
.value
.string
.ptr
, smival
.value
.string
.len
);
2483 DecNetAddress::operator const char *() const
2485 return (char *)output_buffer
;
2488 SmiUINT32
DecNetAddress::get_syntax()
2490 return sNMP_SYNTAX_OCTETS
;
2493 SnmpSyntax
& DecNetAddress::operator=( SnmpSyntax
&val
)
2495 // protect against assignment from itself
2499 valid_flag
= 0; // will get set 1 if really valid
2502 if (((DecNetAddress
&)val
).smival
.value
.string
.len
==DECNETLEN
) {
2503 ACE_OS::memcpy(address_buffer
,
2504 ((DecNetAddress
&)val
).smival
.value
.string
.ptr
, DECNETLEN
);
2508 DecNetAddress::format_output();
2512 SnmpSyntax
*DecNetAddress::clone() const
2514 return (SnmpSyntax
*) new DecNetAddress(*this);
2517 addr_type
DecNetAddress::get_type() const
2522 void DecNetAddress::format_output()
2524 // if valid format else null it
2526 ACE_OS::sprintf( (char *) output_buffer
,"%d.%d",address_buffer
[0],
2529 output_buffer
[0] = 0;
2532 int DecNetAddress::parse_address( const char *address
)
2534 if (ACE_OS::strlen(address
) > DECNETLEN
)
2535 return 0; // invalid
2537 ACE_OS::memset(address_buffer
, 0, DECNETLEN
);
2538 ACE_OS::memcpy(address_buffer
, address
, DECNETLEN
);
2544 //------------------------------------------------------------------------
2545 //---------[ AppleTalk Address Class ]------------------------------------
2546 //------------------------------------------------------------------------
2548 AppleTalkAddress::AppleTalkAddress( const char *inaddr
): Address()
2550 if (ACE_OS::strlen(inaddr
) == 0) {
2551 // always initialize SMI info
2552 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
2553 smival
.value
.string
.len
= APPLETKLEN
;
2554 smival
.value
.string
.ptr
= address_buffer
;
2557 AppleTalkAddress::format_output();
2561 // always initialize SMI info
2562 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
2563 smival
.value
.string
.len
= APPLETKLEN
;
2564 smival
.value
.string
.ptr
= address_buffer
;
2566 valid_flag
= parse_address( (char *) inaddr
);
2567 AppleTalkAddress::format_output();
2569 AppleTalkAddress::AppleTalkAddress( const AppleTalkAddress
& addr
)
2574 AppleTalkAddress::AppleTalkAddress( const GenAddress
& genaddr
)
2576 smival
.syntax
= sNMP_SYNTAX_OCTETS
;
2577 smival
.value
.string
.len
= APPLETKLEN
;
2578 smival
.value
.string
.ptr
= address_buffer
;
2581 // allow use of an ipx or ipxsock address
2582 if ( (genaddr
.get_type() == type_atk
) ) {
2583 valid_flag
= genaddr
.valid();
2585 // copy in the Ipx address data
2586 AppleTalkAddress
temp_ipx( (const char *) genaddr
);
2590 AppleTalkAddress::format_output();
2593 AppleTalkAddress::~AppleTalkAddress()
2597 const char *AppleTalkAddress::to_string()
2599 return (char *)output_buffer
;
2602 AppleTalkAddress
& AppleTalkAddress::operator=( const AppleTalkAddress
&ataddr
)
2604 // protect against assignment from itself
2605 if ( this == &ataddr
)
2607 valid_flag
= ataddr
.valid_flag
;
2609 ACE_OS::memcpy(address_buffer
, ataddr
.address_buffer
, APPLETKLEN
);
2614 void AppleTalkAddress::to_octet(OctetStr
& octet
) const
2616 octet
.set_data( smival
.value
.string
.ptr
, smival
.value
.string
.len
);
2619 AppleTalkAddress::operator const char *() const
2621 return (char *)output_buffer
;
2624 SmiUINT32
AppleTalkAddress::get_syntax()
2626 return sNMP_SYNTAX_OCTETS
;
2629 SnmpSyntax
& AppleTalkAddress::operator=( SnmpSyntax
&val
)
2631 // protect against assignment from itself
2635 valid_flag
= 0; // will get set 1 if really valid
2638 if (((AppleTalkAddress
&)val
).smival
.value
.string
.len
==APPLETKLEN
) {
2639 ACE_OS::memcpy(address_buffer
,
2640 ((AppleTalkAddress
&)val
).smival
.value
.string
.ptr
,APPLETKLEN
);
2644 AppleTalkAddress::format_output();
2648 SnmpSyntax
*AppleTalkAddress::clone() const
2650 return (SnmpSyntax
*) new AppleTalkAddress(*this);
2653 addr_type
AppleTalkAddress::get_type() const
2658 void AppleTalkAddress::format_output()
2660 // if valid format else null it
2662 ACE_OS::sprintf( (char *) output_buffer
,"%d.%d.%d", address_buffer
[0],
2663 address_buffer
[1], address_buffer
[3]);
2665 output_buffer
[0] = 0;
2668 int AppleTalkAddress::parse_address( const char *address
)
2670 if (ACE_OS::strlen(address
) > APPLETKLEN
)
2671 return 0; // invalid
2673 ACE_OS::memset(address_buffer
, 0, APPLETKLEN
);
2674 ACE_OS::memcpy(address_buffer
, address
, APPLETKLEN
);
2679 char AppleTalkAddress::get_host_address() const
2681 return address_buffer
[2];
2684 void AppleTalkAddress::set_host_address(const char host
)
2686 address_buffer
[2] = host
;
2689 short AppleTalkAddress::get_net_address() const
2692 ACE_OS::memcpy(&net
, address_buffer
, APPLETKLEN
- 1);
2696 void AppleTalkAddress::set_net_address(const short atknet
)
2698 ACE_OS::memcpy(address_buffer
, &atknet
, APPLETKLEN
-1);