SCNetwork.pas 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. {
  2. * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
  3. *
  4. * @APPLE_LICENSE_HEADER_START@
  5. *
  6. * This file contains Original Code and/or Modifications of Original Code
  7. * as defined in and that are subject to the Apple Public Source License
  8. * Version 2.0 (the 'License'). You may not use this file except in
  9. * compliance with the License. Please obtain a copy of the License at
  10. * http://www.opensource.apple.com/apsl/ and read it before using this
  11. * file.
  12. *
  13. * The Original Code and all software distributed under the License are
  14. * distributed on an 'AS IS' basis, WITHOUT WARRANTY of ANY KIND, EITHER
  15. * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  16. * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES of MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
  18. * Please see the License for the specific language governing rights and
  19. * limitations under the License.
  20. *
  21. * @APPLE_LICENSE_HEADER_END@
  22. }
  23. { Pascal Translation: Peter N Lewis, <[email protected]>, 2004 }
  24. {
  25. Modified for use with Free Pascal
  26. Version 200
  27. Please report any bugs to <[email protected]>
  28. }
  29. {$mode macpas}
  30. {$packenum 1}
  31. {$macro on}
  32. {$inline on}
  33. {$CALLING MWPASCAL}
  34. unit SCNetwork;
  35. interface
  36. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  37. {$setc GAP_INTERFACES_VERSION := $0200}
  38. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  39. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  40. {$endc}
  41. {$ifc defined CPUPOWERPC and defined CPUI386}
  42. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  43. {$endc}
  44. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  45. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  46. {$endc}
  47. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  48. {$setc __ppc__ := 1}
  49. {$elsec}
  50. {$setc __ppc__ := 0}
  51. {$endc}
  52. {$ifc not defined __i386__ and defined CPUI386}
  53. {$setc __i386__ := 1}
  54. {$elsec}
  55. {$setc __i386__ := 0}
  56. {$endc}
  57. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  58. {$error Conflicting definitions for __ppc__ and __i386__}
  59. {$endc}
  60. {$ifc defined __ppc__ and __ppc__}
  61. {$setc TARGET_CPU_PPC := TRUE}
  62. {$setc TARGET_CPU_X86 := FALSE}
  63. {$elifc defined __i386__ and __i386__}
  64. {$setc TARGET_CPU_PPC := FALSE}
  65. {$setc TARGET_CPU_X86 := TRUE}
  66. {$elsec}
  67. {$error Neither __ppc__ nor __i386__ is defined.}
  68. {$endc}
  69. {$setc TARGET_CPU_PPC_64 := FALSE}
  70. {$ifc defined FPC_BIG_ENDIAN}
  71. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  72. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  73. {$elifc defined FPC_LITTLE_ENDIAN}
  74. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  75. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  76. {$elsec}
  77. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  78. {$endc}
  79. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  80. {$setc CALL_NOT_IN_CARBON := FALSE}
  81. {$setc OLDROUTINENAMES := FALSE}
  82. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  83. {$setc OPAQUE_UPP_TYPES := TRUE}
  84. {$setc OTCARBONAPPLICATION := TRUE}
  85. {$setc OTKERNEL := FALSE}
  86. {$setc PM_USE_SESSION_APIS := TRUE}
  87. {$setc TARGET_API_MAC_CARBON := TRUE}
  88. {$setc TARGET_API_MAC_OS8 := FALSE}
  89. {$setc TARGET_API_MAC_OSX := TRUE}
  90. {$setc TARGET_CARBON := TRUE}
  91. {$setc TARGET_CPU_68K := FALSE}
  92. {$setc TARGET_CPU_MIPS := FALSE}
  93. {$setc TARGET_CPU_SPARC := FALSE}
  94. {$setc TARGET_OS_MAC := TRUE}
  95. {$setc TARGET_OS_UNIX := FALSE}
  96. {$setc TARGET_OS_WIN32 := FALSE}
  97. {$setc TARGET_RT_MAC_68881 := FALSE}
  98. {$setc TARGET_RT_MAC_CFM := FALSE}
  99. {$setc TARGET_RT_MAC_MACHO := TRUE}
  100. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  101. {$setc TYPE_BOOL := FALSE}
  102. {$setc TYPE_EXTENDED := FALSE}
  103. {$setc TYPE_LONGLONG := TRUE}
  104. uses MacTypes,CFBase,MacOSXPosix;
  105. {$ALIGN MAC68K}
  106. {!
  107. @header SCNetwork
  108. SCNetworkCheckReachabilityXXX()
  109. The SCNetworkCheckReachabilityXXX() APIs allow an application to
  110. determine the status of the system's current network configuration
  111. and the accessibility of a target host/address.
  112. The term "reachable" reflects whether a data packet, sent by
  113. an application into the network stack, can be sent to the
  114. the target host/address. Please note that their is no
  115. guarantee that the data packet will actually be received by
  116. the host.
  117. SCNetworkInterfaceRefreshConfiguration()
  118. This API sends a notification to interested network configuration
  119. agents to retry their configuraton immediately. For example, calling
  120. this API will cause the DHCP client to contact the DHCP server
  121. immediately rather than waiting until its timeout has expired.
  122. The utility of this API is to allow the caller to give a hint to
  123. the system that the network infrastructure/configuration has changed.
  124. }
  125. {!
  126. @enum SCNetworkConnectionFlags
  127. @discussion Flags that indicate whether the specified network
  128. nodename/address is reachable, requires a connection,
  129. requires some user intervention in establishing the
  130. connection, and whether the calling application must
  131. initiate the connection using the (TBD???) API.
  132. @constant kSCNetworkFlagsTransientConnection
  133. This flag indicates that the specified nodename/address can
  134. be reached via a transient (e.g. PPP) connection.
  135. @constant kSCNetworkFlagsReachable
  136. This flag indicates that the specified nodename/address can
  137. be reached using the current network configuration.
  138. @constant kSCNetworkFlagsConnectionRequired
  139. This flag indicates that the specified nodename/address can
  140. be reached using the current network configuration but a
  141. connection must first be established.
  142. As an example, this status would be returned for a dialup
  143. connection that was not currently active but could handle
  144. network traffic for the target system.
  145. @constant kSCNetworkFlagsConnectionAutomatic
  146. This flag indicates that the specified nodename/address can
  147. be reached using the current network configuration but a
  148. connection must first be established. Any traffic directed
  149. to the specified name/address will initiate the connection.
  150. @constant kSCNetworkFlagsInterventionRequired
  151. This flag indicates that the specified nodename/address can
  152. be reached using the current network configuration but a
  153. connection must first be established. In addition, some
  154. form of user intervention will be required to establish
  155. this connection (e.g. providing a password, authentication
  156. token, etc.).
  157. @constant kSCNetworkFlagsIsLocalAddress
  158. This flag indicates that the specified nodename/address
  159. is one associated with a network interface on the current
  160. system.
  161. @constant kSCNetworkFlagsIsDirect
  162. This flag indicates that network traffic to the specified
  163. nodename/address will not go through a gateway but is routed
  164. directly to one of the interfaces in the system.
  165. }
  166. type
  167. SCNetworkConnectionFlags = UInt32;
  168. const
  169. kSCNetworkFlagsTransientConnection = 1 shl 0;
  170. kSCNetworkFlagsReachable = 1 shl 1;
  171. kSCNetworkFlagsConnectionRequired = 1 shl 2;
  172. kSCNetworkFlagsConnectionAutomatic = 1 shl 3;
  173. kSCNetworkFlagsInterventionRequired = 1 shl 4;
  174. kSCNetworkFlagsIsLocalAddress = 1 shl 16;
  175. kSCNetworkFlagsIsDirect = 1 shl 17;
  176. {!
  177. @function SCNetworkCheckReachabilityByAddress
  178. @discussion Determines if the given network address is
  179. reachable using the current network configuration.
  180. @param address The network address of the desired host.
  181. @param addrlen The length, in bytes, of the address.
  182. @param flags A pointer to memory that will be filled with a
  183. set of SCNetworkConnectionFlags detailing the reachability
  184. of the specified address.
  185. @result TRUE if the network connection flags are valid; FALSE if the
  186. status could not be determined.
  187. }
  188. function SCNetworkCheckReachabilityByAddress( address: sockaddr_ptr; addrlen: SInt32; var flags: SCNetworkConnectionFlags ): Boolean; external name '_SCNetworkCheckReachabilityByAddress';
  189. {!
  190. @function SCNetworkCheckReachabilityByName
  191. @discussion Determines if the given network host/node name is
  192. reachable using the current network configuration.
  193. @param nodename The node name of the desired host. This name would
  194. be the same as that passed to gethostbyname() or getaddrinfo().
  195. @param flags A pointer to memory that will be filled with a
  196. set of SCNetworkConnectionFlags detailing the reachability
  197. of the specified node name.
  198. @result TRUE if the network connection flags are valid; FALSE if the
  199. status could not be determined.
  200. }
  201. function SCNetworkCheckReachabilityByName( nodename: CStringPtr; var flags: SCNetworkConnectionFlags ): Boolean; external name '_SCNetworkCheckReachabilityByName';
  202. {!
  203. @function SCNetworkInterfaceRefreshConfiguration
  204. @discussion Sends a notification to interested configuration agents
  205. to have them immediately retry their configuration over a
  206. particular network interface.
  207. Note: This API must be invoked by root (uid == 0).
  208. @param ifName The BSD name of the network interface e.g. CFSTR("en0").
  209. @result TRUE if the notification was sent; FALSE otherwise.
  210. }
  211. function SCNetworkInterfaceRefreshConfiguration( ifName: CFStringRef ): Boolean; external name '_SCNetworkInterfaceRefreshConfiguration';
  212. end.