00001 /************************************************************************* 00002 * The contents of this file are subject to the MYRICOM DBL * 00003 * NETWORKING SOFTWARE AND DOCUMENTATION LICENSE (the "License"); * 00004 * User may not use this file except in compliance with the * 00005 * License. The full text of the License can found in LICENSE.TXT * 00006 * * 00007 * Software distributed under the License is distributed on an "AS IS" * 00008 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * 00009 * the License for the specific language governing rights and * 00010 * limitations under the License. * 00011 * * 00012 * Copyright 2009 by Myricom, Inc. All rights reserved. * 00013 *************************************************************************/ 00014 00188 #ifndef _DBL_H 00189 #define _DBL_H 00190 00191 #ifdef __cplusplus 00192 extern "C" 00193 { 00194 #endif 00195 00196 /**********************************************************************/ 00197 /* Control import/export of symbols and calling convention. */ 00198 /**********************************************************************/ 00199 #ifndef _WIN32 00200 # define DBL_FUNC(type) type 00201 # define DBL_VAR(type) type 00202 #else 00203 # ifdef DBL_BUILDING_LIB 00204 # ifdef __cplusplus 00205 # define DBL_FUNC(type) extern "C" __declspec(dllexport) type __cdecl 00206 # define DBL_VAR(type) extern "C" __declspec(dllexport) type 00207 # else 00208 # define DBL_FUNC(type) __declspec(dllexport) type __cdecl 00209 # define DBL_VAR(type) __declspec(dllexport) type 00210 # endif 00211 # else 00212 # ifdef __cplusplus 00213 # define DBL_FUNC(type) extern "C" __declspec(dllimport) type __cdecl 00214 # define DBL_VAR(type) extern "C" __declspec(dllimport) type 00215 # else 00216 # define DBL_FUNC(type) __declspec(dllimport) type __cdecl 00217 # define DBL_VAR(type) __declspec(dllimport) type 00218 # endif 00219 # endif 00220 #endif 00221 00222 #ifdef _WIN32 00223 typedef HANDLE DBL_OS_HANDLE; 00224 #else 00225 typedef int DBL_OS_HANDLE; 00226 #endif 00227 00228 /* Opaque/internal-only structures */ 00229 typedef struct dbl__ep *dbl_device_t; 00230 typedef struct dbl__channel *dbl_channel_t; 00231 typedef struct dbl__send *dbl_send_t; 00232 00241 /* 00242 * DBL API version number 00243 * LSB increases for minor backwards compatible changes in the API 00244 * MSB increases for incompatible changes in the API 00245 * 00246 * dbl release 0.5 is at API version 0x0001 00247 * dbl_init() can be called multiple times, as long as the DBL_VERSION_API is 00248 * the same each time. 00249 */ 00250 00257 #define DBL_VERSION_API 0x0001 00258 00274 DBL_FUNC(int) 00275 dbl_init(uint16_t api_version); /* DBL_VERSION_API */ 00276 00285 #define DBL_OPEN_THREADSAFE 0x1 00286 00312 DBL_FUNC(int) 00313 dbl_open(struct in_addr *interface_addr, 00314 int flags, 00315 dbl_device_t *dev_out); 00316 00317 00342 DBL_FUNC(int) 00343 dbl_open_if(const char*ifname, 00344 int flags, 00345 dbl_device_t *dev_out); 00346 00347 00359 DBL_FUNC(DBL_OS_HANDLE) 00360 dbl_device_handle(dbl_device_t dev); 00361 00371 DBL_FUNC(int) 00372 dbl_close(dbl_device_t dev); 00373 00380 #define DBL_BIND_REUSEADDR 0x02 00381 00384 #define DBL_BIND_DUP_TO_KERNEL 0x04 00385 00389 #define DBL_BIND_NO_UNICAST 0x08 00390 00393 #define DBL_BIND_BROADCAST 0x10 00394 00396 /* Recv functionality, multicast and unicast. 00397 * dbl_bind() creates a channel associated with a given port on the 00398 * specified device. Incoming packets directed to this port will be received 00399 * on this channel, and all packets sent through this channel will have 00400 * this port as the sender address. 00401 */ 00402 00429 DBL_FUNC(int) 00430 dbl_bind(dbl_device_t dev, int flags, int port, 00431 void *context, dbl_channel_t *handle_out); 00432 00463 DBL_FUNC(int) 00464 dbl_bind_addr(dbl_device_t dev, struct in_addr *ipaddr, int flags, int port, 00465 void *context, dbl_channel_t *handle_out); 00466 00477 DBL_FUNC(int) 00478 dbl_unbind(dbl_channel_t handle); 00479 00480 /* return bound address for a channel */ 00492 DBL_FUNC(int) 00493 dbl_getaddress(dbl_channel_t ch, struct sockaddr_in *sin); 00494 00495 /* Join/leave a multicast group 00496 */ 00512 DBL_FUNC(int) 00513 dbl_mcast_join(dbl_channel_t ch, struct in_addr *mcast_addr, void *unused); 00514 00531 DBL_FUNC(int) 00532 dbl_mcast_leave(dbl_channel_t ch, struct in_addr *mcast_addr); 00533 00538 struct dbl_recv_info { 00540 dbl_channel_t chan; 00543 void *chan_context; /* context from dbl_bind() */ 00545 void *unused; /* unused */ 00547 struct sockaddr_in sin_from; 00551 struct sockaddr_in sin_to; /* destination address */ 00555 uint32_t msg_len; 00556 }; 00557 00561 enum dbl_recvmode { 00563 DBL_RECV_DEFAULT = 0, 00565 DBL_RECV_NONBLOCK = 1, 00567 DBL_RECV_BLOCK = 2, 00569 DBL_RECV_PEEK = 3, 00571 DBL_RECV_PEEK_MSG = 4, 00572 #ifdef _WIN32 00573 00574 DBL_RECV_NONBLOCK_SETEVENT = 5, 00575 #endif 00576 }; 00577 00602 DBL_FUNC(int) 00603 dbl_recvfrom(dbl_device_t dev, enum dbl_recvmode mode, 00604 void *buf, size_t len, struct dbl_recv_info *info); 00605 00606 /* 00607 * Send functionality 00608 */ 00644 DBL_FUNC(int) 00645 dbl_send_connect(dbl_channel_t chan, const struct sockaddr_in *dest_sin, 00646 int flags, int ttl, dbl_send_t *hsend); 00652 #define DBL_NONBLOCK 0x4 00653 00671 DBL_FUNC(int) 00672 dbl_send(dbl_send_t sendh, const void *buf, size_t len, int flags); 00673 00683 DBL_FUNC(int) 00684 dbl_send_disconnect(dbl_send_t hsend); 00685 00701 DBL_FUNC(int) 00702 dbl_sendto(dbl_channel_t ch, struct sockaddr_in *sin, 00703 const void *buf, size_t len, int flags); 00704 00705 #ifdef _WIN32 00706 00709 DBL_FUNC(int) 00710 dbl_eventselect(dbl_device_t dev, HANDLE event, long mask); 00711 #endif 00712 00716 #ifdef __cplusplus 00717 } 00718 #endif 00719 00720 #endif /* _DBL_H */
![]()
19 January 2011 DBL 1.0.2