提交 2c0fd387 编写于 作者: A Arnaldo Carvalho de Melo 提交者: David S. Miller

[SCTP]: Introduce sctp_hdr()

For consistency with all the other skb->h.raw accessors.
Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 967b05f6
...@@ -63,6 +63,15 @@ typedef struct sctphdr { ...@@ -63,6 +63,15 @@ typedef struct sctphdr {
__be32 checksum; __be32 checksum;
} __attribute__((packed)) sctp_sctphdr_t; } __attribute__((packed)) sctp_sctphdr_t;
#ifdef __KERNEL__
#include <linux/skbuff.h>
static inline struct sctphdr *sctp_hdr(const struct sk_buff *skb)
{
return (struct sctphdr *)skb->h.raw;
}
#endif
/* Section 3.2. Chunk Field Descriptions. */ /* Section 3.2. Chunk Field Descriptions. */
typedef struct sctp_chunkhdr { typedef struct sctp_chunkhdr {
__u8 type; __u8 type;
......
...@@ -79,14 +79,10 @@ static void sctp_add_backlog(struct sock *sk, struct sk_buff *skb); ...@@ -79,14 +79,10 @@ static void sctp_add_backlog(struct sock *sk, struct sk_buff *skb);
/* Calculate the SCTP checksum of an SCTP packet. */ /* Calculate the SCTP checksum of an SCTP packet. */
static inline int sctp_rcv_checksum(struct sk_buff *skb) static inline int sctp_rcv_checksum(struct sk_buff *skb)
{ {
struct sctphdr *sh;
__u32 cmp, val;
struct sk_buff *list = skb_shinfo(skb)->frag_list; struct sk_buff *list = skb_shinfo(skb)->frag_list;
struct sctphdr *sh = sctp_hdr(skb);
sh = (struct sctphdr *) skb->h.raw; __u32 cmp = ntohl(sh->checksum);
cmp = ntohl(sh->checksum); __u32 val = sctp_start_cksum((__u8 *)sh, skb_headlen(skb));
val = sctp_start_cksum((__u8 *)sh, skb_headlen(skb));
for (; list; list = list->next) for (; list; list = list->next)
val = sctp_update_cksum((__u8 *)list->data, skb_headlen(list), val = sctp_update_cksum((__u8 *)list->data, skb_headlen(list),
...@@ -138,7 +134,7 @@ int sctp_rcv(struct sk_buff *skb) ...@@ -138,7 +134,7 @@ int sctp_rcv(struct sk_buff *skb)
if (skb_linearize(skb)) if (skb_linearize(skb))
goto discard_it; goto discard_it;
sh = (struct sctphdr *) skb->h.raw; sh = sctp_hdr(skb);
/* Pull up the IP and SCTP headers. */ /* Pull up the IP and SCTP headers. */
__skb_pull(skb, skb_transport_offset(skb)); __skb_pull(skb, skb_transport_offset(skb));
...@@ -905,7 +901,7 @@ static struct sctp_association *__sctp_rcv_init_lookup(struct sk_buff *skb, ...@@ -905,7 +901,7 @@ static struct sctp_association *__sctp_rcv_init_lookup(struct sk_buff *skb,
struct sctp_association *asoc; struct sctp_association *asoc;
union sctp_addr addr; union sctp_addr addr;
union sctp_addr *paddr = &addr; union sctp_addr *paddr = &addr;
struct sctphdr *sh = (struct sctphdr *) skb->h.raw; struct sctphdr *sh = sctp_hdr(skb);
sctp_chunkhdr_t *ch; sctp_chunkhdr_t *ch;
union sctp_params params; union sctp_params params;
sctp_init_chunk_t *init; sctp_init_chunk_t *init;
......
...@@ -390,7 +390,7 @@ static void sctp_v6_from_skb(union sctp_addr *addr,struct sk_buff *skb, ...@@ -390,7 +390,7 @@ static void sctp_v6_from_skb(union sctp_addr *addr,struct sk_buff *skb,
addr->v6.sin6_flowinfo = 0; /* FIXME */ addr->v6.sin6_flowinfo = 0; /* FIXME */
addr->v6.sin6_scope_id = ((struct inet6_skb_parm *)skb->cb)->iif; addr->v6.sin6_scope_id = ((struct inet6_skb_parm *)skb->cb)->iif;
sh = (struct sctphdr *) skb->h.raw; sh = sctp_hdr(skb);
if (is_saddr) { if (is_saddr) {
*port = sh->source; *port = sh->source;
from = &ipv6_hdr(skb)->saddr; from = &ipv6_hdr(skb)->saddr;
...@@ -765,7 +765,7 @@ static void sctp_inet6_skb_msgname(struct sk_buff *skb, char *msgname, ...@@ -765,7 +765,7 @@ static void sctp_inet6_skb_msgname(struct sk_buff *skb, char *msgname,
if (msgname) { if (msgname) {
sctp_inet6_msgname(msgname, addr_len); sctp_inet6_msgname(msgname, addr_len);
sin6 = (struct sockaddr_in6 *)msgname; sin6 = (struct sockaddr_in6 *)msgname;
sh = (struct sctphdr *)skb->h.raw; sh = sctp_hdr(skb);
sin6->sin6_port = sh->source; sin6->sin6_port = sh->source;
/* Map ipv4 address into v4-mapped-on-v6 address. */ /* Map ipv4 address into v4-mapped-on-v6 address. */
......
...@@ -235,7 +235,7 @@ static void sctp_v4_from_skb(union sctp_addr *addr, struct sk_buff *skb, ...@@ -235,7 +235,7 @@ static void sctp_v4_from_skb(union sctp_addr *addr, struct sk_buff *skb,
port = &addr->v4.sin_port; port = &addr->v4.sin_port;
addr->v4.sin_family = AF_INET; addr->v4.sin_family = AF_INET;
sh = (struct sctphdr *) skb->h.raw; sh = sctp_hdr(skb);
if (is_saddr) { if (is_saddr) {
*port = sh->source; *port = sh->source;
from = &ip_hdr(skb)->saddr; from = &ip_hdr(skb)->saddr;
...@@ -731,13 +731,11 @@ static void sctp_inet_event_msgname(struct sctp_ulpevent *event, char *msgname, ...@@ -731,13 +731,11 @@ static void sctp_inet_event_msgname(struct sctp_ulpevent *event, char *msgname,
/* Initialize and copy out a msgname from an inbound skb. */ /* Initialize and copy out a msgname from an inbound skb. */
static void sctp_inet_skb_msgname(struct sk_buff *skb, char *msgname, int *len) static void sctp_inet_skb_msgname(struct sk_buff *skb, char *msgname, int *len)
{ {
struct sctphdr *sh;
struct sockaddr_in *sin;
if (msgname) { if (msgname) {
struct sctphdr *sh = sctp_hdr(skb);
struct sockaddr_in *sin = (struct sockaddr_in *)msgname;
sctp_inet_msgname(msgname, len); sctp_inet_msgname(msgname, len);
sin = (struct sockaddr_in *)msgname;
sh = (struct sctphdr *)skb->h.raw;
sin->sin_port = sh->source; sin->sin_port = sh->source;
sin->sin_addr.s_addr = ip_hdr(skb)->saddr; sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册