Changes in uspace/srv/net/nil/eth/eth.c [774e6d1a:797b704] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/nil/eth/eth.c
r774e6d1a r797b704 45 45 46 46 #include <ipc/ipc.h> 47 #include <ipc/nil.h> 47 48 #include <ipc/net.h> 48 49 #include <ipc/services.h> … … 56 57 #include <netif_remote.h> 57 58 #include <net_interface.h> 58 #include <nil_interface.h> 59 #include <il_interface.h> 59 #include <il_remote.h> 60 60 #include <adt/measured_strings.h> 61 61 #include <packet_client.h> 62 62 #include <packet_remote.h> 63 #include <nil_ local.h>63 #include <nil_skel.h> 64 64 65 65 #include "eth.h" 66 #include "eth_header.h"67 66 68 67 /** The module name. */ … … 72 71 #define ETH_PREFIX \ 73 72 (sizeof(eth_header_t) + sizeof(eth_header_lsap_t) + \ 74 sizeof(eth_header_snap_t))73 sizeof(eth_header_snap_t)) 75 74 76 75 /** Reserved packet suffix length. */ 77 #define ETH_SUFFIX \ 78 sizeof(eth_fcs_t) 76 #define ETH_SUFFIX (sizeof(eth_fcs_t)) 79 77 80 78 /** Maximum packet content length. */ 81 #define ETH_MAX_CONTENT 1500u79 #define ETH_MAX_CONTENT 1500u 82 80 83 81 /** Minimum packet content length. */ 84 #define ETH_MIN_CONTENT 46u82 #define ETH_MIN_CONTENT 46u 85 83 86 84 /** Maximum tagged packet content length. */ 87 85 #define ETH_MAX_TAGGED_CONTENT(flags) \ 88 86 (ETH_MAX_CONTENT - \ 89 ((IS_8023_2_LSAP(flags) || IS_8023_2_SNAP(flags)) ? \90 sizeof(eth_header_lsap_t) : 0) - \91 (IS_8023_2_SNAP(flags) ? sizeof(eth_header_snap_t) : 0))87 ((IS_8023_2_LSAP(flags) || IS_8023_2_SNAP(flags)) ? \ 88 sizeof(eth_header_lsap_t) : 0) - \ 89 (IS_8023_2_SNAP(flags) ? sizeof(eth_header_snap_t) : 0)) 92 90 93 91 /** Minimum tagged packet content length. */ 94 92 #define ETH_MIN_TAGGED_CONTENT(flags) \ 95 93 (ETH_MIN_CONTENT - \ 96 ((IS_8023_2_LSAP(flags) || IS_8023_2_SNAP(flags)) ? \97 sizeof(eth_header_lsap_t) : 0) - \98 (IS_8023_2_SNAP(flags) ? sizeof(eth_header_snap_t) : 0))94 ((IS_8023_2_LSAP(flags) || IS_8023_2_SNAP(flags)) ? \ 95 sizeof(eth_header_lsap_t) : 0) - \ 96 (IS_8023_2_SNAP(flags) ? sizeof(eth_header_snap_t) : 0)) 99 97 100 98 /** Dummy flag shift value. */ 101 #define ETH_DUMMY_SHIFT 99 #define ETH_DUMMY_SHIFT 0 102 100 103 101 /** Mode flag shift value. */ 104 #define ETH_MODE_SHIFT 102 #define ETH_MODE_SHIFT 1 105 103 106 104 /** Dummy device flag. 107 105 * Preamble and FCS are mandatory part of the packets. 108 106 */ 109 #define ETH_DUMMY 107 #define ETH_DUMMY (1 << ETH_DUMMY_SHIFT) 110 108 111 109 /** Returns the dummy flag. 112 110 * @see ETH_DUMMY 113 111 */ 114 #define IS_DUMMY(flags) 112 #define IS_DUMMY(flags) ((flags) & ETH_DUMMY) 115 113 116 114 /** Device mode flags. … … 119 117 * @see ETH_8023_2_SNAP 120 118 */ 121 #define ETH_MODE_MASK 119 #define ETH_MODE_MASK (3 << ETH_MODE_SHIFT) 122 120 123 121 /** DIX Ethernet mode flag. */ 124 #define ETH_DIX 125 126 /** Return swhether the DIX Ethernet mode flag is set.127 * 128 * @param[in] flags The ethernet flags.122 #define ETH_DIX (1 << ETH_MODE_SHIFT) 123 124 /** Return whether the DIX Ethernet mode flag is set. 125 * 126 * @param[in] flags Ethernet flags. 129 127 * @see ETH_DIX 130 */ 131 #define IS_DIX(flags) (((flags) & ETH_MODE_MASK) == ETH_DIX) 128 * 129 */ 130 #define IS_DIX(flags) (((flags) & ETH_MODE_MASK) == ETH_DIX) 132 131 133 132 /** 802.3 + 802.2 + LSAP mode flag. */ 134 #define ETH_8023_2_LSAP 135 136 /** Return swhether the 802.3 + 802.2 + LSAP mode flag is set.137 * 138 * @param[in] flags The ethernet flags.133 #define ETH_8023_2_LSAP (2 << ETH_MODE_SHIFT) 134 135 /** Return whether the 802.3 + 802.2 + LSAP mode flag is set. 136 * 137 * @param[in] flags Ethernet flags. 139 138 * @see ETH_8023_2_LSAP 140 */ 141 #define IS_8023_2_LSAP(flags) (((flags) & ETH_MODE_MASK) == ETH_8023_2_LSAP) 139 * 140 */ 141 #define IS_8023_2_LSAP(flags) (((flags) & ETH_MODE_MASK) == ETH_8023_2_LSAP) 142 142 143 143 /** 802.3 + 802.2 + LSAP + SNAP mode flag. */ 144 #define ETH_8023_2_SNAP 145 146 /** Return swhether the 802.3 + 802.2 + LSAP + SNAP mode flag is set.147 * 148 * @param[in] flags The ethernet flags.144 #define ETH_8023_2_SNAP (3 << ETH_MODE_SHIFT) 145 146 /** Return whether the 802.3 + 802.2 + LSAP + SNAP mode flag is set. 147 * 148 * @param[in] flags Ethernet flags. 149 149 * @see ETH_8023_2_SNAP 150 */ 151 #define IS_8023_2_SNAP(flags) (((flags) & ETH_MODE_MASK) == ETH_8023_2_SNAP) 150 * 151 */ 152 #define IS_8023_2_SNAP(flags) (((flags) & ETH_MODE_MASK) == ETH_8023_2_SNAP) 152 153 153 154 /** Type definition of the ethernet address type. … … 246 247 rc = packet_translate_remote(eth_globals.net_phone, 247 248 &packet, IPC_GET_PACKET(*icall)); 248 if (rc == EOK) {249 if (rc == EOK) 249 250 rc = nil_received_msg_local(0, 250 251 IPC_GET_DEVICE(*icall), packet, 0); 251 }252 252 253 ipc_answer_0(iid, (sysarg_t) rc); 253 254 break; … … 836 837 } 837 838 838 int nil_m essage_standalone(const char *name, ipc_callid_t callid,839 ipc_call_t * call, ipc_call_t *answer, size_t *answer_count)839 int nil_module_message(ipc_callid_t callid, ipc_call_t *call, 840 ipc_call_t *answer, size_t *answer_count) 840 841 { 841 842 measured_string_t *address; … … 893 894 } 894 895 895 /** Default thread for new connections.896 *897 * @param[in] iid The initial message identifier.898 * @param[in] icall The initial message call structure.899 */900 static void nil_client_connection(ipc_callid_t iid, ipc_call_t *icall)901 {902 /*903 * Accept the connection904 * - Answer the first IPC_M_CONNECT_ME_TO call.905 */906 ipc_answer_0(iid, EOK);907 908 while (true) {909 ipc_call_t answer;910 size_t count;911 912 /* Clear the answer structure */913 refresh_answer(&answer, &count);914 915 /* Fetch the next message */916 ipc_call_t call;917 ipc_callid_t callid = async_get_call(&call);918 919 /* Process the message */920 int res = nil_module_message_standalone(NAME, callid, &call,921 &answer, &count);922 923 /*924 * End if told to either by the message or the processing925 * result.926 */927 if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) ||928 (res == EHANGUP))929 return;930 931 /* Answer the message */932 answer_call(callid, res, &answer, count);933 }934 }935 936 896 int main(int argc, char *argv[]) 937 897 { 938 int rc;939 940 898 /* Start the module */ 941 rc = nil_module_start_standalone(nil_client_connection); 942 return rc; 899 return nil_module_start(SERVICE_ETHERNET); 943 900 } 944 901
Note:
See TracChangeset
for help on using the changeset viewer.