Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #define DBRU_SIZE 5
  2. struct dbru_st // Unpacked DBRU structure (Upstream)
  3. {
  4. unsigned int onu_id; // unique ID of ONU
  5. unsigned int counter; // TCONT ID within that ONU
  6. unsigned int dbru; // Buffer Occupancy in Bytes, which is being requested
  7. };
  8.  
  9. // Serialise Byte DBRU into packed character stream
  10. void pack_dbru(struct dbru_st *xdbru, unsigned char res[]){
  11. res[0] = (xdbru->onu_id >> 4) & 0x3f;
  12. res[1] = ((xdbru->onu_id & 0x0f) << 4) | (xdbru->counter & 0x0f);
  13. res[2] = (xdbru->dbru >> 16) & 0xff;
  14. res[3] = (xdbru->dbru >> 8) & 0xff;
  15. res[4] = xdbru->dbru & 0xff;
  16. }
  17.  
  18. struct dbru_st dbru_tx; unsigned char stream[DBRU_SIZE];
  19. dbru_tx.onu_id=ont; dbru_tx.counter=tcont;
  20. dbru_tx.dbru=n;
  21. pack_dbru(&dbru_tx,stream);
  22. sendto(sockfd, stream, DBRU_SIZE, 0, (struct sockaddr*)&serv_addr, slen);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement