first and last commit

This commit is contained in:
Chris Nutter committed 2023-07-08 13:03:17 -07:00
commit 1bf4efd552
2612 files changed
+636500

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
*
* This document is the property of Apple Computer, Inc.
* It is considered confidential and proprietary.
*
* This document may not be reproduced or transmitted in any form,
* in whole or in part, without the express written permission of
* Apple Computer, Inc.
*/
#ifndef __ARP_H__
#define __ARP_H__
#include <sys/types.h>
__BEGIN_DECLS
#define ARP_OFFSET_HTYPE 0
#define ARP_OFFSET_PTYPE 2
#define ARP_OFFSET_HLEN 4
#define ARP_OFFSET_PLEN 5
#define ARP_OFFSET_OPER 6
#define ARP_OFFSET_SHA 8
int arp_layer(bool on);
int arp_get_macaddr(uint32_t ip,char *mac);
int arp_fill(uint32_t ip, utime_t timeout); /* send arp requests until it is satisfied or timeout */
void arp_dump_table(void);
#define ARP_CACHE_SIZE 32
typedef struct arp_cache_entry {
uint32_t ip;
char mac[6];
struct arp_cache_entry *next;
} arp_cache_entry_t;
typedef struct arp_cache {
arp_cache_entry_t cache[ARP_CACHE_SIZE];
} arp_cache_t;
__END_DECLS
#endif
+41
View File
@@ -0,0 +1,41 @@
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
*
* This document is the property of Apple Computer, Inc.
* It is considered confidential and proprietary.
*
* This document may not be reproduced or transmitted in any form,
* in whole or in part, without the express written permission of
* Apple Computer, Inc.
*/
#ifndef __CALLBACKS_H__
#define __CALLBACKS_H__
#include <sys/types.h>
__BEGIN_DECLS
typedef int (*callback_handler)(char *data,int offset,int len,void *prevlayerdata);
struct listentry;
typedef struct listentry {
int cb_id;
int port; //port/service/etc
callback_handler callback;
struct listentry *next;
} listentry_t;
typedef struct callbacks {
listentry_t *first;
}callbacks_t;
int registerCallback(callbacks_t *,int port,callback_handler cb);
int unregisterCallback(callbacks_t *cbs,int cb_id);
callback_handler find_callback(callbacks_t *cbs,int port);
__END_DECLS
#endif
+39
View File
@@ -0,0 +1,39 @@
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
*
* This document is the property of Apple Computer, Inc.
* It is considered confidential and proprietary.
*
* This document may not be reproduced or transmitted in any form,
* in whole or in part, without the express written permission of
* Apple Computer, Inc.
*/
#ifndef __ETHERNET_H__
#define __ETHERNET_H__
#include <sys/types.h>
#include <sys/callout.h>
#include "callbacks.h"
#include "xp.h"
__BEGIN_DECLS
#define ETHERTYPE_ARP 0x806
#define ETHERTYPE_IPV4 0x800
#define ETHERNET_OFFSET 14
int registerEtherTypeHandler(int type,callback_handler cb);
int unregisterEtherTypeHandler(int id);
int add_eth_and_transmit(mymbuf_t *,char *dstmac,int ethertype);
void ethernet_init(void);
void ethernet_uninit(void);
void ethernet_workloop(struct callout *c, void *param);
void ethernet_input(mymbuf_t *inputbuf);
__END_DECLS
#endif
+29
View File
@@ -0,0 +1,29 @@
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
*
* This document is the property of Apple Computer, Inc.
* It is considered confidential and proprietary.
*
* This document may not be reproduced or transmitted in any form,
* in whole or in part, without the express written permission of
* Apple Computer, Inc.
*/
#ifndef __ICMP_H___
#define __ICMP_H__
#include <sys/types.h>
#include "callbacks.h"
__BEGIN_DECLS
#define ICMP_ECHO 8
#define ICMP_ECHOREPLY 0
int registerICMPHandler(int messagetype,callback_handler cb);
int unregisterICMPHandler(int id);
int icmp_layer(bool on);
__END_DECLS
#endif
+35
View File
@@ -0,0 +1,35 @@
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
*
* This document is the property of Apple Computer, Inc.
* It is considered confidential and proprietary.
*
* This document may not be reproduced or transmitted in any form,
* in whole or in part, without the express written permission of
* Apple Computer, Inc.
*/
#ifndef __IPV4_H__
#define __IPV4_H__
#include <sys/types.h>
#include "callbacks.h"
#include "xp.h"
__BEGIN_DECLS
#define IPV4_ICMP 1
#define IPV4_TCP 6
#define IPV4_UDP 17
int ipv4_layer(bool on);
int registerIPV4Handler(int protocol,callback_handler handler);
int unregisterIPV4Handler(int id);
uint32_t ipv4_get_ip();
void ipv4_set_ip(uint32_t ip);
int transmit_and_add_ipv4(mymbuf_t *mbuf,uint32_t dest,int protocol);
__END_DECLS
#endif
+54
View File
@@ -0,0 +1,54 @@
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
*
* This document is the property of Apple Computer, Inc.
* It is considered confidential and proprietary.
*
* This document may not be reproduced or transmitted in any form,
* in whole or in part, without the express written permission of
* Apple Computer, Inc.
*/
#ifndef __LIB_NET_MBUF_H
#define __LIB_NET_MBUF_H
#include <sys/types.h>
__BEGIN_DECLS
#define USE_BUILTIN_MBUF 1
#if defined(USE_BUILTIN_MBUF) && USE_BUILTIN_MBUF
struct mbufentry;
typedef struct mbufentry {
int flag;
int len;
char *data;
struct mbufentry *next;
} mbufentry_t;
typedef struct mymbuf {
mbufentry_t *first;
int allocated_length;
int current_length;
char *primarydata;
int offset;
}mymbuf_t;
#else
#error "Unsupported platform"
#endif
mymbuf_t * mbuf_initialize(int packetsize,int header,int trailer);
void mbuf_destroy(mymbuf_t *data);
char* mbuf_head(mymbuf_t *buffer, int len);
char* mbuf_tail(mymbuf_t *buffer, int len);
int mbuf_getlength(mymbuf_t *buffer);
char * mbuf_getlinear(mymbuf_t *buffer);
void mbuf_setlength(mymbuf_t *buffer,int len);
void mbuf_setoffset(mymbuf_t *buffer,int offset);
int mbuf_getallocatedlength(mymbuf_t *buffer);
int mbuf_copy(mymbuf_t *dest, const mymbuf_t *src);
__END_DECLS
#endif
+32
View File
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
*
* This document is the property of Apple Computer, Inc.
* It is considered confidential and proprietary.
*
* This document may not be reproduced or transmitted in any form,
* in whole or in part, without the express written permission of
* Apple Computer, Inc.
*/
#ifndef __UDP_H__
#define __UDP_H__
#include <sys/types.h>
__BEGIN_DECLS
int transmit_udp(mymbuf_t *data, uint32_t toip,int toport, int fromport);
int unregisterUDPHandler(int id);
int registerUDPHandler(int port,callback_handler cb);
int udp_layer(bool on);
typedef struct udpinfo {
uint32_t srcip;
uint16_t srcport;
uint16_t length;
} udpinfo_t;
__END_DECLS
#endif
+38
View File
@@ -0,0 +1,38 @@
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
*
* This document is the property of Apple Computer, Inc.
* It is considered confidential and proprietary.
*
* This document may not be reproduced or transmitted in any form,
* in whole or in part, without the express written permission of
* Apple Computer, Inc.
*/
#ifndef __XP_H__
#define __XP_H__
#include <sys/types.h>
#include <stdint.h>
#include <lib/net/mbuf.h>
__BEGIN_DECLS
//Card specific instructions.
int xp_initialize(void);
int xp_getmac(uint8_t *addr);
void xp_packet_input(void *ethptr, mymbuf_t *inputbuf);
//mymbuf_t * xp_get_packet(mymbuf_t *);
int xp_transmit_packet(mymbuf_t *buffer);
#define htons(A) ( (((A) & 0xff00) >> 8) | \
((A) & 0x00ff) << 8)
#define htonl(A) ( (((A) & 0xff000000) >> 24) | \
(((A) & 0x00ff0000) >> 8) | \
(((A) & 0x0000ff00) << 8) | \
(((A) & 0x000000ff) << 24))
#define ntohs htons
#define ntohl htonl
__END_DECLS
#endif