diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2007-03-13 12:59:32 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 01:25:19 -0400 |
commit | 2c0fd387b00a6758550b5ca1aae4408374483fe7 (patch) | |
tree | e6bd255fb77d476424345c7864f6ee14cb0d1ddc | |
parent | 967b05f64e27d04a4c8879addd0e1c52137e2c9e (diff) |
[SCTP]: Introduce sctp_hdr()
For consistency with all the other skb->h.raw accessors.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/sctp.h | 9 | ||||
-rw-r--r-- | net/sctp/input.c | 14 | ||||
-rw-r--r-- | net/sctp/ipv6.c | 4 | ||||
-rw-r--r-- | net/sctp/protocol.c | 10 |
4 files changed, 20 insertions, 17 deletions
diff --git a/include/linux/sctp.h b/include/linux/sctp.h index d4f86560bfff..d76767dfe59e 100644 --- a/include/linux/sctp.h +++ b/include/linux/sctp.h | |||
@@ -63,6 +63,15 @@ typedef struct sctphdr { | |||
63 | __be32 checksum; | 63 | __be32 checksum; |
64 | } __attribute__((packed)) sctp_sctphdr_t; | 64 | } __attribute__((packed)) sctp_sctphdr_t; |
65 | 65 | ||
66 | #ifdef __KERNEL__ | ||
67 | #include <linux/skbuff.h> | ||
68 | |||
69 | static inline struct sctphdr *sctp_hdr(const struct sk_buff *skb) | ||
70 | { | ||
71 | return (struct sctphdr *)skb->h.raw; | ||
72 | } | ||
73 | #endif | ||
74 | |||
66 | /* Section 3.2. Chunk Field Descriptions. */ | 75 | /* Section 3.2. Chunk Field Descriptions. */ |
67 | typedef struct sctp_chunkhdr { | 76 | typedef struct sctp_chunkhdr { |
68 | __u8 type; | 77 | __u8 type; |
diff --git a/net/sctp/input.c b/net/sctp/input.c index 9311b5ddf5c0..3a322c584c74 100644 --- a/net/sctp/input.c +++ b/net/sctp/input.c | |||
@@ -79,14 +79,10 @@ static void sctp_add_backlog(struct sock *sk, struct sk_buff *skb); | |||
79 | /* Calculate the SCTP checksum of an SCTP packet. */ | 79 | /* Calculate the SCTP checksum of an SCTP packet. */ |
80 | static inline int sctp_rcv_checksum(struct sk_buff *skb) | 80 | static inline int sctp_rcv_checksum(struct sk_buff *skb) |
81 | { | 81 | { |
82 | struct sctphdr *sh; | ||
83 | __u32 cmp, val; | ||
84 | struct sk_buff *list = skb_shinfo(skb)->frag_list; | 82 | struct sk_buff *list = skb_shinfo(skb)->frag_list; |
85 | 83 | struct sctphdr *sh = sctp_hdr(skb); | |
86 | sh = (struct sctphdr *) skb->h.raw; | 84 | __u32 cmp = ntohl(sh->checksum); |
87 | cmp = ntohl(sh->checksum); | 85 | __u32 val = sctp_start_cksum((__u8 *)sh, skb_headlen(skb)); |
88 | |||
89 | val = sctp_start_cksum((__u8 *)sh, skb_headlen(skb)); | ||
90 | 86 | ||
91 | for (; list; list = list->next) | 87 | for (; list; list = list->next) |
92 | val = sctp_update_cksum((__u8 *)list->data, skb_headlen(list), | 88 | val = sctp_update_cksum((__u8 *)list->data, skb_headlen(list), |
@@ -138,7 +134,7 @@ int sctp_rcv(struct sk_buff *skb) | |||
138 | if (skb_linearize(skb)) | 134 | if (skb_linearize(skb)) |
139 | goto discard_it; | 135 | goto discard_it; |
140 | 136 | ||
141 | sh = (struct sctphdr *) skb->h.raw; | 137 | sh = sctp_hdr(skb); |
142 | 138 | ||
143 | /* Pull up the IP and SCTP headers. */ | 139 | /* Pull up the IP and SCTP headers. */ |
144 | __skb_pull(skb, skb_transport_offset(skb)); | 140 | __skb_pull(skb, skb_transport_offset(skb)); |
@@ -905,7 +901,7 @@ static struct sctp_association *__sctp_rcv_init_lookup(struct sk_buff *skb, | |||
905 | struct sctp_association *asoc; | 901 | struct sctp_association *asoc; |
906 | union sctp_addr addr; | 902 | union sctp_addr addr; |
907 | union sctp_addr *paddr = &addr; | 903 | union sctp_addr *paddr = &addr; |
908 | struct sctphdr *sh = (struct sctphdr *) skb->h.raw; | 904 | struct sctphdr *sh = sctp_hdr(skb); |
909 | sctp_chunkhdr_t *ch; | 905 | sctp_chunkhdr_t *ch; |
910 | union sctp_params params; | 906 | union sctp_params params; |
911 | sctp_init_chunk_t *init; | 907 | sctp_init_chunk_t *init; |
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c index 001be2de0b3c..0992bc5bb528 100644 --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c | |||
@@ -390,7 +390,7 @@ static void sctp_v6_from_skb(union sctp_addr *addr,struct sk_buff *skb, | |||
390 | addr->v6.sin6_flowinfo = 0; /* FIXME */ | 390 | addr->v6.sin6_flowinfo = 0; /* FIXME */ |
391 | addr->v6.sin6_scope_id = ((struct inet6_skb_parm *)skb->cb)->iif; | 391 | addr->v6.sin6_scope_id = ((struct inet6_skb_parm *)skb->cb)->iif; |
392 | 392 | ||
393 | sh = (struct sctphdr *) skb->h.raw; | 393 | sh = sctp_hdr(skb); |
394 | if (is_saddr) { | 394 | if (is_saddr) { |
395 | *port = sh->source; | 395 | *port = sh->source; |
396 | from = &ipv6_hdr(skb)->saddr; | 396 | from = &ipv6_hdr(skb)->saddr; |
@@ -765,7 +765,7 @@ static void sctp_inet6_skb_msgname(struct sk_buff *skb, char *msgname, | |||
765 | if (msgname) { | 765 | if (msgname) { |
766 | sctp_inet6_msgname(msgname, addr_len); | 766 | sctp_inet6_msgname(msgname, addr_len); |
767 | sin6 = (struct sockaddr_in6 *)msgname; | 767 | sin6 = (struct sockaddr_in6 *)msgname; |
768 | sh = (struct sctphdr *)skb->h.raw; | 768 | sh = sctp_hdr(skb); |
769 | sin6->sin6_port = sh->source; | 769 | sin6->sin6_port = sh->source; |
770 | 770 | ||
771 | /* Map ipv4 address into v4-mapped-on-v6 address. */ | 771 | /* Map ipv4 address into v4-mapped-on-v6 address. */ |
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index 08f92ba4ebd7..7c28c9b959e2 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c | |||
@@ -235,7 +235,7 @@ static void sctp_v4_from_skb(union sctp_addr *addr, struct sk_buff *skb, | |||
235 | port = &addr->v4.sin_port; | 235 | port = &addr->v4.sin_port; |
236 | addr->v4.sin_family = AF_INET; | 236 | addr->v4.sin_family = AF_INET; |
237 | 237 | ||
238 | sh = (struct sctphdr *) skb->h.raw; | 238 | sh = sctp_hdr(skb); |
239 | if (is_saddr) { | 239 | if (is_saddr) { |
240 | *port = sh->source; | 240 | *port = sh->source; |
241 | from = &ip_hdr(skb)->saddr; | 241 | from = &ip_hdr(skb)->saddr; |
@@ -731,13 +731,11 @@ static void sctp_inet_event_msgname(struct sctp_ulpevent *event, char *msgname, | |||
731 | /* Initialize and copy out a msgname from an inbound skb. */ | 731 | /* Initialize and copy out a msgname from an inbound skb. */ |
732 | static void sctp_inet_skb_msgname(struct sk_buff *skb, char *msgname, int *len) | 732 | static void sctp_inet_skb_msgname(struct sk_buff *skb, char *msgname, int *len) |
733 | { | 733 | { |
734 | struct sctphdr *sh; | ||
735 | struct sockaddr_in *sin; | ||
736 | |||
737 | if (msgname) { | 734 | if (msgname) { |
735 | struct sctphdr *sh = sctp_hdr(skb); | ||
736 | struct sockaddr_in *sin = (struct sockaddr_in *)msgname; | ||
737 | |||
738 | sctp_inet_msgname(msgname, len); | 738 | sctp_inet_msgname(msgname, len); |
739 | sin = (struct sockaddr_in *)msgname; | ||
740 | sh = (struct sctphdr *)skb->h.raw; | ||
741 | sin->sin_port = sh->source; | 739 | sin->sin_port = sh->source; |
742 | sin->sin_addr.s_addr = ip_hdr(skb)->saddr; | 740 | sin->sin_addr.s_addr = ip_hdr(skb)->saddr; |
743 | } | 741 | } |