uipc_sockbuf.c (17047) | uipc_sockbuf.c (17096) |
---|---|
1/* 2 * Copyright (c) 1982, 1986, 1988, 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 172 unchanged lines hidden (view full) --- 181 if (connstatus) { 182 TAILQ_INSERT_TAIL(&head->so_comp, so, so_list); 183 so->so_state |= SS_COMP; 184 } else { 185 TAILQ_INSERT_TAIL(&head->so_incomp, so, so_list); 186 so->so_state |= SS_INCOMP; 187 } 188 head->so_qlen++; | 1/* 2 * Copyright (c) 1982, 1986, 1988, 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 172 unchanged lines hidden (view full) --- 181 if (connstatus) { 182 TAILQ_INSERT_TAIL(&head->so_comp, so, so_list); 183 so->so_state |= SS_COMP; 184 } else { 185 TAILQ_INSERT_TAIL(&head->so_incomp, so, so_list); 186 so->so_state |= SS_INCOMP; 187 } 188 head->so_qlen++; |
189 if ((*so->so_proto->pr_usrreq)(so, PRU_ATTACH, 190 (struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0)) { | 189 if ((*so->so_proto->pr_usrreqs->pru_attach)(so, 0)) { |
191 if (so->so_state & SS_COMP) { 192 TAILQ_REMOVE(&head->so_comp, so, so_list); 193 } else { 194 TAILQ_REMOVE(&head->so_incomp, so, so_list); 195 } 196 head->so_qlen--; 197 (void) free((caddr_t)so, M_SOCKET); 198 return ((struct socket *)0); --- 564 unchanged lines hidden (view full) --- 763 */ 764 765/* syntactic sugar */ 766#define nomb (struct mbuf *)0 767 768static int 769old_abort(struct socket *so) 770{ | 190 if (so->so_state & SS_COMP) { 191 TAILQ_REMOVE(&head->so_comp, so, so_list); 192 } else { 193 TAILQ_REMOVE(&head->so_incomp, so, so_list); 194 } 195 head->so_qlen--; 196 (void) free((caddr_t)so, M_SOCKET); 197 return ((struct socket *)0); --- 564 unchanged lines hidden (view full) --- 762 */ 763 764/* syntactic sugar */ 765#define nomb (struct mbuf *)0 766 767static int 768old_abort(struct socket *so) 769{ |
771 return so->so_proto->pr_usrreq(so, PRU_ABORT, nomb, nomb, nomb); | 770 return so->so_proto->pr_ousrreq(so, PRU_ABORT, nomb, nomb, nomb); |
772} 773 774static int 775old_accept(struct socket *so, struct mbuf *nam) 776{ | 771} 772 773static int 774old_accept(struct socket *so, struct mbuf *nam) 775{ |
777 return so->so_proto->pr_usrreq(so, PRU_ACCEPT, nomb, nam, nomb); | 776 return so->so_proto->pr_ousrreq(so, PRU_ACCEPT, nomb, nam, nomb); |
778} 779 780static int 781old_attach(struct socket *so, int proto) 782{ | 777} 778 779static int 780old_attach(struct socket *so, int proto) 781{ |
783 return so->so_proto->pr_usrreq(so, PRU_ATTACH, nomb, | 782 return so->so_proto->pr_ousrreq(so, PRU_ATTACH, nomb, |
784 (struct mbuf *)proto, /* XXX */ 785 nomb); 786} 787 788static int 789old_bind(struct socket *so, struct mbuf *nam) 790{ | 783 (struct mbuf *)proto, /* XXX */ 784 nomb); 785} 786 787static int 788old_bind(struct socket *so, struct mbuf *nam) 789{ |
791 return so->so_proto->pr_usrreq(so, PRU_BIND, nomb, nam, nomb); | 790 return so->so_proto->pr_ousrreq(so, PRU_BIND, nomb, nam, nomb); |
792} 793 794static int 795old_connect(struct socket *so, struct mbuf *nam) 796{ | 791} 792 793static int 794old_connect(struct socket *so, struct mbuf *nam) 795{ |
797 return so->so_proto->pr_usrreq(so, PRU_CONNECT, nomb, nam, nomb); | 796 return so->so_proto->pr_ousrreq(so, PRU_CONNECT, nomb, nam, nomb); |
798} 799 800static int 801old_connect2(struct socket *so1, struct socket *so2) 802{ | 797} 798 799static int 800old_connect2(struct socket *so1, struct socket *so2) 801{ |
803 return so1->so_proto->pr_usrreq(so1, PRU_CONNECT2, nomb, | 802 return so1->so_proto->pr_ousrreq(so1, PRU_CONNECT2, nomb, |
804 (struct mbuf *)so2, nomb); 805} 806 807static int | 803 (struct mbuf *)so2, nomb); 804} 805 806static int |
808old_control(struct socket *so, int cmd, caddr_t data) | 807old_control(struct socket *so, int cmd, caddr_t data, struct ifnet *ifp) |
809{ | 808{ |
810 return so->so_proto->pr_usrreq(so, PRU_CONTROL, (struct mbuf *)cmd, 811 (struct mbuf *)data, nomb); | 809 return so->so_proto->pr_ousrreq(so, PRU_CONTROL, (struct mbuf *)cmd, 810 (struct mbuf *)data, 811 (struct mbuf *)ifp); |
812} 813 814static int 815old_detach(struct socket *so) 816{ | 812} 813 814static int 815old_detach(struct socket *so) 816{ |
817 return so->so_proto->pr_usrreq(so, PRU_DETACH, nomb, nomb, nomb); | 817 return so->so_proto->pr_ousrreq(so, PRU_DETACH, nomb, nomb, nomb); |
818} 819 820static int 821old_disconnect(struct socket *so) 822{ | 818} 819 820static int 821old_disconnect(struct socket *so) 822{ |
823 return so->so_proto->pr_usrreq(so, PRU_DISCONNECT, nomb, nomb, nomb); | 823 return so->so_proto->pr_ousrreq(so, PRU_DISCONNECT, nomb, nomb, nomb); |
824} 825 826static int 827old_listen(struct socket *so) 828{ | 824} 825 826static int 827old_listen(struct socket *so) 828{ |
829 return so->so_proto->pr_usrreq(so, PRU_LISTEN, nomb, nomb, nomb); | 829 return so->so_proto->pr_ousrreq(so, PRU_LISTEN, nomb, nomb, nomb); |
830} 831 832static int 833old_peeraddr(struct socket *so, struct mbuf *nam) 834{ | 830} 831 832static int 833old_peeraddr(struct socket *so, struct mbuf *nam) 834{ |
835 return so->so_proto->pr_usrreq(so, PRU_PEERADDR, nomb, nam, nomb); | 835 return so->so_proto->pr_ousrreq(so, PRU_PEERADDR, nomb, nam, nomb); |
836} 837 838static int 839old_rcvd(struct socket *so, int flags) 840{ | 836} 837 838static int 839old_rcvd(struct socket *so, int flags) 840{ |
841 return so->so_proto->pr_usrreq(so, PRU_RCVD, nomb, | 841 return so->so_proto->pr_ousrreq(so, PRU_RCVD, nomb, |
842 (struct mbuf *)flags, /* XXX */ 843 nomb); 844} 845 846static int 847old_rcvoob(struct socket *so, struct mbuf *m, int flags) 848{ | 842 (struct mbuf *)flags, /* XXX */ 843 nomb); 844} 845 846static int 847old_rcvoob(struct socket *so, struct mbuf *m, int flags) 848{ |
849 return so->so_proto->pr_usrreq(so, PRU_RCVOOB, m, | 849 return so->so_proto->pr_ousrreq(so, PRU_RCVOOB, m, |
850 (struct mbuf *)flags, /* XXX */ 851 nomb); 852} 853 854static int 855old_send(struct socket *so, int flags, struct mbuf *m, struct mbuf *addr, 856 struct mbuf *control) 857{ 858 int req; 859 860 if (flags & PRUS_OOB) { 861 req = PRU_SENDOOB; 862 } else if(flags & PRUS_EOF) { 863 req = PRU_SEND_EOF; 864 } else { 865 req = PRU_SEND; 866 } | 850 (struct mbuf *)flags, /* XXX */ 851 nomb); 852} 853 854static int 855old_send(struct socket *so, int flags, struct mbuf *m, struct mbuf *addr, 856 struct mbuf *control) 857{ 858 int req; 859 860 if (flags & PRUS_OOB) { 861 req = PRU_SENDOOB; 862 } else if(flags & PRUS_EOF) { 863 req = PRU_SEND_EOF; 864 } else { 865 req = PRU_SEND; 866 } |
867 return so->so_proto->pr_usrreq(so, req, m, addr, control); | 867 return so->so_proto->pr_ousrreq(so, req, m, addr, control); |
868} 869 870static int 871old_sense(struct socket *so, struct stat *sb) 872{ | 868} 869 870static int 871old_sense(struct socket *so, struct stat *sb) 872{ |
873 return so->so_proto->pr_usrreq(so, PRU_SENSE, (struct mbuf *)sb, | 873 return so->so_proto->pr_ousrreq(so, PRU_SENSE, (struct mbuf *)sb, |
874 nomb, nomb); 875} 876 877static int 878old_shutdown(struct socket *so) 879{ | 874 nomb, nomb); 875} 876 877static int 878old_shutdown(struct socket *so) 879{ |
880 return so->so_proto->pr_usrreq(so, PRU_SHUTDOWN, nomb, nomb, nomb); | 880 return so->so_proto->pr_ousrreq(so, PRU_SHUTDOWN, nomb, nomb, nomb); |
881} 882 883static int 884old_sockaddr(struct socket *so, struct mbuf *nam) 885{ | 881} 882 883static int 884old_sockaddr(struct socket *so, struct mbuf *nam) 885{ |
886 return so->so_proto->pr_usrreq(so, PRU_SOCKADDR, nomb, nam, nomb); | 886 return so->so_proto->pr_ousrreq(so, PRU_SOCKADDR, nomb, nam, nomb); |
887} 888 889struct pr_usrreqs pru_oldstyle = { 890 old_abort, old_accept, old_attach, old_bind, old_connect, 891 old_connect2, old_control, old_detach, old_disconnect, 892 old_listen, old_peeraddr, old_rcvd, old_rcvoob, old_send, 893 old_sense, old_shutdown, old_sockaddr 894}; 895 | 887} 888 889struct pr_usrreqs pru_oldstyle = { 890 old_abort, old_accept, old_attach, old_bind, old_connect, 891 old_connect2, old_control, old_detach, old_disconnect, 892 old_listen, old_peeraddr, old_rcvd, old_rcvoob, old_send, 893 old_sense, old_shutdown, old_sockaddr 894}; 895 |
896#endif /* PRU_OLDSTYLE */ 897 |
|
896/* | 898/* |
897 * This function is glue going the other way. It is present to allow 898 * for this interface to be actively developed from both directions 899 * (i.e., work on the kernel and protocol stacks proceeds simultaneously). 900 * It is expected that this function will probably cease to exist much 901 * sooner than the pru_oldstyle interface, above, will, because once the 902 * all of the high-kernel use of pr_usrreq() is removed the function is 903 * no longer needed. | 899 * Some routines that return EOPNOTSUPP for entry points that are not 900 * supported by a protocol. Fill in as needed. |
904 */ 905int | 901 */ 902int |
906pr_newstyle_usrreq(struct socket *so, int req, struct mbuf *m, 907 struct mbuf *nam, struct mbuf *control) | 903pru_connect2_notsupp(struct socket *so1, struct socket *so2) |
908{ | 904{ |
909 struct pr_usrreqs *pru = so->so_proto->pr_usrreqs; 910 911 switch(req) { 912 case PRU_ABORT: 913 return pru->pru_abort(so); 914 915 case PRU_ACCEPT: 916 return pru->pru_accept(so, nam); 917 918 case PRU_ATTACH: 919 return pru->pru_attach(so, (int)nam); 920 921 case PRU_BIND: 922 return pru->pru_bind(so, nam); 923 924 case PRU_CONNECT: 925 return pru->pru_connect(so, nam); 926 927 case PRU_CONNECT2: 928 return pru->pru_connect2(so, (struct socket *)nam); 929 930 case PRU_CONTROL: 931 return pru->pru_control(so, (int)m, (caddr_t)nam); 932 933 case PRU_DETACH: 934 return pru->pru_detach(so); 935 936 case PRU_DISCONNECT: 937 return pru->pru_disconnect(so); 938 939 case PRU_LISTEN: 940 return pru->pru_listen(so); 941 942 case PRU_PEERADDR: 943 return pru->pru_peeraddr(so, nam); 944 945 case PRU_RCVD: 946 return pru->pru_rcvd(so, (int)nam); 947 948 case PRU_RCVOOB: 949 return pru->pru_rcvoob(so, m, (int)nam); 950 951 case PRU_SEND: 952 return pru->pru_send(so, 0, m, nam, control); 953 954 case PRU_SENDOOB: 955 return pru->pru_send(so, PRUS_OOB, m, nam, control); 956 957 case PRU_SEND_EOF: 958 return pru->pru_send(so, PRUS_EOF, m, nam, control); 959 960 case PRU_SENSE: 961 return pru->pru_sense(so, (struct stat *)m); 962 963 case PRU_SHUTDOWN: 964 return pru->pru_shutdown(so); 965 966 case PRU_SOCKADDR: 967 return pru->pru_sockaddr(so, nam); 968 969 } 970 971 panic("pru_newstyle_usrreq: unhandled request %d", req); | 905 return EOPNOTSUPP; |
972} | 906} |
973 974#endif /* PRU_OLDSTYLE */ | |