리눅스 디바이스 드라이버에서 arp 를 보내다 질문 드립니다.

dicecorp의 이미지

디바이스 드라이버에서 arp 를 전송하려고 합니다.

arp 패킷 구조를 보니까
|<--------->|<-------->|<--->|<--------->|<-------->|
  dst mac src mac type  data   crc
   (6)   (6)   (2)  (46-1500) (4)

위와 같이 구성이 되어 있더군요

질문 1.
arp 패킷의 최소 크기가 60 이 맞는지요? 다른 곳에 있는 코드를 참조하니까 60 이상일 경우 60 을 넣고 있길래 그 코드를 참조했습니다.
위 그림을 참조했을때 crc를 뺐을 경우 60이 나오네요

질문 2.
sk_buff->data 멤버에 위의 dst mac 부터 data까지 들어가는지요?
따라서 size는 60 이 되는게 맞는지 궁금합니다.

질문 3.
crc 는 dst mac 부터 data까지 구하는 것인지요?

* 참고로 아래코드의 브로드캐스트 맥 주소의
{0xff, 0x00, 0xff, 0xff, 0xff, 0xff}; 두 번째 필드를 0xff 로 했습니다.
이유는 패킷이 나가는 지 보기 위해서입니다. (참고로 무선랜입니다.)

struct arp_data{
        unsigned char   ar_sha[ETH_ALEN];//sender HW addr
        unsigned long   ar_sip;                  //sender IP addr
        unsigned char   ar_tha[ETH_ALEN];//target HW addr
        unsigned long   ar_tip;                  //target IP addr
}__attribute__((packed));
 
 
struct sk_buff *skb;
struct arp_data *arp_request;
int size;
unsigned char sum_crc;
unsigned char broadcast_mac[6] =
        {0xff, 0x00, 0xff, 0xff, 0xff, 0xff};
 
// arp packet send
size = 2 * ETH_ALEN + 2 +
        sizeof(struct arphdr) + sizeof(struct arp_data) + 4;
 
if (size < 60)
        size = 60;
 
if( (skb = dev_alloc_skb(size)) == NULL){
        printk("_SDBG_ dev alloc failed\n");
        return ;
}
 
skb->mac.ethernet  = (struct ethhdr *)skb->data;
skb->dev = priv->dev;
skb->len = size;
skb->protocol = htons(ETH_P_ARP);
memcpy(skb->mac.ethernet->h_dest, broadcast_mac, ETH_ALEN); //h_dest
memcpy(skb->mac.ethernet->h_source, priv->dev->dev_addr, ETH_ALEN);//h_source
skb->mac.ethernet->h_proto = ETH_P_ARP; //h_proto
 
skb->nh.arph = (struct arphdr*)(skb->data + sizeof(struct ethhdr));
skb->nh.arph->ar_hrd = ARPHRD_ETHER;
skb->nh.arph->ar_pro = EHT_P_IP;
skb->nh.arph->ar_hln = 0x06;
skb->nh.arph->ar_pln = 0x04;
skb->nh.arph->ar_op = ARPOP_REQUEST;
 
sum_crc = byte-check_sum(skb->data, size);
skb->data[size -4] = sum_crc;
 
dev_queue_xmit(skb);

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.