1 /**************************************************************************/ 2 /* */ 3 /* Copyright (c) Microsoft Corporation. All rights reserved. */ 4 /* */ 5 /* This software is licensed under the Microsoft Software License */ 6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */ 7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ 8 /* and in the root directory of this software. */ 9 /* */ 10 /**************************************************************************/ 11 12 /**************************************************************************/ 13 /**************************************************************************/ 14 /** */ 15 /** NetX Component */ 16 /** */ 17 /** BSD 4.3 Socket API Compatible Interface to NetX Duo */ 18 /** */ 19 /** */ 20 /**************************************************************************/ 21 /**************************************************************************/ 22 23 /**************************************************************************/ 24 /* */ 25 /* BSD DEFINITIONS RELEASE */ 26 /* */ 27 /* nxd_bsd.h PORTABLE C */ 28 /* 6.3.0 */ 29 /* AUTHOR */ 30 /* */ 31 /* Yuxin Zhou, Microsoft Corporation */ 32 /* */ 33 /* DESCRIPTION */ 34 /* */ 35 /* This file defines the constants, structures, etc... needed to */ 36 /* implement the BSD 4.3 Socket API Compatible Interface to NetX Duo. */ 37 /* */ 38 /* */ 39 /* RELEASE HISTORY */ 40 /* */ 41 /* DATE NAME DESCRIPTION */ 42 /* */ 43 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ 44 /* 09-30-2020 Yuxin Zhou Modified comment(s), */ 45 /* resulting in version 6.1 */ 46 /* 03-02-2021 Yuxin Zhou Modified comment(s), and */ 47 /* fixed compiler warnings, */ 48 /* resulting in version 6.1.5 */ 49 /* 10-15-2021 Yuxin Zhou Modified comment(s), and */ 50 /* defined IP protocols for */ 51 /* ICMP, IGMP and ICMPv6, */ 52 /* resulting in version 6.1.9 */ 53 /* 10-31-2023 Chaoqiong Xiao Modified comment(s), and */ 54 /* added option to enable */ 55 /* native APIs with prefix, */ 56 /* resulting in version 6.3.0 */ 57 /* */ 58 /**************************************************************************/ 59 60 #ifndef NXD_BSD_H 61 #define NXD_BSD_H 62 63 /* Determine if a C++ compiler is being used. If so, ensure that standard 64 C is used to process the API information. */ 65 66 #ifdef __cplusplus 67 68 /* Yes, C++ compiler is present. Use standard C. */ 69 extern "C" { 70 71 #endif 72 73 #ifndef __CCRX__ 74 #include "time.h" 75 #endif /* __CCRX__ */ 76 77 /* Bring in the necessary NetX include file. */ 78 #include "nx_api.h" 79 80 81 /* Define the print error macro for reporting source line number. 82 83 #define NX_BSD_PRINT_ERRORS 84 */ 85 86 /* Defined, raw pppoe feature is enabled. */ 87 /* 88 #define NX_BSD_RAW_PPPOE_SUPPORT 89 */ 90 91 /* Defined, raw feature is enabled. */ 92 /* 93 #define NX_BSD_RAW_SUPPORT 94 */ 95 96 /* Defined, raw packet is not duplicated. Then NetX will not handle packets such as ARP. */ 97 /* 98 #define NX_DISABLE_BSD_RAW_PACKET_DUPLICATE 99 */ 100 101 #if defined(NX_BSD_RAW_SUPPORT) && defined(NX_BSD_RAW_PPPOE_SUPPORT) 102 #error "Raw feature conflicts with raw PPPoE feature" 103 #endif /* defined(NX_BSD_RAW_SUPPORT) && defined(NX_BSD_RAW_PPPOE_SUPPORT) */ 104 105 /* Defined, getaddrinfo is able to get address by name/cname. getnameinfo is able to get name by address. */ 106 /* 107 #define NX_BSD_ENABLE_DNS 108 */ 109 110 111 /* 112 Define the BSD socket timeout process to execute in the timer context. 113 If this option is not defined, application needs to create stack space for the BSD timeout process 114 thread, and passes the stack to the BSD layer through the bsd_initialize() call. In this configuration, 115 the BSD timeout process is all done in the BSD timeout process thread context. 116 117 User may choose to define NX_BSD_TIMEOUT_PROCESS_IN_TIMER, so the BSD timeout process is executed in the 118 ThreadX timer object context. This configuration could eliminate an extra thread (and associated stack 119 space.) The following parameters passed into bsd_initialize are ignored: 120 * bsd_thread_stack_area 121 * bsd_thread_stack_size 122 * bsd_thread_priority 123 However system designer needs to be aware of the following if the BSD timeout process is 124 executed in ThreadX timer context: 125 * The amount of BSD socket processing may slow down the ThreadX timer; 126 * If the timer is executed in ISR context (ThreadX library is built with TX_TIMER_PROCESS_IN_ISR), 127 the BSD timeout process is now executing in the ISR context; 128 129 By default NX_BSD_TIMEOUT_PROCESS_IN_TIMER is NOT defined. 130 */ 131 /* #define NX_BSD_TIMEOUT_PROCESS_IN_TIMER */ 132 133 134 /* Defined, APIs are natively named with nx_bsd_ prefix to avoid conflicting/overriding OS BSD APIs. */ 135 /* 136 #define NX_BSD_ENABLE_NATIVE_API 137 */ 138 139 140 /* Define configuration constants for the BSD compatibility layer. Note that these can be overridden via -D or a #define somewhere else. */ 141 142 #ifndef NX_BSD_TCP_WINDOW 143 #define NX_BSD_TCP_WINDOW 65535 /* 64k is typical window size for 100Mb ethernet. */ 144 #endif 145 146 #ifndef NX_BSD_SOCKFD_START 147 #define NX_BSD_SOCKFD_START 32 /* Logical FD starting value. */ 148 #endif 149 150 #ifndef NX_BSD_MAX_SOCKETS 151 #define NX_BSD_MAX_SOCKETS 32 /* Maximum number of total sockets available in the BSD layer. Note */ 152 #endif /* NOTE: Must be multiple of 32! */ 153 154 #ifndef NX_BSD_MAX_LISTEN_BACKLOG 155 #define NX_BSD_MAX_LISTEN_BACKLOG 5 /* Maximum listen backlog. */ 156 #endif 157 158 #ifndef NX_MICROSECOND_PER_CPU_TICK 159 #define NX_MICROSECOND_PER_CPU_TICK (1000000/NX_IP_PERIODIC_RATE) /* Number of microseconds per timer interrupt, default 10ms. */ 160 #endif 161 #ifndef NX_BSD_TIMEOUT 162 #define NX_BSD_TIMEOUT (20*NX_IP_PERIODIC_RATE) 163 /* By default all internal NetX calls wait and block for 20 seconds. */ 164 #endif 165 166 167 #ifndef NX_BSD_TCP_SOCKET_DISCONNECT_TIMEOUT 168 #define NX_BSD_TCP_SOCKET_DISCONNECT_TIMEOUT 1 /* Timeout in timer ticks for internal NetX to disconnect the socket. 169 The default value of 1 tick is so NetX BSD emulates native BSD 170 socket and performs an immediate socket close without sending an RST 171 packet. */ 172 #endif 173 174 /* Define configurable options for BSD extended options. */ 175 176 177 #ifndef NX_BSD_TIMER_RATE 178 #define NX_BSD_TIMER_RATE (1 * NX_IP_PERIODIC_RATE) /* Rate at which BSD timer runs. */ 179 #endif 180 181 182 /* Define BSD events */ 183 184 #define NX_BSD_RECEIVE_EVENT ((ULONG) 0x00000001) /* Event flag to signal a receive packet event */ 185 #define NX_BSD_SELECT_EVENT ((ULONG) 0x00008000) /* Event flag to signal a thread is waiting in select */ 186 #define NX_BSD_ALL_EVENTS ((ULONG) 0xFFFFFFFF) /* All event flag */ 187 #define NX_BSD_CONNECT_EVENT ((ULONG) 0x00000002) 188 #define NX_BSD_LINGER_EVENT ((ULONG) 0x00000004) /* Event flag to signal a timed linger state has expired on a socket */ 189 #define NX_BSD_TIMED_WAIT_EVENT ((ULONG) 0x00000008) /* Event flag to signal a timed wait state has expired on a socket */ 190 #define NX_BSD_TIMER_EVENT ((ULONG) 0x00000010) /* Event flag to singal a BSD 1 sec timer */ 191 192 193 /* For BSD APIs overriding. */ 194 195 #if !defined(NX_BSD_ENABLE_NATIVE_API) 196 197 198 /* Overriding struct names. */ 199 200 #define nx_bsd_time_t time_t 201 #define nx_bsd_suseconds_t suseconds_t 202 203 #define nx_bsd_timeval timeval 204 205 #define nx_bsd_sockaddr_storage sockaddr_storage 206 207 #define nx_bsd_sockaddr sockaddr 208 209 #define nx_bsd_in6_addr in6_addr 210 211 #define nx_bsd_sockaddr_in6 sockaddr_in6 212 213 #define nx_bsd_in_addr in_addr 214 #define nx_bsd_in_addr_t in_addr_t 215 #define nx_bsd_socklen_t socklen_t 216 217 #define nx_bsd_sockaddr_in sockaddr_in 218 219 #define nx_bsd_fd_set fd_set 220 221 #define nx_bsd_ip_mreq ip_mreq 222 223 #define nx_bsd_sock_errno sock_errno 224 225 #define nx_bsd_linger linger 226 227 #define nx_bsd_sock_keepalive sock_keepalive 228 229 #define nx_bsd_sock_reuseaddr sock_reuseaddr 230 231 #define nx_bsd_sock_winsize sock_winsize 232 233 #define nx_bsd_addrinfo addrinfo 234 235 #define nx_bsd_pollfd pollfd 236 237 #define nx_bsd_sockaddr_ll sockaddr_ll 238 239 240 /* Overriding function names. */ 241 242 #define nx_bsd_accept accept 243 #define nx_bsd_initialize bsd_initialize 244 #define nx_bsd_bind bind 245 #define nx_bsd_connect connect 246 #define nx_bsd_getpeername getpeername 247 #define nx_bsd_getsockname getsockname 248 #define nx_bsd_ioctl ioctl 249 #define nx_bsd_inet_addr inet_addr 250 #define nx_bsd_inet_ntoa inet_ntoa 251 #define nx_bsd_inet_aton inet_aton 252 #define nx_bsd_inet_pton inet_pton 253 #define nx_bsd_inet_ntop inet_ntop 254 #define nx_bsd_listen listen 255 #define nx_bsd_recvfrom recvfrom 256 #define nx_bsd_recv recv 257 #define nx_bsd_sendto sendto 258 #define nx_bsd_send send 259 #define nx_bsd_select select 260 #define nx_bsd_soc_close soc_close 261 #define nx_bsd_socket socket 262 #define nx_bsd_fcntl fcntl 263 #define nx_bsd_getsockopt getsockopt 264 #define nx_bsd_setsockopt setsockopt 265 #define nx_bsd_getaddrinfo getaddrinfo 266 #define nx_bsd_freeaddrinfo freeaddrinfo 267 #define nx_bsd_getnameinfo getnameinfo 268 #define nx_bsd_set_errno set_errno 269 #define nx_bsd_poll poll 270 271 #define NX_BSD_FD_SET FD_SET 272 #define NX_BSD_FD_CLR FD_CLR 273 #define NX_BSD_FD_ISSET FD_ISSET 274 #define NX_BSD_FD_ZERO FD_ZERO 275 276 277 278 #endif 279 280 /* For compatibility undefine the fd_set. Then define the FD set size. */ 281 282 #ifdef fd_set 283 #undef fd_set 284 #endif 285 286 #ifdef FD_SETSIZE 287 #undef FD_SETSIZE /* May be different in other header files e.g 64 in GNU types.h file */ 288 #define FD_SETSIZE (NX_BSD_MAX_SOCKETS + NX_BSD_SOCKFD_START) /* Number of sockets to select on - same is max sockets! */ 289 #else 290 #define FD_SETSIZE (NX_BSD_MAX_SOCKETS + NX_BSD_SOCKFD_START) /* Number of sockets to select on - same is max sockets! */ 291 #endif 292 293 294 /* Define some BSD protocol constants. */ 295 296 #define SOCK_STREAM 1 /* TCP Socket */ 297 #define SOCK_DGRAM 2 /* UDP Socket */ 298 #define SOCK_RAW 3 /* Raw socket */ 299 #define IPPROTO_ICMP 1 /* ICMP used with socket type SOCK_RAW */ 300 #define IPPROTO_IGMP 2 /* IGMP used with socket type SOCK_RAW */ 301 #define IPPROTO_TCP 6 /* TCP Socket */ 302 #define IPPROTO_UDP 17 /* TCP Socket */ 303 #define IPPROTO_ICMPV6 58 /* ICMPv6 used with socket type SOCK_RAW */ 304 #define IPPROTO_RAW 255 /* Raw Socket */ 305 306 /* Define supported flags for 'send' and 'recv'. */ 307 #define MSG_PEEK 0x02 /* Peek incoming message */ 308 #define MSG_DONTWAIT 0x40 /* Nonblocking IO */ 309 310 /* Address families. */ 311 312 #define AF_UNSPEC 0 /* Unspecified. */ 313 #define AF_NS 1 /* Local to host (pipes, portals). */ 314 #define AF_INET 2 /* IPv4 socket (UDP, TCP, etc) */ 315 #define AF_INET6 3 /* IPv6 socket (UDP, TCP, etc) */ 316 #define AF_PACKET 4 /* Raw Packet type (Link Layer packets) */ 317 318 /* Protocol families, same as address families. */ 319 #define PF_INET AF_INET 320 #define PF_INET6 AF_INET6 321 #define PF_PACKET AF_PACKET 322 #define ETH_P_ALL 3 323 324 #define INADDR_ANY 0 325 #define NX_BSD_LOCAL_IF_INADDR_ANY 0xFFFFFFFF 326 /* Define API error codes. */ 327 328 #define NX_SOC_ERROR -1 /* Failure. */ 329 #ifndef ERROR 330 #define ERROR NX_SOC_ERROR 331 #endif 332 #define NX_SOC_OK 0 /* Success. */ 333 #ifndef OK 334 #define OK NX_SOC_OK 335 #endif 336 #define NX_BSD_BLOCK_POOL_ERROR 1 337 #define NX_BSD_MUTEX_ERROR 2 338 #define NX_BSD_THREAD_ERROR 4 339 #define NX_BSD_EVENT_ERROR 7 340 #define NX_BSD_ENVIRONMENT_ERROR 8 341 342 #ifndef NX_PACKET_OFFSET_ERROR 343 #define NX_PACKET_OFFSET_ERROR 0x53 344 #endif 345 346 /* The Netx API does not require Host to Network conversion or vice versa. The following macro's are provided for source compatibility reasons only. */ 347 348 #ifndef htons 349 #define htons(a) a 350 #endif 351 #ifndef htonl 352 #define htonl(a) a 353 #endif 354 #ifndef ntohs 355 #define ntohs(a) a 356 #endif 357 #ifndef ntohl 358 #define ntohl(a) a 359 #endif 360 361 /* Define error handling macro. */ 362 363 #ifdef NX_BSD_PRINT_ERRORS 364 #define NX_BSD_ERROR(status, line) printf(" NX BSD debug error message:, NX status: %x source line: %i \n", status, line) 365 #else 366 #define NX_BSD_ERROR(status, line) 367 #endif 368 369 370 /* Define file descriptor operation flags. */ 371 372 /* Note: FIONREAD is hardware dependant. The default is for i386 processor. */ 373 #ifndef FIONREAD 374 #define FIONREAD 0x541B /* Read bytes available for the ioctl() command */ 375 #endif 376 377 #define F_GETFL 3 /* Get file descriptors */ 378 #define F_SETFL 4 /* Set a subset of file descriptors (e.g. O_NONBlOCK */ 379 #define O_NONBLOCK 0x4000 /* Option to enable non blocking on a file (e.g. socket) */ 380 381 #ifndef FIONBIO 382 #define FIONBIO 0x5421 /* Enables socket non blocking option for the ioctl() command */ 383 #endif 384 385 386 /* Define the minimal TCP socket listen backlog value. */ 387 #ifndef NX_BSD_TCP_LISTEN_MIN_BACKLOG 388 #define NX_BSD_TCP_LISTEN_MIN_BACKLOG 1 389 #endif 390 391 /* Define the maximum number of packets that can be queued on a UDP socket or RAW socket. */ 392 #ifndef NX_BSD_SOCKET_QUEUE_MAX 393 #define NX_BSD_SOCKET_QUEUE_MAX 5 394 #endif 395 396 /* Define the constants that determine how big the hash table is for raw socket Protocol. The 397 value must be a power of two, so subtracting one gives us the mask. */ 398 399 #ifndef NX_BSD_SOCKET_RAW_PROTOCOL_TABLE_SIZE 400 #define NX_BSD_SOCKET_RAW_PROTOCOL_TABLE_SIZE 32 401 #endif /* NX_BSD_SOCKET_RAW_PROTOCOL_TABLE_SIZE */ 402 403 #define NX_BSD_SOCKET_RAW_PROTOCOL_TABLE_MASK (NX_BSD_SOCKET_RAW_PROTOCOL_TABLE_SIZE-1) 404 405 /* Define additional BSD socket errors. */ 406 407 /* From errno-base.h in /usr/include/asm-generic; */ 408 #define EPERM 1 /* Operation not permitted */ 409 #define E_MIN 1 /* Minimum Socket/IO error */ 410 #define ENOENT 2 /* No such file or directory */ 411 #define ESRCH 3 /* No such process */ 412 #define EINTR 4 /* Interrupted system call */ 413 #define EIO 5 /* I/O error */ 414 #define ENXIO 6 /* No such device or address */ 415 #define E2BIG 7 /* Argument list too long */ 416 #define ENOEXEC 8 /* Exec format error */ 417 #define EBADF 9 /* Bad file number */ 418 #define ECHILD 10 /* No child processes */ 419 #define EAGAIN 11 /* Try again */ 420 #define ENOMEM 12 /* Out of memory */ 421 #define EACCES 13 /* Permission denied */ 422 #define EFAULT 14 /* Bad address */ 423 #define ENOTBLK 15 /* Block device required */ 424 #define EBUSY 16 /* Device or resource busy */ 425 #define EEXIST 17 /* File exists */ 426 #define EXDEV 18 /* Cross-device link */ 427 #define ENODEV 19 /* No such device */ 428 #define ENOTDIR 20 /* Not a directory */ 429 #define EISDIR 21 /* Is a directory */ 430 #define EINVAL 22 /* Invalid argument */ 431 #define ENFILE 23 /* File table overflow */ 432 #define EMFILE 24 /* Too many open files */ 433 #define ENOTTY 25 /* Not a typewriter */ 434 #define ETXTBSY 26 /* Text file busy */ 435 #define EFBIG 27 /* File too large */ 436 #define ENOSPC 28 /* No space left on device */ 437 #define ESPIPE 29 /* Illegal seek */ 438 #define EROFS 30 /* Read-only file system */ 439 #define EMLINK 31 /* Too many links */ 440 #define EPIPE 32 /* Broken pipe */ 441 #define EDOM 33 /* Math argument out of domain of func */ 442 #define ERANGE 34 /* Math result not representable */ 443 444 /* From errno.h in /usr/include/asm-generic; */ 445 446 #define EDEADLK 35 /* Resource deadlock would occur */ 447 #define ENAMETOOLONG 36 /* File name too long */ 448 #define ENOLCK 37 /* No record locks available */ 449 #define ENOSYS 38 /* Function not implemented */ 450 #define ENOTEMPTY 39 /* Directory not empty */ 451 #define ELOOP 40 /* Too many symbolic links encountered */ 452 #define EWOULDBLOCK EAGAIN /* Operation would block */ 453 #define ENOMSG 42 /* No message of desired type */ 454 #define EIDRM 43 /* Identifier removed */ 455 #define ECHRNG 44 /* Channel number out of range */ 456 #define EL2NSYNC 45 /* Level 2 not synchronized */ 457 #define EL3HLT 46 /* Level 3 halted */ 458 #define EL3RST 47 /* Level 3 reset */ 459 #define ELNRNG 48 /* Link number out of range */ 460 #define EUNATCH 49 /* Protocol driver not attached */ 461 #define ENOCSI 50 /* No CSI structure available */ 462 #define EL2HLT 51 /* Level 2 halted */ 463 #define EBADE 52 /* Invalid exchange */ 464 #define EBADR 53 /* Invalid request descriptor */ 465 #define EXFULL 54 /* Exchange full */ 466 #define ENOANO 55 /* No anode */ 467 #define EBADRQC 56 /* Invalid request code */ 468 #define EBADSLT 57 /* Invalid slot */ 469 #define EDEADLOCK EDEADLK 470 #define EBFONT 59 /* Bad font file format */ 471 #define ENOSTR 60 /* Device not a stream */ 472 #define ENODATA 61 /* No data available */ 473 #define ETIME 62 /* Timer expired */ 474 #define ENOSR 63 /* Out of streams resources */ 475 #define ENONET 64 /* Machine is not on the network */ 476 #define ENOPKG 65 /* Package not installed */ 477 #define EREMOTE 66 /* Object is remote */ 478 #define ENOLINK 67 /* Link has been severed */ 479 #define EADV 68 /* Advertise error */ 480 #define ESRMNT 69 /* Srmount error */ 481 #define ECOMM 70 /* Communication error on send */ 482 #define EPROTO 71 /* Protocol error */ 483 #define EMULTIHOP 72 /* Multihop attempted */ 484 #define EDOTDOT 73 /* RFS specific error */ 485 #define EBADMSG 74 /* Not a data message */ 486 #define EOVERFLOW 75 /* Value too large for defined data type */ 487 #define ENOTUNIQ 76 /* Name not unique on network */ 488 #define EBADFD 77 /* File descriptor in bad state */ 489 #define EREMCHG 78 /* Remote address changed */ 490 #define ELIBACC 79 /* Can not access a needed shared library */ 491 #define ELIBBAD 80 /* Accessing a corrupted shared library */ 492 #define ELIBSCN 81 /* .lib section in a.out corrupted */ 493 #define ELIBMAX 82 /* Attempting to link in too many shared libraries */ 494 #define ELIBEXEC 83 /* Cannot exec a shared library directly */ 495 #define EILSEQ 84 /* Illegal byte sequence */ 496 #define ERESTART 85 /* Interrupted system call should be restarted */ 497 #define ESTRPIPE 86 /* Streams pipe error */ 498 #define EUSERS 87 /* Too many users */ 499 #define ENOTSOCK 88 /* Socket operation on non-socket */ 500 #define EDESTADDRREQ 89 /* Destination address required */ 501 #define EMSGSIZE 90 /* Message too long */ 502 #define EPROTOTYPE 91 /* Protocol wrong type for socket */ 503 #define ENOPROTOOPT 92 /* Protocol not available */ 504 #define EPROTONOSUPPORT 93 /* Protocol not supported */ 505 #define ESOCKTNOSUPPORT 94 /* Socket type not supported */ 506 #define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ 507 #define EPFNOSUPPORT 96 /* Protocol family not supported */ 508 #define EAFNOSUPPORT 97 /* Address family not supported by protocol */ 509 #define EADDRINUSE 98 /* Address already in use */ 510 #define EADDRNOTAVAIL 99 /* Cannot assign requested address */ 511 #define ENETDOWN 100 /* Network is down */ 512 #define ENETUNREACH 101 /* Network is unreachable */ 513 #define ENETRESET 102 /* Network dropped connection because of reset */ 514 #define ECONNABORTED 103 /* Software caused connection abort */ 515 #define ECONNRESET 104 /* Connection reset by peer */ 516 #define ENOBUFS 105 /* No buffer space available */ 517 #define EISCONN 106 /* Transport endpoint is already connected */ 518 #define ENOTCONN 107 /* Transport endpoint is not connected */ 519 #define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ 520 #define ETOOMANYREFS 109 /* Too many references: cannot splice */ 521 #define ETIMEDOUT 110 /* Connection timed out */ 522 #define ECONNREFUSED 111 /* Connection refused */ 523 #define EHOSTDOWN 112 /* Host is down */ 524 #define EHOSTUNREACH 113 /* No route to host */ 525 #define EALREADY 114 /* Operation already in progress */ 526 #define EINPROGRESS 115 /* Operation now in progress */ 527 #define ESTALE 116 /* Stale NFS file handle */ 528 #define EUCLEAN 117 /* Structure needs cleaning */ 529 #define ENOTNAM 118 /* Not a XENIX named type file */ 530 #define ENAVAIL 119 /* No XENIX semaphores available */ 531 #define EISNAM 120 /* Is a named type file */ 532 #define EREMOTEIO 121 /* Remote I/O error */ 533 #define EDQUOT 122 /* Quota exceeded */ 534 #define ENOMEDIUM 123 /* No medium found */ 535 #define EMEDIUMTYPE 124 /* Wrong medium type */ 536 #define ECANCELED 125 /* Operation Canceled */ 537 #define ENOKEY 126 /* Required key not available */ 538 #define EKEYEXPIRED 127 /* Key has expired */ 539 #define EKEYREVOKED 128 /* Key has been revoked */ 540 #define EKEYREJECTED 129 /* Key was rejected by service */ 541 #define EOWNERDEAD 130 /* Owner died - for robust mutexes*/ 542 #define ENOTRECOVERABLE 131 /* State not recoverable */ 543 #define ERFKILL 132 /* Operation not possible due to RF-kill */ 544 545 546 /* List of BSD sock options from socket.h in /usr/include/asm/socket.h and asm-generic/socket.h. 547 Note: not all of these are implemented in NetX Duo Extended socket options. 548 549 The first set of socket options take the socket level (category) SOL_SOCKET. */ 550 551 #define SOL_SOCKET 1 /* Define the socket option category. */ 552 #define IPPROTO_IP 2 /* Define the IP option category. */ 553 #define SO_MIN 1 /* Minimum Socket option ID */ 554 #define SO_DEBUG 1 /* Debugging information is being recorded.*/ 555 #define SO_REUSEADDR 2 /* Enable reuse of local addresses in the time wait state */ 556 #define SO_TYPE 3 /* Socket type */ 557 #define SO_ERROR 4 /* Socket error status */ 558 #define SO_DONTROUTE 5 /* Bypass normal routing */ 559 #define SO_BROADCAST 6 /* Transmission of broadcast messages is supported.*/ 560 #define SO_SNDBUF 7 /* Enable setting trasnmit buffer size */ 561 #define SO_RCVBUF 8 /* Enable setting receive buffer size */ 562 #define SO_KEEPALIVE 9 /* Connections are kept alive with periodic messages */ 563 #define SO_OOBINLINE 10 /* Out-of-band data is transmitted in line */ 564 #define SO_NO_CHECK 11 /* Disable UDP checksum */ 565 #define SO_PRIORITY 12 /* Set the protocol-defined priority for all packets to be sent on this socket */ 566 #define SO_LINGER 13 /* Socket lingers on close pending remaining send/receive packets. */ 567 #define SO_BSDCOMPAT 14 /* Enable BSD bug-to-bug compatibility */ 568 #define SO_REUSEPORT 15 /* Rebind a port already in use */ 569 570 #ifndef SO_PASSCRED /* Used for passing credentials. Not currently in use. */ 571 #define SO_PASSCRED 16 /* Enable passing local user credentials */ 572 #define SO_PEERCRED 17 /* Obtain the process, user and group ids of the other end of the socket connection */ 573 #define SO_RCVLOWAT 18 /* Enable receive "low water mark" */ 574 #define SO_SNDLOWAT 19 /* Enable send "low water mark" */ 575 #define SO_RCVTIMEO 20 /* Enable receive timeout */ 576 #define SO_SNDTIMEO 21 /* Enable send timeout */ 577 #endif /* SO_PASSCRED */ 578 #define SO_SNDBUFFORCE 22 /* Enable setting trasnmit buffer size overriding user limit (admin privelege) */ 579 #define SO_RCVBUFFORCE 23 /* Enable setting trasnmit buffer size overriding user limit (admin privelege) */ 580 #define SO_MAX SO_RCVBUFFORCE /* Maximum Socket option ID */ 581 582 /* This second set of socket options take the socket level (category) IPPROTO_IP. */ 583 584 #define IP_MULTICAST_IF 27 /* Specify outgoing multicast interface */ 585 #define IP_MULTICAST_TTL 28 /* Specify the TTL value to use for outgoing multicast packet. */ 586 #define IP_MULTICAST_LOOP 29 /* Whether or not receive the outgoing multicast packet, loopbacloopbackk mode. */ 587 #define IP_BLOCK_SOURCE 30 /* Block multicast from certain source. */ 588 #define IP_UNBLOCK_SOURCE 31 /* Unblock multicast from certain source. */ 589 #define IP_ADD_MEMBERSHIP 32 /* Join IPv4 multicast membership */ 590 #define IP_DROP_MEMBERSHIP 33 /* Leave IPv4 multicast membership */ 591 #define IP_HDRINCL 34 /* Raw socket IPv4 header included. */ 592 #define IP_RAW_RX_NO_HEADER 35 /* NetX proprietary socket option that does not include 593 IPv4/IPv6 header (and extension headers) on received raw sockets.*/ 594 #define IP_RAW_IPV6_HDRINCL 36 /* Transmitted buffer over IPv6 socket contains IPv6 header. */ 595 #define IP_OPTION_MAX IP_RAW_IPV6_HDRINCL 596 597 598 599 /* 600 * User-settable options (used with setsockopt). 601 */ 602 #define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */ 603 #define TCP_MAXSEG 0x02 /* set maximum segment size */ 604 #define TCP_NOPUSH 0x04 /* don't push last block of write */ 605 #define TCP_NOOPT 0x08 /* don't use TCP options */ 606 607 608 /* Define data types used in structure timeval. */ 609 610 #if defined(__CCRX__) || defined(NX_BSD_ENABLE_NATIVE_API) 611 typedef LONG nx_bsd_time_t; 612 #endif /* __CCRX__ || NX_BSD_ENABLE_NATIVE_API */ 613 typedef LONG nx_bsd_suseconds_t; 614 615 #ifndef __SES_ARM 616 struct nx_bsd_timeval 617 { 618 nx_bsd_time_t tv_sec; /* Seconds */ 619 nx_bsd_suseconds_t 620 tv_usec; /* Microseconds */ 621 }; 622 #endif /* __SES_ARM */ 623 624 struct nx_bsd_sockaddr_storage 625 { 626 USHORT ss_len; 627 USHORT ss_family; 628 }; 629 630 struct nx_bsd_sockaddr 631 { 632 USHORT sa_family; /* Address family (e.g. , AF_INET). */ 633 UCHAR sa_data[14]; /* Protocol- specific address information. */ 634 }; 635 636 struct nx_bsd_in6_addr 637 { 638 union 639 { 640 UCHAR _S6_u8[16]; 641 ULONG _S6_u32[4]; 642 } _S6_un; 643 }; 644 645 #define s6_addr _S6_un._S6_u8 646 #define s6_addr32 _S6_un._S6_u32 647 648 struct nx_bsd_sockaddr_in6 649 { 650 USHORT sin6_family; /* AF_INET6 */ 651 USHORT sin6_port; /* Transport layer port. */ 652 ULONG sin6_flowinfo; /* IPv6 flow information. */ 653 struct nx_bsd_in6_addr 654 sin6_addr; /* IPv6 address. */ 655 ULONG sin6_scope_id; /* set of interafces for a scope. */ 656 657 }; 658 659 /* Internet address (a structure for historical reasons). */ 660 661 struct nx_bsd_in_addr 662 { 663 ULONG s_addr; /* Internet address (32 bits). */ 664 }; 665 666 typedef ULONG nx_bsd_in_addr_t; 667 typedef ULONG nx_bsd_socklen_t; 668 669 670 671 /* Socket address, Internet style. */ 672 673 struct nx_bsd_sockaddr_in 674 { 675 USHORT sin_family; /* Internet Protocol (AF_INET). */ 676 USHORT sin_port; /* Address port (16 bits). */ 677 struct nx_bsd_in_addr 678 sin_addr; /* Internet address (32 bits). */ 679 CHAR sin_zero[8]; /* Not used. */ 680 }; 681 682 683 684 typedef struct FD_SET_STRUCT /* The select socket array manager. */ 685 { 686 INT fd_count; /* How many are SET? */ 687 ULONG fd_array[(NX_BSD_MAX_SOCKETS + 31)/32]; /* Bit map of SOCKET Descriptors. */ 688 } nx_bsd_fd_set; 689 690 691 692 typedef struct NX_BSD_SOCKET_SUSPEND_STRUCT 693 { 694 ULONG nx_bsd_socket_suspend_actual_flags; 695 nx_bsd_fd_set nx_bsd_socket_suspend_read_fd_set; 696 nx_bsd_fd_set nx_bsd_socket_suspend_write_fd_set; 697 nx_bsd_fd_set nx_bsd_socket_suspend_exception_fd_set; 698 699 } NX_BSD_SOCKET_SUSPEND; 700 701 702 struct nx_bsd_ip_mreq 703 { 704 struct nx_bsd_in_addr 705 imr_multiaddr; /* The IPv4 multicast address to join. */ 706 struct nx_bsd_in_addr 707 imr_interface; /* The interface to use for this group. */ 708 }; 709 710 711 /* Define additional BSD data structures for supporting socket options. */ 712 713 struct nx_bsd_sock_errno 714 { 715 INT error; /* default = 0; */ 716 }; 717 718 struct nx_bsd_linger 719 { 720 INT l_onoff; /* 0 = disabled; 1 = enabled; default = 0;*/ 721 INT l_linger; /* linger time in seconds; default = 0;*/ 722 }; 723 724 struct nx_bsd_sock_keepalive 725 { 726 INT keepalive_enabled; /* 0 = disabled; 1 = enabled; default = 0;*/ 727 }; 728 729 struct nx_bsd_sock_reuseaddr 730 { 731 INT reuseaddr_enabled; /* 0 = disabled; 1 = enabled; default = 1; */ 732 }; 733 734 struct nx_bsd_sock_winsize 735 { 736 INT winsize; /* receive window size for TCP sockets ; */ 737 }; 738 739 /* Define an union struct for master ID and secondary ID used in NX_BSD_SOCKET_STRUCT. */ 740 union UNION_ID 741 { 742 INT nx_bsd_socket_master_socket_id; 743 INT nx_bsd_socket_secondary_socket_id; 744 }; 745 746 747 struct nx_bsd_addrinfo 748 { 749 INT ai_flags; 750 INT ai_family; 751 INT ai_socktype; 752 INT ai_protocol; 753 nx_bsd_socklen_t ai_addrlen; 754 struct nx_bsd_sockaddr *ai_addr; 755 CHAR *ai_canonname; 756 struct nx_bsd_addrinfo 757 *ai_next; 758 }; 759 760 struct NX_BSD_SERVICE_LIST 761 { 762 CHAR *service_name; 763 USHORT service_port; 764 INT service_socktype; 765 INT service_protocol; 766 }; 767 768 /* Define the Errors return by getaddrinfo. */ 769 770 /* The specified host doesn't have addresses in the specified address family. */ 771 #define EAI_ADDRFAMILY 40 772 /* Name server temporary failure. */ 773 #define EAI_AGAIN 41 774 /* hints.si_flags contains invalid flag. */ 775 #define EAI_BADFLAGS 42 776 /* DNS fail. */ 777 #define EAI_FAIL 43 778 /* Invalid address family. */ 779 #define EAI_FAMILY 44 780 /* memory failure. */ 781 #define EAI_MEMORY 45 782 /* host exsits, but doesn't have address in specified family. */ 783 #define EAI_NODATA 46 784 #define EAI_NONAME 47 785 /* service not available for the specified socket type. */ 786 #define EAI_SERVICE 48 787 #define EAI_OVERFLOW 49 788 /* invalid socktype. */ 789 #define EAI_SOCKTYPE 50 790 #define EAI_SYSTEM 51 791 792 793 /* Define ai_flags value. */ 794 #define AI_PASSIVE 0x0001 795 /* request CNAME. */ 796 #define AI_CANONNAME 0x0002 797 /* host must be a address string. */ 798 #define AI_NUMERICHOST 0x0004 799 /* service must be a port string. */ 800 #define AI_NUMERICSERV 0x0008 801 #define AI_V4MAPPED 0x0010 802 #define AI_ALL 0x0020 803 #define AI_ADDRCONFIG 0x0040 804 805 /* Return numeric string for hostname. */ 806 #define NI_NUMERICHOST 0x0001 807 /* Return numeric string for service name. */ 808 #define NI_NUMERICSERV 0x0002 809 /* Return only hostname portion of FQDN. */ 810 #define NI_NOFQDN 0x0004 811 /* Return error if name can't be resolved from address. */ 812 #define NI_NAMEREQD 0x0008 813 /* Datagram service. */ 814 #define NI_DGRAM 0x0010 815 816 817 /* Define the struct used by poll. */ 818 struct nx_bsd_pollfd 819 { 820 INT fd; /* file descriptor. */ 821 SHORT events; /* requested events. */ 822 SHORT revents; /* returned events. */ 823 }; 824 825 /* Define the options used by poll. */ 826 827 #define POLLRDNORM 0x0100 828 #define POLLRDBAND 0x0200 /* Not supported. */ 829 #define POLLIN (POLLRDNORM) 830 #define POLLPRI 0x0400 831 832 #define POLLWRNORM 0x0010 833 #define POLLOUT (POLLWRNORM) 834 #define POLLWRBAND 0x0020 /* Not supported. */ 835 836 #define POLLERR 0x0001 837 #define POLLHUP 0x0002 838 #define POLLNVAL 0x0004 839 840 841 /* Defines maximum IPv4 addresses for getaddrinfo. */ 842 #ifndef NX_BSD_IPV4_ADDR_MAX_NUM 843 #define NX_BSD_IPV4_ADDR_MAX_NUM 5 844 #endif /* NX_BSD_IPV4_ADDR_MAX_NUM */ 845 846 /* Defines maximum IPv6 addresses for getaddrinfo. */ 847 #ifndef NX_BSD_IPV6_ADDR_MAX_NUM 848 #define NX_BSD_IPV6_ADDR_MAX_NUM 5 849 #endif /* NX_BSD_IPV6_ADDR_MAX_NUM */ 850 851 /* Defines maximum IPv4 addresses stored from DNS. */ 852 #ifndef NX_BSD_IPV4_ADDR_PER_HOST 853 #define NX_BSD_IPV4_ADDR_PER_HOST 5 854 #endif /* NX_BSD_IPV4_ADDR_PER_HOST */ 855 856 /* Defines maximum IPv6 addresses stored from DNS. */ 857 #ifndef NX_BSD_IPV6_ADDR_PER_HOST 858 #define NX_BSD_IPV6_ADDR_PER_HOST 2 859 #endif /* NX_BSD_IPV6_ADDR_PER_HOST */ 860 861 /* Define the BSD socket status bits. */ 862 #define NX_BSD_SOCKET_CONNECTION_INPROGRESS 1 863 #define NX_BSD_SOCKET_ERROR (1 << 1) 864 #define NX_BSD_SOCKET_CONNECTED (1 << 2) 865 /* Disconnected from the stack. */ 866 #define NX_BSD_SOCKET_DISCONNECT_FROM_STACK (1 << 3) 867 #define NX_BSD_SOCKET_SERVER_MASTER_SOCKET (1 << 4) 868 #define NX_BSD_SOCKET_SERVER_SECONDARY_SOCKET (1 << 5) 869 #define NX_BSD_SOCKET_TX_HDR_INCLUDE (1 << 6) 870 #define NX_BSD_SOCKET_RX_NO_HDR (1 << 7) 871 #define NX_BSD_SOCKET_IN_USE (1 << 8) 872 #define NX_BSD_SOCKET_CLIENT (1 << 9) 873 #define NX_BSD_SOCKET_ENABLE_LISTEN (1 << 10) 874 #define NX_BSD_SOCKET_BOUND (1 << 11) 875 #define NX_BSD_SOCKET_ACCEPTING (1 << 12) 876 #define NX_BSD_SOCKET_CONNECTION_REQUEST (1 << 13) 877 #define NX_BSD_SOCKET_DISCONNECTION_REQUEST (1 << 14) 878 879 /* Define the BSD socket options bits. */ 880 #define NX_BSD_SOCKET_ENABLE_RAW_SOCKET 1 881 #define NX_BSD_SOCKET_ENABLE_OPTION_LINGER (1 << 1) 882 #define NX_BSD_SOCKET_ENABLE_OPTION_REUSEADDR (1 << 2) 883 #define NX_BSD_SOCKET_ENABLE_OPTION_NON_BLOCKING (1 << 3) 884 885 /* Define the internal management structure for the BSD layer. */ 886 887 typedef struct NX_BSD_SOCKET_STRUCT 888 { 889 NX_TCP_SOCKET *nx_bsd_socket_tcp_socket; 890 NX_UDP_SOCKET *nx_bsd_socket_udp_socket; 891 ULONG nx_bsd_socket_family; 892 /* Store the protocol number. For example TCP is 6, UDP is 17. For raw socket 893 it is the protocol it wishes to receive. */ 894 USHORT nx_bsd_socket_protocol; 895 TX_THREAD *nx_bsd_socket_busy; 896 union UNION_ID nx_bsd_socket_union_id; 897 NX_PACKET* nx_bsd_socket_received_packet; 898 NX_PACKET* nx_bsd_socket_received_packet_tail; 899 UINT nx_bsd_socket_received_byte_count; 900 UINT nx_bsd_socket_received_byte_count_max; 901 UINT nx_bsd_socket_received_packet_count; 902 UINT nx_bsd_socket_received_packet_count_max; 903 ULONG nx_bsd_socket_received_packet_offset; 904 INT nx_bsd_socket_source_port; 905 ULONG nx_bsd_socket_local_bind_interface; 906 UINT nx_bsd_socket_local_bind_interface_index; 907 NXD_ADDRESS nx_bsd_socket_source_ip_address; 908 NXD_ADDRESS nx_bsd_socket_peer_ip; 909 910 /* For TCP/UDP, the local port is the port number this socket receives on. 911 For raw socket this field is not used. */ 912 USHORT nx_bsd_socket_local_port; 913 USHORT nx_bsd_socket_peer_port; 914 INT nx_bsd_option_linger_time; 915 UINT nx_bsd_option_linger_time_closed; 916 UINT nx_bsd_option_linger_start_close; 917 UINT nx_bsd_socket_time_wait_remaining; 918 ULONG nx_bsd_option_receive_timeout; 919 ULONG nx_bsd_option_send_timeout; 920 INT nx_bsd_file_descriptor_flags; 921 ULONG nx_bsd_socket_status_flags; 922 ULONG nx_bsd_socket_option_flags; 923 int nx_bsd_socket_error_code; 924 925 struct NX_BSD_SOCKET_STRUCT 926 *nx_bsd_socket_next; 927 struct NX_BSD_SOCKET_STRUCT 928 *nx_bsd_socket_previous; 929 930 INT nx_bsd_socket_id; 931 #ifdef NX_BSD_RAW_PPPOE_SUPPORT 932 UINT nx_bsd_socket_create_id; 933 #endif /* NX_BSD_RAW_PPPOE_SUPPORT */ 934 #if defined(NX_BSD_RAW_SUPPORT) || defined(NX_BSD_RAW_PPPOE_SUPPORT) 935 UCHAR nx_bsd_socket_sll_addr[6]; 936 USHORT nx_bsd_socket_sll_protocol; 937 INT nx_bsd_socket_sll_ifindex; 938 #endif /* defined(NX_BSD_RAW_SUPPORT) || defined(NX_BSD_RAW_PPPOE_SUPPORT) */ 939 940 } NX_BSD_SOCKET; 941 942 943 /* Define the BSD function prototypes for use by the application. */ 944 945 946 INT nx_bsd_accept(INT sockID, struct nx_bsd_sockaddr *ClientAddress, INT *addressLength); 947 INT nx_bsd_initialize(NX_IP *default_ip, NX_PACKET_POOL *default_pool, CHAR *bsd_thread_stack_area, ULONG bsd_thread_stack_size, UINT bsd_thread_priority); 948 INT nx_bsd_bind(INT sockID, const struct nx_bsd_sockaddr *localAddress, INT addressLength); 949 INT nx_bsd_connect(INT sockID, struct nx_bsd_sockaddr *remoteAddress, INT addressLength); 950 INT nx_bsd_getpeername(INT sockID, struct nx_bsd_sockaddr *remoteAddress, INT *addressLength); 951 INT nx_bsd_getsockname(INT sockID, struct nx_bsd_sockaddr *localAddress, INT *addressLength); 952 INT nx_bsd_ioctl(INT sockID, INT command, INT *result); 953 nx_bsd_in_addr_t nx_bsd_inet_addr(const CHAR *buffer); 954 CHAR *nx_bsd_inet_ntoa(struct nx_bsd_in_addr address_to_convert); 955 INT nx_bsd_inet_aton(const CHAR *cp_arg, struct nx_bsd_in_addr *addr); 956 INT nx_bsd_inet_pton(INT af, const CHAR *src, VOID *dst); 957 const CHAR *nx_bsd_inet_ntop(INT af, const VOID *src, CHAR *dst, nx_bsd_socklen_t size); 958 INT nx_bsd_listen(INT sockID, INT backlog); 959 #ifdef NX_ENABLE_IP_RAW_PACKET_FILTER 960 UINT nx_bsd_raw_packet_receive(NX_BSD_SOCKET *bsd_socket_ptr, NX_PACKET **packet_ptr); 961 UINT nx_bsd_raw_packet_info_extract(NX_PACKET *packet_ptr, NXD_ADDRESS *nxd_address, UINT *interface_index); 962 VOID nx_bsd_raw_receive_notify(NX_IP *ip_ptr, UINT bsd_socket_index); 963 #endif 964 UINT nx_bsd_socket_set_inherited_settings(UINT master_sock_id, UINT secondary_sock_id); 965 INT nx_bsd_recvfrom(INT sockID, CHAR *buffer, INT buffersize, INT flags,struct nx_bsd_sockaddr *fromAddr, INT *fromAddrLen); 966 INT nx_bsd_recv(INT sockID, VOID *rcvBuffer, INT bufferLength, INT flags); 967 INT nx_bsd_sendto(INT sockID, CHAR *msg, INT msgLength, INT flags, struct nx_bsd_sockaddr *destAddr, INT destAddrLen); 968 INT nx_bsd_send(INT sockID, const CHAR *msg, INT msgLength, INT flags); 969 INT nx_bsd_select(INT nfds, nx_bsd_fd_set *readfds, nx_bsd_fd_set *writefds, nx_bsd_fd_set *exceptfds, struct nx_bsd_timeval *timeout); 970 INT nx_bsd_soc_close( INT sockID); 971 INT nx_bsd_socket(INT protocolFamily, INT type, INT protocol); 972 INT nx_bsd_fcntl(INT sock_ID, UINT flag_type, UINT f_options); 973 INT nx_bsd_getsockopt(INT sockID, INT option_level, INT option_name, VOID *option_value, INT *option_length); 974 INT nx_bsd_setsockopt(INT sockID, INT option_level, INT option_name, const VOID *option_value, INT option_length); 975 INT nx_bsd_getaddrinfo(const CHAR *node, const CHAR *service, const struct nx_bsd_addrinfo *hints, struct nx_bsd_addrinfo **res); 976 VOID nx_bsd_freeaddrinfo(struct nx_bsd_addrinfo *res); 977 INT nx_bsd_getnameinfo(const struct nx_bsd_sockaddr *sa, nx_bsd_socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags); 978 VOID nx_bsd_set_service_list(struct NX_BSD_SERVICE_LIST *serv_list_ptr, ULONG serv_list_len); 979 INT nx_bsd_poll(struct nx_bsd_pollfd *fds, ULONG nfds, INT timeout); 980 981 #if !defined(NX_BSD_ENABLE_NATIVE_API) 982 #undef FD_SET 983 #undef FD_CLR 984 #undef FD_ISSET 985 #undef FD_ZERO 986 #endif 987 988 VOID NX_BSD_FD_SET(INT fd, nx_bsd_fd_set *fdset); 989 VOID NX_BSD_FD_CLR(INT fd, nx_bsd_fd_set *fdset); 990 INT NX_BSD_FD_ISSET(INT fd, nx_bsd_fd_set *fdset); 991 VOID NX_BSD_FD_ZERO(nx_bsd_fd_set *fdset); 992 VOID nx_bsd_set_errno(INT tx_errno); 993 994 INT _nxd_get_errno(VOID); 995 996 #if !defined(NX_BSD_ENABLE_NATIVE_API) 997 #define errno (tx_thread_identify() -> bsd_errno) 998 #else 999 #define nx_bsd_errno (tx_thread_identify() -> bsd_errno) 1000 #endif 1001 1002 1003 #ifdef NX_BSD_RAW_PPPOE_SUPPORT 1004 1005 #define ETHERTYPE_PPPOE_DISC 0x8863 /* PPPoE Discovery protocol type */ 1006 #define ETHERTYPE_PPPOE_SESS 0x8864 /* PPPoE Session Protocol type */ 1007 1008 #define NX_LINK_PACKET_PPPOE_SESS_SEND ETHERTYPE_PPPOE_SESS 1009 #define NX_LINK_PACKET_PPPOE_DISC_SEND ETHERTYPE_PPPOE_DISC 1010 1011 1012 UINT _nx_bsd_pppoe_packet_received(NX_PACKET *packet_ptr, UINT frame_type, UINT interface_id); 1013 #endif /* NX_BSD_RAW_PPPOE_SUPPORT */ 1014 1015 #if defined(NX_BSD_RAW_SUPPORT) || defined(NX_BSD_RAW_PPPOE_SUPPORT) 1016 /* Link Layer Socket Addressing */ 1017 struct nx_bsd_sockaddr_ll 1018 { 1019 USHORT sll_family; /* Address Family. Must be AF_PACKET */ 1020 USHORT sll_protocol; /* LL frame type */ 1021 INT sll_ifindex; /* Interface Index. */ 1022 USHORT sll_hatype; /* Header type */ 1023 UCHAR sll_pkttype; /* Packet type */ 1024 UCHAR sll_halen; /* Length of address */ 1025 UCHAR sll_addr[8]; /* Physical layer address */ 1026 }; 1027 #endif /* defined(NX_BSD_RAW_SUPPORT) || defined(NX_BSD_RAW_PPPOE_SUPPORT) */ 1028 1029 #ifdef NX_BSD_RAW_SUPPORT 1030 extern UINT _nx_driver_hardware_packet_send(NX_PACKET *packet_ptr); /* Send hardware packet. */ 1031 extern VOID (*_nx_driver_hardware_packet_received_callback)(NX_PACKET *packet_ptr, UCHAR *consumed);/* Callback function pointer when packet is received. */ 1032 #endif /* NX_BSD_RAW_SUPPORT */ 1033 1034 1035 /* Determine if a C++ compiler is being used. If so, complete the standard 1036 C conditional started above. */ 1037 #ifdef __cplusplus 1038 } 1039 #endif 1040 1041 #endif /* NXD_BSD_H */ 1042 1043