| 136 | } |
| 137 | |
| 138 | static void |
| 139 | process_accept(int ret, int sockfd, struct sockaddr *addr, socklen_t *addrlen) |
| 140 | { |
| 141 | JASSERT(ret != -1); |
| 142 | Connection *parent = SocketConnList::instance().getConnection(sockfd); |
| 143 | if (parent == NULL) { |
| 144 | JTRACE("unable to get the connection."); |
| 145 | return; |
| 146 | } |
| 147 | |
| 148 | SocketConnection *con = NULL; |
| 149 | |
| 150 | // FIXME: Checking for conType is ugly; fix class design |
| 151 | if (parent->conType() == Connection::TCP) { |
| 152 | TcpConnection *tcpParent = dynamic_cast<TcpConnection *>(parent); |
| 153 | con = new TcpConnection(*tcpParent, ConnectionIdentifier::null()); |
| 154 | } else if (parent->conType() == Connection::RAW) { |
| 155 | RawSocketConnection *rawSockParent = |
| 156 | dynamic_cast<RawSocketConnection *>(parent); |
| 157 | con = new RawSocketConnection(*rawSockParent, ConnectionIdentifier::null()); |
| 158 | } |
| 159 | |
| 160 | if (con == NULL) { |
| 161 | JTRACE("accept operation on unsupported socket type."); |
| 162 | return; |
| 163 | } else { |
| 164 | SocketConnList::instance().add(ret, dynamic_cast<Connection *>(con)); |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | extern "C" int |
| 169 | accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen) |
no test coverage detected