Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define DBRU_SIZE 5
- struct dbru_st // Unpacked DBRU structure (Upstream)
- {
- unsigned int onu_id; // unique ID of ONU
- unsigned int counter; // TCONT ID within that ONU
- unsigned int dbru; // Buffer Occupancy in Bytes, which is being requested
- };
- // Serialise Byte DBRU into packed character stream
- void pack_dbru(struct dbru_st *xdbru, unsigned char res[]){
- res[0] = (xdbru->onu_id >> 4) & 0x3f;
- res[1] = ((xdbru->onu_id & 0x0f) << 4) | (xdbru->counter & 0x0f);
- res[2] = (xdbru->dbru >> 16) & 0xff;
- res[3] = (xdbru->dbru >> 8) & 0xff;
- res[4] = xdbru->dbru & 0xff;
- }
- struct dbru_st dbru_tx; unsigned char stream[DBRU_SIZE];
- dbru_tx.onu_id=ont; dbru_tx.counter=tcont;
- dbru_tx.dbru=n;
- pack_dbru(&dbru_tx,stream);
- sendto(sockfd, stream, DBRU_SIZE, 0, (struct sockaddr*)&serv_addr, slen);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement