+ nDescs = 0;
+ for( int id = -1; -1 != (id = IPStack_Buffer_GetBuffer(Buffer, id, &len, &data)); )
+ {
+ if( ((tVAddr)data & (PAGE_SIZE-1)) + len > PAGE_SIZE )
+ nDescs ++;
+ nDescs ++;
+ }
+ if( nDescs == 0 ) {
+ LEAVE('i', -1);
+ return -1;
+ }
+
+ LOG("%i descriptors needed", nDescs);
+
+ if( card->nFreeTX < nDescs ) {
+ // Oops... wait?
+ // TODO: Semaphore instead?
+ LEAVE('i', 1);
+ return 1;
+ }
+
+ first_desc_id = card->NextTX;
+ card->NextTX = (card->NextTX + nDescs) % N_TX_DESCS;
+
+ desc = card->TXDescs + first_desc_id;
+
+ nDescs = 0;