📄 ans_os.c
字号:
/* check ans communication protocol. If we are not up, there is * nothing to do. */ if ((piANSdata->iANS_status == IANS_COMMUNICATION_DOWN) || (piANSdata->reporting_mode == IANS_STATUS_REPORTING_OFF)) return; /* update the driver's status */ bd_ans_drv_UpdateStatus(bps); /* fill out the current status */ bd_ans_FillStatus(bps, ANS_PRIVATE_DATA_FIELD(bps), ¤t_status); /* compare the status to the last status update. If they are different, * we need to send an indication. */ /* Compare current status against previous one: if equal, just return */ if(BD_ANS_BCMP(&piANSdata->prev_status, ¤t_status, sizeof(IANS_BD_PARAM_STATUS)) == BD_ANS_TRUE) { return; } /* if we are here, we need to send a status change notification */ BD_ANS_BCOPY(&piANSdata->prev_status, ¤t_status, sizeof(IANS_BD_PARAM_STATUS)); DEBUGLOG("bd_ans_os_Watchdog: sending notification\n"); if (ans_notify) ans_notify(dev, IANS_IND_EXT_STATUS_CHANGE); DEBUGLOG("bd_ans_os_watchdog: done send\n"); return;} #ifdef IANS_BASE_VLAN_TAGGING /* bd_ans_os_InsertQtagSW()**** This function will insert the IEEE vlan id into the data portion of the ** packet. **** Arguments: BOARD_PRIVATE_STRUCT *bps - pointer to the boards private data** structure** struct sk_buff **skb - pointer to a pointer to the sk_buff** which describes this packet** UINT16 *vlanid - pointer to the vlan id to insert**** Returns: BD_ANS_STATUS - BD_ANS_FAILURE if a new skb needed to be ** allocated but could not, BD_ANS_SUCCESS** otherwise*/ BD_ANS_STATUSbd_ans_os_InsertQtagSW(BOARD_PRIVATE_STRUCT *bps, struct sk_buff **skb, UINT16 *vlan_id){ UINT32 frame_len; UINT32 count; UCHAR *from; UCHAR *to; peth_header_t peth_header; peth_vlan_header_t peth_vlan_header; struct sk_buff *new_skb; /* we can be guarenteed that there is headroom here because we are * blowing away the old TLV list since we don't need it anymore. */ if (skb_headroom(*skb) < sizeof(x8021Q_tag_t) ) { DEBUGLOG("bd_ans_os_InsertQtagSW: inserting vlan into headroom\n"); /* reallocate the skb */ new_skb = skb_realloc_headroom((*skb), sizeof(x8021Q_tag_t)); if (new_skb == NULL) return BD_ANS_FAILURE; /* return the old one */ dev_kfree_skb(*skb); *skb = new_skb; } /* move the da/sa out of the way */ from = (*skb)->data; to = ((UCHAR *)(*skb)->data) - sizeof(x8021Q_tag_t); for (count = 0; count < (ETHERNET_ADDRESS_LENGTH*2); count++) *to++ = *from++; /* adjust the data pointer to new spot */ skb_push(*skb,sizeof(x8021Q_tag_t)); /* insert the vlan id in the proper place */ peth_vlan_header = (peth_vlan_header_t)(*skb)->data; peth_vlan_header->Qtag.EtherType = htons(QTAG_TYPE); peth_vlan_header->Qtag.VLAN_ID = htons(*vlan_id); return BD_ANS_SUCCESS; }/* bd_ans_os_StripQtagSW()**** This routine will strip a IEEE tag out of the data area of the ** skb. We assume that the data pointer is still pointing to the** raw ethernet data (i.e. it better be!)**** Arguments: struct sk_buff *skb - pointer to the sk_buff which** describes this packet** Returns: void - you get what you asked for, no checks to see** if it is a valid vlan packet.*/voidbd_ans_os_StripQtagSW(struct sk_buff *skb){ unsigned char *to; unsigned char *from; eth_vlan_header_t *header; header = (eth_vlan_header_t *) skb->data; /* start from the last byte of the source address and copy to * the last byte of the qtag. */ from = &(header->eth_src[5]); to = from + sizeof(x8021Q_tag_t); while (from >= (unsigned char *)header) *to-- = *from--; /* reset the data to 4 bytes above what it was. */ skb_pull(skb, sizeof(x8021Q_tag_t)); }#endif/* bd_ans_os_AllocateTLV()**** This function will just set the tlv pointer to the proper place** to begin copying TLV information. Under Linux, this function** doesn't do much, it is more complex under other OS.**** struct sk_buff *frame - pointer to the sk_buff which describes** the frame to be passed up.** struct sk_buff **tlv - address of the sk_buff which will contain** the tlv info.** ** Returns: BD_ANS_SUCCESS - always succeeds for now.*/BD_ANS_BOOLEANbd_ans_os_AllocateTLV(struct sk_buff *frame, struct sk_buff **tlv){ /* since under linux we have our tlv at the head of the * frame data, we use the same sk_buff for the tlv as * the frame data and do not need to do any new allocation */ *tlv = frame; return BD_ANS_SUCCESS;}/* bd_ans_os_AttributeFill()**** This function will serve as a translation layer between the generic** attribute fill routine and the OS specific data structures. Tell** the generic routines where to fill in the TLV information.**** Arguments: iANS_Attribute_ID attr_id - the id of the attribute** struct sk_buff *skb - the skb which describes the tlv list** UINT32 prev_tlv_length - this will tell the routine how ** many bytes to skip to avoid ** writing over previous TLV information** void *data - pointer any associated values that** belong to this TLV.** Returns: UINT32 - the length of the new TLV*/ UINT32bd_ans_os_AttributeFill(iANS_Attribute_ID attr_id, struct sk_buff *skb, UINT32 prev_tlv_length, void *data){ int tlv_length = 0; Per_Frame_Attribute_Header *header; /* we need to skip any previously filled in attributes so that we * don't blow them away. */ header = iANSGetAttributeHeader(skb)->pFirstTLV; header = (Per_Frame_Attribute_Header *)(((UINT8 *)header) + prev_tlv_length); tlv_length = bd_ans_AttributeFill(attr_id, header, data); /* we don't adjust the len field because the len is in relation to the * frame data only. */ return tlv_length;} /* bd_ans_os_ReserveSpaceForANS()**** ANS requires that we have space in the skb for the following:** ** pointer to TLV list** old protocol id** TLV list with at most 2 TLVs for now** ** This function abstracts the call to skb_reserve so that if the** amount of space that needs to be reserved changes, this is ** only needed to be updated in the shared code and not in each ** individual driver.**** Arguments: struct sk_buff *skb - the sk_buff which is being** adjusted.**** Returns: void.*/ void bd_ans_os_ReserveSpaceForANS(struct sk_buff *skb){ /* (??? what is the best way to * handle this variable number of tlv's? Perhaps ANS can set this * number for us in a query or something, or as a define in the * base_comm.h file...) */ skb_reserve(skb, BD_ANS_INFO_SIZE);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -