Пример #1
0
NMErr
NMAcceptConnection(
    NMEndpointRef				inEndpoint,
    void						*inCookie,
    NMEndpointCallbackFunction	*inCallback,
    void						*inContext)
{
    DEBUG_ENTRY_EXIT("NMAcceptConnection");

    NMErr				status = kNMNoError;
    NMIPEndpointPriv	*epRef;
    Endpoint			*ep;
    NMIPEndpointPriv	*newEPRef;

    op_vassert_return((inEndpoint != NULL),"Endpoint is NIL!",kNMParameterErr);
    op_vassert_return((inCookie != NULL),"Cookie is NIL!",kNMParameterErr);
    op_vassert_return((inCallback != NULL),"Callback function is NIL!",kNMParameterErr);

    epRef = (NMIPEndpointPriv *) inEndpoint;
    ep = epRef->ep;

    op_vassert_return((ep != NULL),"Private endpoint is NIL!",kNMParameterErr);
    op_vassert_return((epRef->id == kModuleID),"Endpoint id is not mine!",kNMParameterErr);

    // First, we need to create a new endpoint that will be returned to the user
    status = MakeNewIPEndpointPriv(NULL, inCallback, inContext, ep->mMode, ep->mNetSprocketMode, &newEPRef);

    if( !status )
        status = ep->AcceptConnection(newEPRef->ep, inCookie);	// Hands off the new connection async

    return (status);
}