📄 ans_os.c
字号:
* how many protocols, so it seems like this wouldn't be a very good idea... */ BD_ANS_BCOPY((UCHAR *)&piANSdata->prev_status, (UCHAR *)¤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 count; UCHAR *from; UCHAR *to; peth_vlan_header_t peth_vlan_header; struct sk_buff *new_skb; DEBUGLOG("bd_ans_os_InsertQtagSW: enter\n"); /* 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 = iANSGetReceiveAttributeHeader(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){ skb_reserve(skb, BD_ANS_INFO_SIZE);} BD_ANS_STATUS bd_ans_os_ProcessRequest(BOARD_PRIVATE_STRUCT *bps, iANSsupport_t *iANSdata, IANS_BD_PARAM_HEADER *header){ switch (header->Opcode) { case IANS_OP_ANS_SET_CB: DEBUGLOG("bd_ans_ProcessRequest: ans set callbacks\n"); return (bd_ans_os_SetCallback(bps, header)); default: DEBUGLOG1("bd_ans_os_ProcessRequest: unknown op code = %d\n", header->Opcode); return (BD_ANS_FAILURE); }}BD_ANS_STATUS bd_ans_os_ExtendedGetCapability(BOARD_PRIVATE_STRUCT *bps, iANSsupport_t *iANSdata, IANS_BD_PARAM_HEADER *header){ ((IANS_BD_PARAM_EXT_CAP *)header)->BDAllAvailableRouting = IANS_ROUTING_NOT_SUPPORTED; /* get routing capabilities */ if (BD_ANS_OS_CAN_ROUTE_RX(bps) == BD_ANS_TRUE) { ((IANS_BD_PARAM_EXT_CAP *)header)->BDAllAvailableRouting |= IANS_ROUTING_RX_PROTOCOL; } ((IANS_BD_PARAM_EXT_CAP *)header)->BDFlags = iANSdata->flags.bd_flags; return BD_ANS_SUCCESS; }BD_ANS_STATUS bd_ans_os_ExtendedSetMode(BOARD_PRIVATE_STRUCT *bps, iANSsupport_t *iANSdata, IANS_BD_PARAM_HEADER *header){ IANS_BD_PARAM_EXT_SET_MODE *request = (IANS_BD_PARAM_EXT_SET_MODE *)header; if (request->BDIansRoutingMode & IANS_ROUTING_RX_PROTOCOL) iANSdata->routing_mode = IANS_ROUTING_ON; else iANSdata->routing_mode = IANS_ROUTING_OFF; return BD_ANS_SUCCESS;}BD_ANS_STATUS bd_ans_os_ActivateFastPolling(BOARD_PRIVATE_STRUCT *bps, iANSsupport_t *iANSdata){ /* initialize the previous status with the current status so * that we don't send any bogus status change indications */ bd_ans_drv_UpdateStatus(bps); bd_ans_FillStatus(bps, iANSdata, &(iANSdata->prev_status)); /* tell the driver that we need to start checking the * status */ iANSdata->timer_id = bd_ans_drv_StartWatchdog(bps); /* a non-zero timer_id indicates that the driver has * started the Watchdog. */ if (iANSdata->timer_id == 0) return BD_ANS_FAILURE; return BD_ANS_SUCCESS; }BD_ANS_STATUS bd_ans_os_GetAllCapabilities(BOARD_PRIVATE_STRUCT *bps, iANSsupport_t *iANSdata){ iANSdata->flags.bd_flags = BD_ANS_HW_FLAGS(bps); return BD_ANS_SUCCESS;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -